Class PuiBase<M,C extends ControllerBase<M>>
- Direct Known Subclasses:
GamePUI
In our scenario we also have a GUI.
We have to avoid that one of the UIs is blocked because the other UI has to perform a long-running task.
Therefore, we need an additional "worker-thread" in both UIs.
For JavaFX-based GUIs that's already available (the JavaFX Application Thread).
For PUIs we need to do that ourselves. It's implemented as a provider/consumer-pattern
(see ConcurrentTaskQueue
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Second step to specify an observer.class
Second step to specify an observer. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
Intermediate solution for TestCase support.default void
needs to be called inside the constructor of your UI-partvoid
completely initialize all necessary UI-elements (like buttons, text-fields, etc.default void
Everything that needs to be done to initialize the UI-part itself.protected <V> PuiBase<M,
C>.ArrayUpdater<V> onChangeOf
(ObservableArray<V> observableArray) First step to register an observer.onChangeOf
(ObservableValue<V> observableValue) First step to register an observer.void
default void
setupModelToUiBindings
(M model) Whenever an 'ObservableValue' in 'model' changes, the UI must be updated.default void
setupUiToActionBindings
(C controller) Triggering some action on Controller if the user interacts with the UI.void
shutdown()
default void
At the Startup, this method gets called.
-
Field Details
-
pi4J
protected final com.pi4j.context.Context pi4J
-
-
Constructor Details
-
PuiBase
-
-
Method Details
-
shutdown
public void shutdown() -
async
-
runLater
-
awaitCompletion
public void awaitCompletion()Intermediate solution for TestCase support.Best solution would be that 'action' of 'runLater' is executed on calling thread.
Waits until all current actions in actionQueue are completed.
-
onChangeOf
First step to register an observer.- Parameters:
observableValue
- the value that should trigger some PUI-updates- Returns:
- an Updater to specify what needs to be done whenever observableValue changes
-
onChangeOf
First step to register an observer.- Parameters:
observableArray
- the value that should trigger some PUI-updates- Returns:
- an Updater to specify what needs to be done whenever observableValue changes
-
init
needs to be called inside the constructor of your UI-part -
initializeSelf
default void initializeSelf()Everything that needs to be done to initialize the UI-part itself.For GUIs loading stylesheet-files or additional fonts are typical examples.
-
initializeParts
void initializeParts()completely initialize all necessary UI-elements (like buttons, text-fields, etc. on GUI or distance sensors on PUI ) -
setupUiToActionBindings
Triggering some action on Controller if the user interacts with the UI.There's no need to have access to model for this task.
All EventHandlers will call a single method on the Controller.
If you are about to call more than one method, you should introduce a new method on Controller.
-
setupModelToUiBindings
Whenever an 'ObservableValue' in 'model' changes, the UI must be updated.There's no need to have access to controller for this task.
Register all necessary observers here.
-
startUp
At the Startup, this method gets called.Perfect, if a function in the controller or in the pui needs to be run exactly once.
-