Class HTMLAnimationPanel
java.lang.Object
nl.tudelft.simulation.dsol.web.animation.D2.HTMLGridPanel
nl.tudelft.simulation.dsol.web.animation.D2.HTMLAnimationPanel
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.util.EventListener
,javax.naming.event.NamespaceChangeListener
,javax.naming.event.NamingListener
,EventListenerInterface
public class HTMLAnimationPanel extends HTMLGridPanel implements EventListenerInterface, javax.naming.event.NamespaceChangeListener
The AnimationPanel to display animated (Locatable) objects. Added the possibility to witch layers on and off. By default all
layers will be drawn, so no changes to existing software need to be made.
copyright (c) 2002-2018 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl .
copyright (c) 2002-2018 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl .
Copyright (c) 2002-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.
- Author:
- Peter Jacobs
-
Field Summary
Fields inherited from class nl.tudelft.simulation.dsol.web.animation.D2.HTMLGridPanel
DOWN, extent, formatter, GRIDCOLOR, gridSize, homeExtent, htmlGraphics2D, lastDimension, LEFT, preferredSize, RIGHT, showGrid, showToolTip, size, UP, worldCoordinate, ZOOMFACTOR
-
Constructor Summary
Constructors Constructor Description HTMLAnimationPanel(java.awt.geom.Rectangle2D extent, java.awt.Dimension size, SimulatorInterface<?,?,?> simulator)
constructs a new AnimationPanel. -
Method Summary
Modifier and Type Method Description void
addAllToggleGISButtonText(java.lang.String header, GisRenderable2D gisMap, java.lang.String toolTipText)
Add buttons for toggling all GIS layers on or off.void
addToggleAnimationButtonText(java.lang.String name, java.lang.Class<? extends Locatable> locatableClass, java.lang.String toolTipText, boolean initiallyVisible)
Add a button for toggling an animatable class on or off.void
addToggleGISButtonText(java.lang.String layerName, java.lang.String displayName, GisRenderable2D gisMap, java.lang.String toolTipText)
Add a button to toggle a GIS Layer on or off.void
addToggleText(java.lang.String text)
Add a text to explain animatable classes.java.awt.geom.Rectangle2D
fullExtent()
Calculate the full extent based on the current positions of the objects.javax.vecmath.Point4i
getDragLine()
java.util.SortedSet<Renderable2DInterface<? extends Locatable>>
getElements()
java.util.List<ToggleButtonInfo>
getToggleButtons()
void
hideClass(java.lang.Class<? extends Locatable> locatableClass)
Set a class to be hidden in the animation to true.void
hideClass(java.lang.String name)
Hide a Locatable class based on the name.void
hideGISLayer(java.lang.String layerName)
Set a GIS layer to be hidden in the animation to true.boolean
isDragLineEnabled()
boolean
isShowClass(java.lang.Class<? extends Locatable> locatableClass)
Test whether a certain class needs to be shown on the screen or not.boolean
isShowElement(Renderable2DInterface<? extends Locatable> element)
Test whether the element needs to be shown on the screen or not.void
namingExceptionThrown(javax.naming.event.NamingExceptionEvent namingEvent)
void
notify(EventInterface event)
void
objectAdded(javax.naming.event.NamingEvent namingEvent)
void
objectRemoved(javax.naming.event.NamingEvent namingEvent)
void
objectRenamed(javax.naming.event.NamingEvent namingEvent)
void
paintComponent(HTMLGraphics2D g2)
Draw the grid.void
setDragLineEnabled(boolean dragLineEnabled)
void
showClass(java.lang.Class<? extends Locatable> locatableClass)
Set a class to be shown in the animation to true.void
showClass(java.lang.String name)
Show a Locatable class based on the name.void
showGISLayer(java.lang.String layerName)
Set a GIS layer to be shown in the animation to true.void
toggleClass(java.lang.Class<? extends Locatable> locatableClass)
Toggle a class to be displayed in the animation to its reverse value.void
toggleGISLayer(java.lang.String layerName)
Toggle a GIS layer to be displayed in the animation to its reverse value.void
zoomAll()
resets the panel to its an extent that covers all displayed objects.Methods inherited from class nl.tudelft.simulation.dsol.web.animation.D2.HTMLGridPanel
displayWorldCoordinateToolTip, drawGrid, getBackground, getDrawingCommands, getExtent, getFont, getFontMetrics, getHeight, getPreferredSize, getSize, getToolTipText, getWidth, getWorldCoordinate, home, imageUpdate, isDirty, isShowGrid, isShowing, isShowToolTip, pan, repaint, setBackground, setFont, setPreferredSize, setShowGrid, setShowing, setShowToolTip, setSize, setToolTipText, setWorldCoordinate, showGrid, zoom, zoom
-
Constructor Details
-
HTMLAnimationPanel
public HTMLAnimationPanel(java.awt.geom.Rectangle2D extent, java.awt.Dimension size, SimulatorInterface<?,?,?> simulator) throws java.rmi.RemoteExceptionconstructs a new AnimationPanel.- Parameters:
extent
- Rectangle2D; the extent of the panelsize
- Dimension; the size of the panel.simulator
- SimulatorInterface<?,?,?>; the simulator of which we want to know the events for animation- Throws:
java.rmi.RemoteException
- on network error for one of the listeners
-
-
Method Details
-
paintComponent
Draw the grid.- Overrides:
paintComponent
in classHTMLGridPanel
- Parameters:
g2
- HTMLGraphics2D; the virtual Graphics2D canvas to enable writing to the browser
-
isShowElement
Test whether the element needs to be shown on the screen or not.- Parameters:
element
- Renderable2DInterface<? extends Locatable>; the renderable element to test- Returns:
- whether the element needs to be shown or not
-
isShowClass
Test whether a certain class needs to be shown on the screen or not. The class needs to implement Locatable, otherwise it cannot be shown at all.- Parameters:
locatableClass
- Class<? extends Locatable>; the class to test- Returns:
- whether the class needs to be shown or not
-
notify
- Specified by:
notify
in interfaceEventListenerInterface
- Throws:
java.rmi.RemoteException
-
objectAdded
public void objectAdded(javax.naming.event.NamingEvent namingEvent)- Specified by:
objectAdded
in interfacejavax.naming.event.NamespaceChangeListener
-
objectRemoved
public void objectRemoved(javax.naming.event.NamingEvent namingEvent)- Specified by:
objectRemoved
in interfacejavax.naming.event.NamespaceChangeListener
-
objectRenamed
public void objectRenamed(javax.naming.event.NamingEvent namingEvent)- Specified by:
objectRenamed
in interfacejavax.naming.event.NamespaceChangeListener
-
namingExceptionThrown
public void namingExceptionThrown(javax.naming.event.NamingExceptionEvent namingEvent)- Specified by:
namingExceptionThrown
in interfacejavax.naming.event.NamingListener
-
fullExtent
public java.awt.geom.Rectangle2D fullExtent()Calculate the full extent based on the current positions of the objects.- Returns:
- the full extent of the animation.
-
zoomAll
public void zoomAll()resets the panel to its an extent that covers all displayed objects. -
showClass
Set a class to be shown in the animation to true.- Parameters:
locatableClass
- Class<? extends Locatable>; the class for which the animation has to be shown.
-
hideClass
Set a class to be hidden in the animation to true.- Parameters:
locatableClass
- Class<? extends Locatable>; the class for which the animation has to be hidden.
-
toggleClass
Toggle a class to be displayed in the animation to its reverse value.- Parameters:
locatableClass
- Class<? extends Locatable>; the class for which a visible animation has to be turned off or vice versa.
-
getElements
- Returns:
- the set of animation elements.
-
getDragLine
public final javax.vecmath.Point4i getDragLine()- Returns:
- returns the dragLine.
-
isDragLineEnabled
public final boolean isDragLineEnabled()- Returns:
- returns the dragLineEnabled.
-
setDragLineEnabled
public final void setDragLineEnabled(boolean dragLineEnabled)- Parameters:
dragLineEnabled
- boolean; the dragLineEnabled to set.
-
addToggleAnimationButtonText
public final void addToggleAnimationButtonText(java.lang.String name, java.lang.Class<? extends Locatable> locatableClass, java.lang.String toolTipText, boolean initiallyVisible)Add a button for toggling an animatable class on or off.- Parameters:
name
- String; the name of the buttonlocatableClass
- 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 buttoninitiallyVisible
- boolean; whether the class is initially shown or not
-
showClass
public final void showClass(java.lang.String name)Show a Locatable class based on the name.- Parameters:
name
- the name of the class to show
-
hideClass
public final void hideClass(java.lang.String name)Hide a Locatable class based on the name.- Parameters:
name
- the name of the class to hide
-
addToggleText
public final void addToggleText(java.lang.String text)Add a text to explain animatable classes.- Parameters:
text
- String; the text to show
-
addAllToggleGISButtonText
public final void addAllToggleGISButtonText(java.lang.String header, GisRenderable2D gisMap, java.lang.String toolTipText)Add buttons for toggling all GIS layers on or off.- Parameters:
header
- String; the name of the group of layersgisMap
- GisRenderable2D; the GIS map for which the toggles have to be addedtoolTipText
- String; the tool tip text to show when hovering over the button
-
addToggleGISButtonText
public final void addToggleGISButtonText(java.lang.String layerName, java.lang.String displayName, GisRenderable2D gisMap, java.lang.String toolTipText)Add a button to toggle a GIS Layer on or off.- Parameters:
layerName
- String; the name of the layerdisplayName
- String; the name to display next to the tick boxgisMap
- GisRenderable2D; the maptoolTipText
- String; the tool tip text
-
showGISLayer
public final void showGISLayer(java.lang.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(java.lang.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(java.lang.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.
-
getToggleButtons
- Returns:
- toggleButtons
-