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
ConstructorsModifierConstructorDescriptionprotectedViewerDefaultGUI(Viewer viewer) Creates a new ViewerDefaultGUI for the given viewer. -
Method Summary
Modifier and TypeMethodDescriptionprotected NodeCreates the bottom node.protected abstract NodeCreates the central node of the viewer agent.protected NodeReturns theVBoxthat will positioned on the right part of the main pane, which is aBorderPane.protected ToolBarCreates a toolbar for the viewer agent.protected NodeCreates 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.booleanReturns if the rendering is activated.protected voidRedefines to initialize the default rendering actions.voidRequests the rendering of the simulation state.voidsetRenderingOff(boolean activated) Enable or disable the renderingOff activityvoidsetSynchroPainting(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:
onInitializein 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:
createTopNodein classDefaultAgentGUI- Returns:
- a VBox containing the menu bar
-
createBottomNode
Creates the bottom node.- Overrides:
createBottomNodein classDefaultAgentGUI- Returns:
- the node
-
createRightNode
Returns theVBoxthat 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:
createRightNodein 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:
createCenterNodein classDefaultAgentGUI- Returns:
- the central node of the main pane
-
createToolBar
Creates a toolbar for the viewer agent.- Overrides:
createToolBarin 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:
trueif 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
-