public abstract class AbstractWrappableAnimation extends Object implements WrappableAnimation, Serializable
Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2017-04-29 12:51:08 +0200 (Sat, 29 Apr 2017) $, @version $Revision: 3570 $, by $Author: averbraeck $,
initial version Jun 18, 2015
Modifier and Type | Field and Description |
---|---|
protected boolean |
exitOnClose
Use EXIT_ON_CLOSE when true, DISPOSE_ON_CLOSE when false on closing of the window.
|
protected OTSAnimationPanel |
panel
The tabbed panel so other tabs can be added by the classes that extend this class.
|
protected List<org.opentrafficsim.base.modelproperties.Property<?>> |
properties
The properties exhibited by this simulation.
|
protected List<org.opentrafficsim.base.modelproperties.Property<?>> |
savedUserModifiedProperties
The properties after (possible) editing by the user.
|
Constructor and Description |
---|
AbstractWrappableAnimation() |
Modifier and Type | Method and Description |
---|---|
protected void |
addAnimationToggles()
Placeholder method to place animation buttons or to show/hide classes on the animation.
|
void |
addTab(int index,
String caption,
Container container)
Add a tab to the simulation window.
|
protected void |
addTabs(SimpleSimulatorInterface simulator)
Make additional tabs in the main simulation window.
|
void |
addToggleAnimationButtonIcon(String name,
Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass,
String iconPath,
String toolTipText,
boolean initiallyVisible,
boolean idButton)
Add a button for toggling an animatable class on or off.
|
void |
addToggleAnimationButtonText(String name,
Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass,
String toolTipText,
boolean initiallyVisible)
Add a button for toggling an animatable class on or off.
|
void |
addToggleGISButtonText(String header,
nl.tudelft.simulation.dsol.animation.D2.GisRenderable2D gisMap,
String toolTipText)
Add a button for toggling a GIS class on or off.
|
SimpleAnimator |
buildAnimator(org.djunits.value.vdouble.scalar.Time startTime,
org.djunits.value.vdouble.scalar.Duration warmupPeriod,
org.djunits.value.vdouble.scalar.Duration runLength,
List<org.opentrafficsim.base.modelproperties.Property<?>> userModifiedProperties,
Rectangle rect,
boolean eoc)
Build the animation.
|
protected SimpleAnimator |
buildSimpleAnimator(org.djunits.value.vdouble.scalar.Time startTime,
org.djunits.value.vdouble.scalar.Duration warmupPeriod,
org.djunits.value.vdouble.scalar.Duration runLength,
OTSModelInterface otsModel)
Build the animator.
|
protected SimpleAnimator |
buildSimpleAnimator(org.djunits.value.vdouble.scalar.Time startTime,
org.djunits.value.vdouble.scalar.Duration warmupPeriod,
org.djunits.value.vdouble.scalar.Duration runLength,
OTSModelInterface otsModel,
int replicationNumber)
Build the animator with the specified replication number.
|
protected GTUColorer |
getColorer()
Overrridable method to return GTU colorer.
|
OTSAnimationPanel |
getPanel() |
ArrayList<org.opentrafficsim.base.modelproperties.Property<?>> |
getProperties()
Retrieve a list of visible properties of the simulation.
|
int |
getTabCount()
Report the current number of tabs in the simulation window.
|
List<org.opentrafficsim.base.modelproperties.Property<?>> |
getUserModifiedProperties()
Retrieve a list of properties as the user has modified them.
|
void |
hideAnimationClass(Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass)
Set a class to be hidden in the animation to true.
|
void |
hideGISLayer(String layerName)
Set a GIS layer to be hidden in the animation to true.
|
protected Rectangle2D |
makeAnimationRectangle()
Return the initial 'home' extent for the animation.
|
protected abstract OTSModelInterface |
makeModel(GTUColorer colorer) |
SimpleSimulatorInterface |
rebuildSimulator(Rectangle rect)
Restart (rebuild) the simulation.
|
void |
setNextReplication(Integer nextReplication)
Set the number of the next spawned replication.
|
void |
showAnimationClass(Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass)
Set a class to be shown in the animation to true.
|
void |
showGISLayer(String layerName)
Set a GIS layer to be shown in the animation to true.
|
void |
stopTimersThreads()
Stop the timers and threads that are connected when disposing of this wrappable simulation.
|
void |
toggleAnimationClass(Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass)
Toggle a class to be displayed in the animation to its reverse value.
|
void |
toggleGISLayer(String layerName)
Toggle a GIS layer to be displayed in the animation to its reverse value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
description, shortName
protected List<org.opentrafficsim.base.modelproperties.Property<?>> properties
protected List<org.opentrafficsim.base.modelproperties.Property<?>> savedUserModifiedProperties
protected boolean exitOnClose
protected OTSAnimationPanel panel
protected SimpleAnimator buildSimpleAnimator(org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Duration warmupPeriod, org.djunits.value.vdouble.scalar.Duration runLength, OTSModelInterface otsModel) throws nl.tudelft.simulation.dsol.SimRuntimeException, NamingException, org.opentrafficsim.base.modelproperties.PropertyException
startTime
- Time; the start timewarmupPeriod
- Duration; the warm up periodrunLength
- Duration; the duration of the simulation / animationotsModel
- OTSModelInterface; the simulation modelnl.tudelft.simulation.dsol.SimRuntimeException
- on ???NamingException
- when context for the animation cannot be createdorg.opentrafficsim.base.modelproperties.PropertyException
- when one of the user modified properties has the empty string as keyprotected SimpleAnimator buildSimpleAnimator(org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Duration warmupPeriod, org.djunits.value.vdouble.scalar.Duration runLength, OTSModelInterface otsModel, int replicationNumber) throws nl.tudelft.simulation.dsol.SimRuntimeException, NamingException, org.opentrafficsim.base.modelproperties.PropertyException
startTime
- Time; the start timewarmupPeriod
- Duration; the warm up periodrunLength
- Duration; the duration of the simulation / animationotsModel
- OTSModelInterface; the simulation modelreplicationNumber
- int; the replication numbernl.tudelft.simulation.dsol.SimRuntimeException
- on ???NamingException
- when context for the animation cannot be createdorg.opentrafficsim.base.modelproperties.PropertyException
- when one of the user modified properties has the empty string as keypublic SimpleAnimator buildAnimator(org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Duration warmupPeriod, org.djunits.value.vdouble.scalar.Duration runLength, List<org.opentrafficsim.base.modelproperties.Property<?>> userModifiedProperties, Rectangle rect, boolean eoc) throws nl.tudelft.simulation.dsol.SimRuntimeException, NamingException, OTSSimulationException, org.opentrafficsim.base.modelproperties.PropertyException
buildAnimator
in interface WrappableAnimation
startTime
- Time; the start time of the simulationwarmupPeriod
- Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what
this is)runLength
- Duration; the duration of the simulationuserModifiedProperties
- List<Property<?>>; the (possibly user-modified) properties. This list must contain all the
properties returned by getProperties(); any additional properties may be ignoredrect
- the x, y, width and height for the window to rebuild. Use null for maximized screen.eoc
- Use EXIT_ON_CLOSE when true, DISPOSE_ON_CLOSE when false on closing of the window.nl.tudelft.simulation.dsol.SimRuntimeException
- on ???NamingException
- when context for the animation cannot be createdOTSSimulationException
- when the construction of the simulation, the control panel, the animation, or the charts
failsorg.opentrafficsim.base.modelproperties.PropertyException
- when one of the user modified properties has the empty string as keyprotected GTUColorer getColorer()
protected void addTabs(SimpleSimulatorInterface simulator) throws OTSSimulationException, org.opentrafficsim.base.modelproperties.PropertyException
simulator
- SimpleSimulatorInterface; the simulatorOTSSimulationException
- in case the chart, axes or legend cannot be generatedorg.opentrafficsim.base.modelproperties.PropertyException
- when one of the user modified properties has the empty string as keyprotected void addAnimationToggles()
public final void addToggleAnimationButtonIcon(String name, Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass, String iconPath, String toolTipText, boolean initiallyVisible, boolean idButton)
name
- the name of the buttonlocatableClass
- the class for which the button holds (e.g., GTU.class)iconPath
- the path to the 24x24 icon to displaytoolTipText
- the tool tip text to show when hovering over the buttoninitiallyVisible
- whether the class is initially shown or notidButton
- id button that needs to be placed next to the previous buttonpublic final void addToggleAnimationButtonText(String name, Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass, String toolTipText, boolean initiallyVisible)
name
- the name of the buttonlocatableClass
- the class for which the button holds (e.g., GTU.class)toolTipText
- the tool tip text to show when hovering over the buttoninitiallyVisible
- whether the class is initially shown or notpublic final void showAnimationClass(Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass)
locatableClass
- the class for which the animation has to be shown.public final void hideAnimationClass(Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass)
locatableClass
- the class for which the animation has to be hidden.public final void toggleAnimationClass(Class<? extends nl.tudelft.simulation.dsol.animation.Locatable> locatableClass)
locatableClass
- the class for which a visible animation has to be turned off or vice versa.public final void addToggleGISButtonText(String header, nl.tudelft.simulation.dsol.animation.D2.GisRenderable2D gisMap, String toolTipText)
header
- the name of the group of layersgisMap
- the GIS map for which the toggles have to be addedtoolTipText
- the tool tip text to show when hovering over the buttonpublic final void showGISLayer(String layerName)
layerName
- the name of the GIS-layer that has to be shown.public final void hideGISLayer(String layerName)
layerName
- the name of the GIS-layer that has to be hidden.public final void toggleGISLayer(String layerName)
layerName
- the name of the GIS-layer that has to be turned off or vice versa.protected abstract OTSModelInterface makeModel(GTUColorer colorer) throws OTSSimulationException
colorer
- the GTU colorer to use.OTSSimulationException
- in case the construction of the model failsprotected Rectangle2D makeAnimationRectangle()
public final ArrayList<org.opentrafficsim.base.modelproperties.Property<?>> getProperties()
getProperties
in interface WrappableAnimation
public final SimpleSimulatorInterface rebuildSimulator(Rectangle rect) throws nl.tudelft.simulation.dsol.SimRuntimeException, NetworkException, NamingException, OTSSimulationException, org.opentrafficsim.base.modelproperties.PropertyException
rebuildSimulator
in interface WrappableAnimation
rect
- the x, y, width and height for the window to rebuild. Use null for maximized screen.nl.tudelft.simulation.dsol.SimRuntimeException
- on ???NetworkException
- on Network inconsistencyNamingException
- when context for the animation cannot be createdOTSSimulationException
- when the (re)construction of the simulation model failsorg.opentrafficsim.base.modelproperties.PropertyException
- when one of the user modified properties has the empty string as keypublic final List<org.opentrafficsim.base.modelproperties.Property<?>> getUserModifiedProperties()
getUserModifiedProperties
in interface WrappableAnimation
public void stopTimersThreads()
stopTimersThreads
in interface WrappableAnimation
public final OTSAnimationPanel getPanel()
public final void addTab(int index, String caption, Container container)
index
- int; index of the new tab; use getTabCount()
to obtain the valid rangecaption
- String; caption of the new tabcontainer
- Container; content of the new tabpublic final int getTabCount()
public final void setNextReplication(Integer nextReplication)
setNextReplication
in interface WrappableAnimation
nextReplication
- Integer; the next replication number, or null to use the built-in auto-incrementing replication
counterCopyright © 2014–2017 Delft University of Technology. All rights reserved.