Class FdDataSource
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.animation.graphs.PlotDelegate<FundamentalDiagram.FdPaintState,FundamentalDiagram>
org.opentrafficsim.animation.graphs.FdDataSource
- All Implemented Interfaces:
EventProducer
public abstract class FdDataSource
extends PlotDelegate<FundamentalDiagram.FdPaintState,FundamentalDiagram>
Data source for a fundamental diagram.
Copyright (c) 2026-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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EventTypeAggregation period.static final EventTypeUpdates per period.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION -
Constructor Summary
ConstructorsConstructorDescriptionFdDataSource(org.djunits.value.vdouble.scalar.Duration aggregationInterval, org.djunits.value.vdouble.scalar.Duration delay, PlotScheduler plotScheduler) Constructor.FdDataSource(org.djunits.value.vdouble.scalar.Duration aggregationInterval, org.djunits.value.vdouble.scalar.Duration delay, PlotScheduler plotScheduler, PlotSetting<org.djunits.value.vdouble.scalar.Duration> aggregationPeriodSetting, PlotSetting<Integer> updatesPerPeriodSetting) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcalculatePaintStateUnsafe(org.djunits.value.vdouble.scalar.Duration time) Calculates paint state and offers it to the coupled plots.static FdDataSourcecombinedSource(Map<String, FdDataSource> sources) Combines multiple sources in to one source.org.djunits.value.vdouble.scalar.DurationThe aggregation period.PlotSetting<org.djunits.value.vdouble.scalar.Duration>Returns the aggregation period setting.org.djunits.value.vdouble.scalar.DurationReturns the update interval.intThe updates per period.Returns the updates per period setting.abstract voidsetAggregateName(String aggregateName) Sets the name of the series when aggregated, e.g. for legend.voidsetAggregationPeriod(org.djunits.value.vdouble.scalar.Duration aggregationPeriod) Changes the aggregation period.voidsetUpdatesPerPeriod(int n) Changes the updates per period.static <L extends LaneData<L>>
FdDataSourcesourceFromSampler(Sampler<?, L> sampler, PlotScheduler plotScheduler, GraphCrossSection<L> crossSection, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime, boolean harmonic) Creates aFdDataSourcefrom a sampler and positions.static <L extends LaneData<L>>
FdDataSourcesourceFromSampler(Sampler<?, L> sampler, PlotScheduler plotScheduler, GraphPath<L> path, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime) Creates aFdDataSourcefrom a sampler and positions.Methods inherited from class org.opentrafficsim.animation.graphs.PlotDelegate
addPlot, 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, toString, 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
-
UPDATES_PER_PERIOD
Updates per period. -
AGGREGATION_PERIOD
Aggregation period.
-
-
Constructor Details
-
FdDataSource
public FdDataSource(org.djunits.value.vdouble.scalar.Duration aggregationInterval, org.djunits.value.vdouble.scalar.Duration delay, PlotScheduler plotScheduler) Constructor.- Parameters:
aggregationInterval- aggregation intervaldelay- delayplotScheduler- plot scheduler
-
FdDataSource
public FdDataSource(org.djunits.value.vdouble.scalar.Duration aggregationInterval, org.djunits.value.vdouble.scalar.Duration delay, PlotScheduler plotScheduler, PlotSetting<org.djunits.value.vdouble.scalar.Duration> aggregationPeriodSetting, PlotSetting<Integer> updatesPerPeriodSetting) Constructor.- Parameters:
aggregationInterval- aggregation intervaldelay- delayplotScheduler- plot scheduleraggregationPeriodSetting- setting for aggregation periodupdatesPerPeriodSetting- setting for updates per period
-
-
Method Details
-
getAggregationPeriodSetting
Returns the aggregation period setting.- Returns:
- aggregation period setting
-
getUpdatesPerPeriodSetting
Returns the updates per period setting.- Returns:
- updates per period setting
-
getUpdatesPerPeriod
public int getUpdatesPerPeriod()The updates per period.- Returns:
- updates per period
-
setUpdatesPerPeriod
public void setUpdatesPerPeriod(int n) Changes the updates per period.- Parameters:
n- updates per period
-
getAggregationPeriod
public org.djunits.value.vdouble.scalar.Duration getAggregationPeriod()The aggregation period.- Returns:
- aggregation period
-
setAggregationPeriod
public void setAggregationPeriod(org.djunits.value.vdouble.scalar.Duration aggregationPeriod) Changes the aggregation period.- Parameters:
aggregationPeriod- aggregation period
-
getUpdateInterval
public org.djunits.value.vdouble.scalar.Duration getUpdateInterval()Returns the update interval.- Returns:
- update interval
-
calculatePaintStateUnsafe
public void calculatePaintStateUnsafe(org.djunits.value.vdouble.scalar.Duration time) Description copied from class:PlotDelegateCalculates paint state and offers it to the coupled plots. This method should only be invoked byPlotDelegate.calculatePaintStateSafe(org.djunits.value.vdouble.scalar.Duration)which makes sure that setting changes from different plots (with different working threads) do not cause parallel calculations on the same delegate. This makes sure that internal data gathering can occur consistently.- Specified by:
calculatePaintStateUnsafein classPlotDelegate<FundamentalDiagram.FdPaintState,FundamentalDiagram> - Parameters:
time- current time
-
setAggregateName
Sets the name of the series when aggregated, e.g. for legend. Default is "Aggregate".- Parameters:
aggregateName- name of the series when aggregated
-
sourceFromSampler
public static <L extends LaneData<L>> FdDataSource sourceFromSampler(Sampler<?, L> sampler, PlotScheduler plotScheduler, GraphCrossSection<L> crossSection, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime, boolean harmonic) Creates aFdDataSourcefrom a sampler and positions.- Type Parameters:
L- LaneData- Parameters:
sampler- samplerplotScheduler- plot schedulercrossSection- cross sectionaggregateLanes- whether to aggregate the positionsaggregationTime- aggregation time (and update time)harmonic- harmonic mean- Returns:
- source for a fundamental diagram from a sampler and positions
-
sourceFromSampler
public static <L extends LaneData<L>> FdDataSource sourceFromSampler(Sampler<?, L> sampler, PlotScheduler plotScheduler, GraphPath<L> path, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime) Creates aFdDataSourcefrom a sampler and positions.- Type Parameters:
L- LaneData- Parameters:
sampler- samplerplotScheduler- plot schedulerpath- cross sectionaggregateLanes- whether to aggregate the positionsaggregationTime- aggregation time (and update time)- Returns:
- source for a fundamental diagram from a sampler and positions
-
combinedSource
Combines multiple sources in to one source.- Parameters:
sources- sources coupled to their names for in the legend- Returns:
- combined source
-