public abstract class AbstractWrappableAnimation extends Object implements WrappableAnimation, Serializable
Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2018-09-19 13:55:45 +0200 (Wed, 19 Sep 2018) $, @version $Revision: 4006 $, 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 Properties |
frameProperties
Properties for the frame appearance (not simulation related).
|
protected OTSAnimationPanel |
panel
The tabbed panel so other tabs can be added by the classes that extend this class.
|
protected List<Property<?>> |
properties
The properties exhibited by this simulation.
|
protected List<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 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 Locatable> locatableClass,
String toolTipText,
boolean initiallyVisible)
Add a button for toggling an animatable class on or off.
|
void |
addToggleGISButtonText(String header,
GisRenderable2D gisMap,
String toolTipText)
Add a button for toggling a GIS class on or off.
|
SimpleAnimator |
buildAnimator(Time startTime,
Duration warmupPeriod,
Duration runLength,
List<Property<?>> userModifiedProperties,
Rectangle rect,
boolean eoc)
Build the animation.
|
protected SimpleAnimator |
buildSimpleAnimator(Time startTime,
Duration warmupPeriod,
Duration runLength,
OTSModelInterface otsModel)
Build the animator.
|
protected SimpleAnimator |
buildSimpleAnimator(Time startTime,
Duration warmupPeriod,
Duration runLength,
OTSModelInterface otsModel,
int replicationNumber)
Build the animator with the specified replication number.
|
Appearance |
getAppearance()
Returns the appearance.
|
GTUColorer |
getColorer()
Overridable method to return GTU colorer.
|
JPanel |
getDemoPanel()
Return a panel for on-screen demo controls.
|
OTSAnimationPanel |
getPanel() |
ArrayList<Property<?>> |
getProperties()
Retrieve a list of visible properties of the simulation.
|
int |
getTabCount()
Report the current number of tabs in the simulation window.
|
List<Property<?>> |
getUserModifiedProperties()
Retrieve a list of properties as the user has modified them.
|
void |
hideAnimationClass(Class<? extends 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() |
SimpleSimulatorInterface |
rebuildSimulator(Rectangle rect)
Restart (rebuild) the simulation.
|
void |
setAppearance(Appearance appearance)
Sets an appearance.
|
void |
setNextReplication(Integer nextReplication)
Set the number of the next spawned replication.
|
protected void |
setupDemo(AbstractWrappableAnimation animation,
OTSNetwork net)
Method that is called when the animation has been created, to add components for a demo.
|
void |
showAnimationClass(Class<? extends 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 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<Property<?>> savedUserModifiedProperties
protected Properties frameProperties
protected boolean exitOnClose
protected OTSAnimationPanel panel
protected SimpleAnimator buildSimpleAnimator(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface otsModel) throws SimRuntimeException, NamingException, PropertyException
startTime
- Time; the start timewarmupPeriod
- Duration; the warm up periodrunLength
- Duration; the duration of the simulation / animationotsModel
- OTSModelInterface; the simulation modelSimRuntimeException
- on ???NamingException
- when context for the animation cannot be createdPropertyException
- when one of the user modified properties has the empty string as keyprotected SimpleAnimator buildSimpleAnimator(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface otsModel, int replicationNumber) throws SimRuntimeException, NamingException, 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 numberSimRuntimeException
- on ???NamingException
- when context for the animation cannot be createdPropertyException
- when one of the user modified properties has the empty string as keypublic SimpleAnimator buildAnimator(Time startTime, Duration warmupPeriod, Duration runLength, List<Property<?>> userModifiedProperties, Rectangle rect, boolean eoc) throws SimRuntimeException, NamingException, OTSSimulationException, 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.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
failsPropertyException
- when one of the user modified properties has the empty string as keypublic void setAppearance(Appearance appearance)
appearance
- Appearance; appearancepublic Appearance getAppearance()
public GTUColorer getColorer()
protected void addTabs(SimpleSimulatorInterface simulator) throws OTSSimulationException, PropertyException
simulator
- SimpleSimulatorInterface; the simulatorOTSSimulationException
- in case the chart, axes or legend cannot be generatedPropertyException
- when one of the user modified properties has the empty string as keyprotected void addAnimationToggles()
protected void setupDemo(AbstractWrappableAnimation animation, OTSNetwork net)
animation
- AbstractWrappableAnimation; animationnet
- OTSNetwork; networkpublic final void addToggleAnimationButtonIcon(String name, Class<? extends 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 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 Locatable> locatableClass)
locatableClass
- the class for which the animation has to be shown.public final void hideAnimationClass(Class<? extends Locatable> locatableClass)
locatableClass
- the class for which the animation has to be hidden.public final void toggleAnimationClass(Class<? extends Locatable> locatableClass)
locatableClass
- the class for which a visible animation has to be turned off or vice versa.public final void addToggleGISButtonText(String header, 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() throws OTSSimulationException
OTSSimulationException
- in case the construction of the model failsprotected Rectangle2D makeAnimationRectangle()
public final ArrayList<Property<?>> getProperties()
getProperties
in interface WrappableAnimation
public final SimpleSimulatorInterface rebuildSimulator(Rectangle rect) throws SimRuntimeException, NetworkException, NamingException, OTSSimulationException, PropertyException
rebuildSimulator
in interface WrappableAnimation
rect
- the x, y, width and height for the window to rebuild. Use null for maximized screen.SimRuntimeException
- on ???NetworkException
- on Network inconsistencyNamingException
- when context for the animation cannot be createdOTSSimulationException
- when the (re)construction of the simulation model failsPropertyException
- when one of the user modified properties has the empty string as keypublic final List<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
counterpublic JPanel getDemoPanel()
Copyright © 2014–2018 Delft University of Technology. All rights reserved.