Class Viewer

Direct Known Subclasses:
LineChartDrawer, Viewer2D

public abstract class Viewer extends Watcher
A Viewer is a Watcher that is designed to display simulation states on screen.

By default, a viewer agent is automatically granted the role SimuOrganization.VIEWER_ROLE in the group SimuOrganization.ENGINE_GROUP when it is activated. This can be changed by overriding the onActivation() method.

To this end, it holds a ViewerDefaultGUI which is used to render the simulation state through a predefined JavaFX stage. When the viewer agent wants to render the simulation state, it calls the ViewerDefaultGUI.requestRendering() method which triggers the render() in the JavaFX thread if needed, depending on the state of the GUI such as the synchronous painting mode.

See Also:
  • Constructor Details

    • Viewer

      public Viewer()
  • Method Details

    • onActivation

      protected void onActivation()
      This method is called when the agent is activated. By default, it requests the role SimuOrganization.VIEWER_ROLE in the group SimuOrganization.ENGINE_GROUP.
      Overrides:
      onActivation in class Watcher
    • display

      public void display()
      When using the default simulation engine setup, this method is automatically called by the scheduler agent when it is time to render the simulation state. It calls the ViewerDefaultGUI.requestRendering() method which triggers the render() in the JavaFX thread if needed, depending on the state of the GUI such as the synchronous painting mode.
    • onEnd

      protected void onEnd()
      This method is called when the agent is ending. By default, it sends a SchedulingMessage with the SchedulingAction.SHUTDOWN action to the scheduler agent if no other viewer agent is present in the group SimuOrganization.ENGINE_GROUP with the role #VIEWER_ROLE.
      Overrides:
      onEnd in class Watcher
    • onSimulationStart

      public void onSimulationStart()
      On simulation start.
      Overrides:
      onSimulationStart in class SimuAgent
    • render

      public abstract void render()
      Renders the simulation state. This method is called by the GUI bounded to this agent when it is time to render the simulation state. The rendering is done in the JavaFX thread.
    • getGUI

      public <G extends ViewerDefaultGUI> G getGUI()
      Returns the GUI of this viewer.
      Returns:
      the GUI of this viewer
    • setGUI

      public void setGUI(ViewerDefaultGUI gui)
      Sets the GUI of this viewer.
      Parameters:
      gui - the GUI to set