Class ContourDataSource
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.animation.graphs.PlotDelegate<AbstractContourPlot.ContourPaintState,AbstractContourPlot<?>>
org.opentrafficsim.animation.graphs.ContourDataSource
- All Implemented Interfaces:
EventProducer
public class ContourDataSource
extends PlotDelegate<AbstractContourPlot.ContourPaintState,AbstractContourPlot<?>>
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-2026 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 interfaceInterface for data types of which a contour plot can be made.static interfaceContourDataSource.ContourDataType<Z extends Number>Contour data type.static interfaceContourDataSource.ContourEdieDataType<Z extends Number>Edie's contour data source types.static enumEnum to refer to either the distance or time axis. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.djunits.value.vdouble.scalar.DurationInitial lower bound for the time scale.static final EventTypeGranularity changed.static final EventTypeInterpolation changed.static final EventTypeSmooth changed.protected static final PlotSetting<org.djunits.value.vdouble.scalar.Length>Space granularities.protected static final PlotSetting<org.djunits.value.vdouble.scalar.Duration>Time granularities.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION -
Constructor Summary
ConstructorsConstructorDescriptionContourDataSource(SamplerData<?> samplerData, org.djunits.value.vdouble.scalar.Duration delay, GraphPath<? extends LaneData<?>> path, PlotScheduler plotScheduler, PlotSetting<org.djunits.value.vdouble.scalar.Length> spaceGranularities, PlotSetting<org.djunits.value.vdouble.scalar.Duration> timeGranularities, org.djunits.value.vdouble.scalar.Duration start, org.djunits.value.vdouble.scalar.Duration initialEnd) Constructor for non-default input.ContourDataSource(SamplerData<?> samplerData, GraphPath<? extends LaneData<?>> path, PlotScheduler plotScheduler) Constructor using default granularities. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPlot(AbstractContourPlot<?> contourPlot) Add plot.protected voidcalculatePaintStateUnsafe(org.djunits.value.vdouble.scalar.Duration t) Heart of the data pool.double[]getGranularities(ContourDataSource.Dimension dimension) Returns the available granularities that a linked plot may use.doublegetGranularity(ContourDataSource.Dimension dimension) Returns the selected granularity that a linked plot should use.voidsetGranularity(ContourDataSource.Dimension dimension, double granularity) Sets the granularity of the plot.voidsetInterpolate(boolean interpolate) Sets bi-linear interpolation enabled or disabled.voidsetSmooth(boolean smooth) Sets the adaptive smoothing enabled or disabled.toString()Methods inherited from class org.opentrafficsim.animation.graphs.PlotDelegate
calculatePaintStateSafe, clearPlots, getAndResetInvalidTimeSpan, getDelay, getInitialUpdateInterval, getPlots, getPlotScheduler, invalidateTimeSpan, isInvalidTimeSpanMethods 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. -
SPACE_GRANULARITIES
Space granularities. -
TIME_GRANULARITIES
Time granularities. -
DEFAULT_LOWER_TIME_BOUND
protected static final org.djunits.value.vdouble.scalar.Duration DEFAULT_LOWER_TIME_BOUNDInitial lower bound for the time scale.
-
-
Constructor Details
-
ContourDataSource
public ContourDataSource(SamplerData<?> samplerData, GraphPath<? extends LaneData<?>> path, PlotScheduler plotScheduler) Constructor using default granularities.- Parameters:
samplerData- sampler datapath- pathplotScheduler- plot scheduler
-
ContourDataSource
public ContourDataSource(SamplerData<?> samplerData, org.djunits.value.vdouble.scalar.Duration delay, GraphPath<? extends LaneData<?>> path, PlotScheduler plotScheduler, PlotSetting<org.djunits.value.vdouble.scalar.Length> spaceGranularities, PlotSetting<org.djunits.value.vdouble.scalar.Duration> timeGranularities, org.djunits.value.vdouble.scalar.Duration start, org.djunits.value.vdouble.scalar.Duration 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- pathplotScheduler- plot schedulerspaceGranularities- granularity options for space dimensiontimeGranularities- granularity options for time dimensionstart- start timeinitialEnd- initial end time of plots, will be expanded if simulation time exceeds it
-
-
Method Details
-
toString
-
addPlot
Description copied from class:PlotDelegateAdd plot. Used to notify plots when data has changed.- Overrides:
addPlotin classPlotDelegate<AbstractContourPlot.ContourPaintState,AbstractContourPlot<?>> - Parameters:
contourPlot- plot
-
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
-
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 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 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
-
calculatePaintStateUnsafe
protected void calculatePaintStateUnsafe(org.djunits.value.vdouble.scalar.Duration t) Heart of the data pool. This method is invoked regularly by the worker thread of a plot, either for a scheduled update or due to user input. No two invocations can happen at the same time.This method regularly checks conditions that indicate the update should be interrupted as for example a setting has changed and repainting is required. Whenever a new invalidation causes
PlotDelegate.invalidateTimeSpan()to be invoked, this method can stop as the full data needs to be recalculated. This can be set by any change of e.g. granularity or smoothing, during the update.- Specified by:
calculatePaintStateUnsafein classPlotDelegate<AbstractContourPlot.ContourPaintState,AbstractContourPlot<?>> - Parameters:
t- time up to which to show data
-