Class OTSAnimationPanel

    • Field Detail

      • closeHandlerRegistered

        protected boolean closeHandlerRegistered
        Has the window close handler been registered?
      • windowExited

        protected boolean windowExited
        Indicate the window has been closed and the timer thread can stop.
    • Constructor Detail

      • OTSAnimationPanel

        public OTSAnimationPanel​(Rectangle2D extent,
                                 Dimension size,
                                 org.opentrafficsim.core.dsol.OTSAnimator simulator,
                                 org.opentrafficsim.core.dsol.OTSModelInterface otsModel,
                                 org.opentrafficsim.core.animation.gtu.colorer.GTUColorer gtuColorer,
                                 org.opentrafficsim.core.network.OTSNetwork network)
                          throws RemoteException,
                                 DSOLException
        Construct a panel that looks like the DSOLPanel for quick building of OTS applications.
        Parameters:
        extent - Rectangle2D; bottom left corner, length and width of the area (world) to animate.
        size - Dimension; the size to be used for the animation.
        simulator - OTSAnimator; the simulator or animator of the model.
        otsModel - OTSModelInterface; the builder and rebuilder of the simulation, based on properties.
        gtuColorer - GTUColorer; the colorer to use for the GTUs.
        network - OTSNetwork; network
        Throws:
        RemoteException - when notification of the animation panel fails
        DSOLException - when simulator does not implement AnimatorInterface
    • Method Detail

      • setAutoPan

        public void setAutoPan​(String newAutoPanId,
                               OTSSearchPanel.ObjectKind<?> newAutoPanKind,
                               boolean newAutoPanTrack)
        Change auto pan target.
        Parameters:
        newAutoPanId - String; id of object to track (or
        newAutoPanKind - String; kind of object to track
        newAutoPanTrack - boolean; if true; tracking is continuously; if false; tracking is once
      • addToggleAnimationButtonIcon

        public final void addToggleAnimationButtonIcon​(String name,
                                                       Class<? extends Locatable> locatableClass,
                                                       String iconPath,
                                                       String toolTipText,
                                                       boolean initiallyVisible,
                                                       boolean idButton)
        Add a button for toggling an animatable class on or off. Button icons for which 'idButton' is true will be placed to the right of the previous button, which should be the corresponding button without the id. An example is an icon for showing/hiding the class 'Lane' followed by the button to show/hide the Lane ids.
        Parameters:
        name - String; the name of the button
        locatableClass - Class<? extends Locatable>; the class for which the button holds (e.g., GTU.class)
        iconPath - String; the path to the 24x24 icon to display
        toolTipText - String; the tool tip text to show when hovering over the button
        initiallyVisible - boolean; whether the class is initially shown or not
        idButton - boolean; id button that needs to be placed next to the previous button
      • addToggleAnimationButtonText

        public final void addToggleAnimationButtonText​(String name,
                                                       Class<? extends Locatable> locatableClass,
                                                       String toolTipText,
                                                       boolean initiallyVisible)
        Add a button for toggling an animatable class on or off.
        Parameters:
        name - String; the name of the button
        locatableClass - Class<? extends Locatable>; the class for which the button holds (e.g., GTU.class)
        toolTipText - String; the tool tip text to show when hovering over the button
        initiallyVisible - boolean; whether the class is initially shown or not
      • addToggleText

        public final void addToggleText​(String text)
        Add a text to explain animatable classes.
        Parameters:
        text - String; the text to show
      • addAllToggleGISButtonText

        public final void addAllToggleGISButtonText​(String header,
                                                    GisRenderable2D gisMap,
                                                    String toolTipText)
        Add buttons for toggling all GIS layers on or off.
        Parameters:
        header - String; the name of the group of layers
        gisMap - GisRenderable2D; the GIS map for which the toggles have to be added
        toolTipText - String; the tool tip text to show when hovering over the button
      • addToggleGISButtonText

        public final void addToggleGISButtonText​(String layerName,
                                                 String displayName,
                                                 GisRenderable2D gisMap,
                                                 String toolTipText)
        Add a button to toggle a GIS Layer on or off.
        Parameters:
        layerName - String; the name of the layer
        displayName - String; the name to display next to the tick box
        gisMap - GisRenderable2D; the map
        toolTipText - String; the tool tip text
      • showGISLayer

        public final void showGISLayer​(String layerName)
        Set a GIS layer to be shown in the animation to true.
        Parameters:
        layerName - String; the name of the GIS-layer that has to be shown.
      • hideGISLayer

        public final void hideGISLayer​(String layerName)
        Set a GIS layer to be hidden in the animation to true.
        Parameters:
        layerName - String; the name of the GIS-layer that has to be hidden.
      • toggleGISLayer

        public final void toggleGISLayer​(String layerName)
        Toggle a GIS layer to be displayed in the animation to its reverse value.
        Parameters:
        layerName - String; the name of the GIS-layer that has to be turned off or vice versa.
      • getAnimationPanel

        public final AnimationPanel getAnimationPanel()
        Easy access to the AnimationPanel.
        Returns:
        AnimationPanel
      • createDemoPanel

        public void createDemoPanel​(OTSAnimationPanel.DemoPanelPosition position)
        Creates a demo panel within the animation area.
        Parameters:
        position - String; any string from BorderLayout indicating the position of the demo panel, except CENTER.
        Throws:
        IllegalStateException - if the panel was already created
      • getDemoPanel

        public JPanel getDemoPanel()
        Return a panel for on-screen demo controls. The panel is create on first call.
        Returns:
        JPanel; panel
      • updateAnimationClassCheckBox

        public final void updateAnimationClassCheckBox​(Class<? extends Locatable> locatableClass)
        Update the checkmark related to a programmatically changed animation state.
        Parameters:
        locatableClass - Class<? extends Locatable>; class to show the checkmark for
      • updateWorldCoordinate

        protected final void updateWorldCoordinate()
        Display the latest world coordinate based on the mouse position on the screen.
      • getGTUColorer

        public final org.opentrafficsim.core.animation.gtu.colorer.GTUColorer getGTUColorer()
        Access the GTUColorer of this animation ControlPanel.
        Returns:
        GTUColorer the colorer used. If it is a SwitchableGTUColorer, the wrapper with the list will be returned, not the actual colorer in use.
      • getColorControlPanel

        public final ColorControlPanel getColorControlPanel()
        Access the ColorControlPanel of this ControlPanel. If the simulator is not a SimpleAnimator, no ColorControlPanel was constructed and this method will return null.
        Returns:
        ColorControlPanel
      • installWindowCloseHandler

        public final void installWindowCloseHandler()
        Install a handler for the window closed event that stops the simulator (if it is running).