JOID
final class JOID
Package: dev.joid.lib · Module: core · Source: JOID.java
Entry point that opens and closes UIs, finds the open ones and runs code once JOID has loaded.
Description
Section titled “Description”JOID holds static methods only, apart from inst().load() that the backend calls.
open, close, forceOpen and forceClose can be called from any thread: off the render thread, JOID runs them at the next frame.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
JOID | inst() factory | The single instance of JOID. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
this | load() fluent | Loads JOID once: prints the version, the mode and the data and cache folders, cleans the cache in the background, loads the fonts of the dev tools in dev mode, installs the hook that closes the open UIs and saves the stores when the JVM stops, then runs the onReady listeners. |
void | onReady(Runnable callback) static | Runs the listener on the render thread once JOID has loaded; when it has already loaded, at once on the render thread, or at the start of the next frame from another thread. |
void | checkVersion(String version) static | Throws an IllegalStateException when this version has another major number than the loaded core. |
String | readVersion(Class<?> owner, String resource) static | Reads the version property of a properties file found next to this class, or development when the file or the property is missing. |
boolean | isOpen(UI ui) static | If true, this UI is open in a UI bridge. |
boolean | isOpen(Class<? extends UI> uiClass) static | If true, a UI of this class (or of a subclass) is open in any UI bridge. |
T | getUi(Class | The first open UI of this class or of a subclass, searched in every UI bridge from the highest priority down, or null when none is open. |
IUIBridge | open(UI ui) static | Opens the UI in the UI bridge that already holds it, otherwise in the bridge of highest priority whose canHandle accepts it, and returns that bridge. |
void | close(UI ui) static | Closes the UI: the beforeClose listeners can refuse, then the closing transition plays. |
IUIBridge | forceOpen(UI ui) static | Closes every UI of the bridge that accepts this one, without asking them and without transition, then opens it; returns that bridge. |
void | forceClose(UI ui) static | Closes the UI at once, without asking the beforeClose listeners and without its closing transition. |
boolean | isReady() | If true, load() has finished; another thread sees it at once. |
Constants and fields
Section titled “Constants and fields”| Type | Name | Value | Summary |
|---|---|---|---|
String | VERSION | JOID.readVersion(JOID.class, "joid.properties") | Version of the JOID core on the classpath, read from its jar; development when the classes do not come from a released jar. |
Creation details
Section titled “Creation details”JOID inst() factory
The single instance of JOID.
Method details
Section titled “Method details”this load() fluent
Thread: runs on the render thread.
Loads JOID once: prints the version, the mode and the data and cache folders, cleans the cache in the background, loads the fonts of the dev tools in dev mode, installs the hook that closes the open UIs and saves the stores when the JVM stops, then runs the onReady listeners.
Backend calls it at the end of register(); a second call does nothing.
onReady
Section titled “onReady”void onReady(Runnable callback) static
Thread: runs on the render thread.
Runs the listener on the render thread once JOID has loaded; when it has already loaded, at once on the render thread, or at the start of the next frame from another thread. A listener given before JOID has loaded that throws prints a warning and does not stop the next ones; once JOID has loaded, the exception reaches a caller on the render thread, and a call from another thread prints the warning of a failed render-thread task.
checkVersion
Section titled “checkVersion”void checkVersion(String version) static
Throws an IllegalStateException when this version has another major number than the loaded core.
A backend calls it with the version it was built for; a development version on either side always passes.
readVersion
Section titled “readVersion”String readVersion(Class<?> owner, String resource) static
Reads the version property of a properties file found next to this class, or development when the file or the property is missing.
isOpen
Section titled “isOpen”boolean isOpen(UI ui) static
If true, this UI is open in a UI bridge.
boolean isOpen(Class<? extends UI> uiClass) static
If true, a UI of this class (or of a subclass) is open in any UI bridge.
<T extends UI> T getUi(Class<T> uiClass) static
The first open UI of this class or of a subclass, searched in every UI bridge from the highest priority down, or null when none is open.
IUIBridge open(UI ui) static
Thread: runs on the render thread.
Opens the UI in the UI bridge that already holds it, otherwise in the bridge of highest priority whose canHandle accepts it, and returns that bridge.
A screen replaces the open screens, a popup or an overlay opens above them, and a UI already open moves to the top.
Throws an IllegalStateException when no registered bridge accepts the UI.
void close(UI ui) static
Thread: runs on the render thread.
Closes the UI: the beforeClose listeners can refuse, then the closing transition plays.
A UI that is not open is only removed from its bridge.
forceOpen
Section titled “forceOpen”IUIBridge forceOpen(UI ui) static
Thread: runs on the render thread.
Closes every UI of the bridge that accepts this one, without asking them and without transition, then opens it; returns that bridge.
Throws an IllegalStateException when no registered bridge accepts the UI.
forceClose
Section titled “forceClose”void forceClose(UI ui) static
Thread: runs on the render thread.
Closes the UI at once, without asking the beforeClose listeners and without its closing transition.
isReady
Section titled “isReady”boolean isReady()
If true, load() has finished; another thread sees it at once.
Constant and field details
Section titled “Constant and field details”VERSION
Section titled “VERSION”String VERSION
Version of the JOID core on the classpath, read from its jar; development when the classes do not come from a released jar.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
