Package org.opentrafficsim.draw.graphs
Class ContourDataSource
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.draw.graphs.ContourDataSource
- All Implemented Interfaces:
EventProducer
Class that contains data for contour plots. One data source can be shared between contour plots, in which case the
granularity, path, sampler, update interval, and whether the data is smoothed (EGTF) are equal between the plots.
By default the source contains traveled time and traveled distance per cell.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceContourDataSource.ContourDataType<Z extends Number,I> Interface for data types of which a contour plot can be made.static enumEnum to refer to either the distance or time axis. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final TimeInitial lower bound for the time scale.protected static final double[]Space granularity values.protected static final intIndex of the initial space granularity.protected static final double[]Time granularity values.protected static final intIndex of the initial time granularity.static final EventTypeGranularity changed.static final EventTypeInterpolation changed.static final EventTypeSmooth changed.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION -
Constructor Summary
ConstructorsConstructorDescriptionContourDataSource(SamplerData<?> samplerData, Duration delay, GraphPath<? extends LaneData<?>> path, double[] spaceGranularity, int initSpaceIndex, double[] timeGranularity, int initTimeIndex, Time start, Time initialEnd) Constructor for non-default input.ContourDataSource(SamplerData<?> samplerData, GraphPath<? extends LaneData<?>> path) Constructor using default granularities. -
Method Summary
Modifier and TypeMethodDescriptiondoubleget(int item, ContourDataSource.ContourDataType<?, ?> contourDataType) Returns data of the givenContourDataTypefor a specific item.final double[]getGranularities(ContourDataSource.Dimension dimension) Returns the available granularities that a linked plot may use.final doublegetGranularity(ContourDataSource.Dimension dimension) Returns the selected granularity that a linked plot should use.final SamplerData<?>Returns the sampler data for anAbstractContourPlotusing thisContourDataSource.doublegetSpeed(int item) Returns the speed of the cell pertaining to plot item.doublegetTotalDistance(int item) Returns the total distance traveled in the cell pertaining to plot item.doublegetTotalTime(int item) Returns the total time traveled in the cell pertaining to plot item.final voidofferGranularity(ContourDataSource.Dimension dimension, double granularity) Offer granularity to the updater.final voidsetGranularity(ContourDataSource.Dimension dimension, double granularity) Sets the granularity of the plot.final voidsetInterpolate(boolean interpolate) Sets bi-linear interpolation enabled or disabled.final voidsetSmooth(boolean smooth) Sets the adaptive smoothing enabled or disabled.toString()Methods inherited from class org.djutils.event.LocalEventProducer
getEventListenerMapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
GRANULARITY
Granularity changed. -
INTERPOLATE
Interpolation changed. -
SMOOTH
Smooth changed. -
DEFAULT_SPACE_GRANULARITIES
protected static final double[] DEFAULT_SPACE_GRANULARITIESSpace granularity values. -
DEFAULT_SPACE_GRANULARITY_INDEX
protected static final int DEFAULT_SPACE_GRANULARITY_INDEXIndex of the initial space granularity.- See Also:
-
DEFAULT_TIME_GRANULARITIES
protected static final double[] DEFAULT_TIME_GRANULARITIESTime granularity values. -
DEFAULT_TIME_GRANULARITY_INDEX
protected static final int DEFAULT_TIME_GRANULARITY_INDEXIndex of the initial time granularity.- See Also:
-
DEFAULT_LOWER_TIME_BOUND
Initial lower bound for the time scale.
-
-
Constructor Details
-
ContourDataSource
Constructor using default granularities.- Parameters:
samplerData- sampler datapath- path
-
ContourDataSource
public ContourDataSource(SamplerData<?> samplerData, Duration delay, GraphPath<? extends LaneData<?>> path, double[] spaceGranularity, int initSpaceIndex, double[] timeGranularity, int initTimeIndex, Time start, Time initialEnd) Constructor for non-default input.- Parameters:
samplerData- sampler datadelay- delay so critical future events have occurred, e.g. GTU's next move's to extend trajectoriespath- pathspaceGranularity- granularity options for space dimensioninitSpaceIndex- initial selected space granularitytimeGranularity- granularity options for time dimensioninitTimeIndex- initial selected time granularitystart- start timeinitialEnd- initial end time of plots, will be expanded if simulation time exceeds it
-
-
Method Details
-
getSamplerData
Returns the sampler data for anAbstractContourPlotusing thisContourDataSource.- Returns:
- the sampler
-
getGranularities
Returns the available granularities that a linked plot may use.- Parameters:
dimension- space or time- Returns:
- available granularities that a linked plot may use
-
getGranularity
Returns the selected granularity that a linked plot should use.- Parameters:
dimension- space or time- Returns:
- granularity that a linked plot should use
-
offerGranularity
Offer granularity to the updater. This is a thread-safe execution as it hands over setting the granularity to the graph updater.- Parameters:
dimension- space or timegranularity- granularity in space or time (SI unit)
-
setGranularity
Sets the granularity of the plot. This will invalidate the plot triggering a redraw.- Parameters:
dimension- space or timegranularity- granularity in space or time (SI unit)
-
setInterpolate
public final void setInterpolate(boolean interpolate) Sets bi-linear interpolation enabled or disabled. This will invalidate the plot triggering a redraw.- Parameters:
interpolate- whether to enable interpolation
-
setSmooth
public final void setSmooth(boolean smooth) Sets the adaptive smoothing enabled or disabled. This will invalidate the plot triggering a redraw.- Parameters:
smooth- whether to smooth the plot
-
getSpeed
public double getSpeed(int item) Returns the speed of the cell pertaining to plot item.- Parameters:
item- plot item- Returns:
- speed of the cell, calculated as 'total distance' / 'total space'.
-
getTotalDistance
public double getTotalDistance(int item) Returns the total distance traveled in the cell pertaining to plot item.- Parameters:
item- plot item- Returns:
- total distance traveled in the cell
-
getTotalTime
public double getTotalTime(int item) Returns the total time traveled in the cell pertaining to plot item.- Parameters:
item- plot item- Returns:
- total time traveled in the cell
-
get
Returns data of the givenContourDataTypefor a specific item.- Parameters:
item- plot itemcontourDataType- contour data type- Returns:
- data of the given
ContourDataTypefor a specific item
-
toString
-