Class ViewerDefaultGUI
- Direct Known Subclasses:
CanvasDrawerGUI
The central node is created by the createCenterNode()
method, which has to be
implemented by the subclass.
The right node is created by the createRightNode()
method, which can be
overridden to provide a custom right node. By default, it creates a VBox containing the
simulation properties using the PropertySheetFactory
.
The toolbar is created by the createToolBar()
method, which can be overridden
to provide a custom toolbar. By default, it creates a toolbar with the viewer agent's
actions and the scheduler's actions.
The rendering is managed by the requestRendering()
method, which is called by
the viewer agent when it wants to render the simulation state. This method triggers the
Viewer.render()
in the JavaFX thread, depending on the state of the GUI such as
the synchronous painting mode.
The synchronous painting mode can be activated or deactivated by the user. When activated, the rendering is done for each simulation step and blocks the simulation process. When deactivated, the rendering is done without blocking the simulation process, at a rate corresponding to the complexity of the rendering.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ViewerDefaultGUI
(Viewer viewer) Creates a new ViewerDefaultGUI for the given viewer. -
Method Summary
Modifier and TypeMethodDescriptionprotected Node
Creates the bottom node.protected abstract Node
Creates the central node of the viewer agent.protected Node
Returns theVBox
that will positioned on the right part of the main pane, which is aBorderPane
.protected ToolBar
Creates a toolbar for the viewer agent.protected Node
Creates the top node of the viewer agent.Returns the rendering off action.Returns the synchronous painting action.Returns the viewer agent associated with this GUI.boolean
Returns if the rendering is activated.protected void
Redefines to initialize the default rendering actions.void
Requests the rendering of the simulation state.void
setRenderingOff
(boolean activated) Enable or disable the renderingOff activityvoid
setSynchroPainting
(boolean activated) Enable or disable the synchronous paintingMethods inherited from class madkit.gui.DefaultAgentGUI
createLeftNode, getAgent, getBottomNode, getCenterNode, getLeftNode, getMainPane, getRightNode, getScene, getStage, getToolbar, getToolBar, getTopNode
-
Constructor Details
-
ViewerDefaultGUI
Creates a new ViewerDefaultGUI for the given viewer.- Parameters:
viewer
- the viewer agent
-
-
Method Details
-
onInitialize
protected void onInitialize()Redefines to initialize the default rendering actions.- Overrides:
onInitialize
in classDefaultAgentGUI
-
createTopNode
Creates the top node of the viewer agent. By default, it creates a menu bar with the rendering actions and returns a VBox containing the menu bar.- Overrides:
createTopNode
in classDefaultAgentGUI
- Returns:
- a VBox containing the menu bar
-
createBottomNode
Creates the bottom node.- Overrides:
createBottomNode
in classDefaultAgentGUI
- Returns:
- the node
-
createRightNode
Returns theVBox
that will positioned on the right part of the main pane, which is aBorderPane
. By default, it creates a VBox containing the simulation properties using thePropertySheetFactory
.This method can be overridden to provide a custom right node.
Default code is:
protected VBox createRightNode() { return PropertySheetFactory.getVBoxProperties(getViewer().getSimuEngine(), getViewer().getModel(), getViewer().getEnvironment(), getViewer().getScheduler(), getViewer()); }
It will be positioned on the right of the main pane.
- Overrides:
createRightNode
in classDefaultAgentGUI
- Returns:
- a VBox that will be used as the right node of the main pane
-
createCenterNode
Creates the central node of the viewer agent. This method has to be implemented by the subclass.- Overrides:
createCenterNode
in classDefaultAgentGUI
- Returns:
- the central node of the main pane
-
createToolBar
Creates a toolbar for the viewer agent.- Overrides:
createToolBar
in classDefaultAgentGUI
- Returns:
- a ToolBar with the viewer agent's actions
-
requestRendering
public void requestRendering()Requests the rendering of the simulation state. The rendering is done in the JavaFX thread depending on the state of the GUI such as the synchronous painting mode. -
getRenderingOffAction
Returns the rendering off action.- Returns:
- the renderingOff action
-
getSynchroPaintingAction
Returns the synchronous painting action.- Returns:
- the synchroPainting
-
isRendering
public boolean isRendering()Returns if the rendering is activated.- Returns:
true
if the renderingOff activity is activated.
-
setRenderingOff
public void setRenderingOff(boolean activated) Enable or disable the renderingOff activity- Parameters:
activated
- iftrue
, the renderingOff activity is activated
-
setSynchroPainting
public void setSynchroPainting(boolean activated) Enable or disable the synchronous painting- Parameters:
activated
- if true, the synchronous painting is activated
-
getViewer
Returns the viewer agent associated with this GUI.- Returns:
- the viewer agent
-