Class FundamentalDiagram
java.lang.Object
org.opentrafficsim.animation.graphs.AbstractPlot<S>
org.opentrafficsim.animation.graphs.AbstractBoundedPlot<FundamentalDiagram.FdPaintState>
org.opentrafficsim.animation.graphs.FundamentalDiagram
- All Implemented Interfaces:
Identifiable,org.jfree.data.general.Dataset,org.jfree.data.general.SeriesDataset,org.jfree.data.xy.XYDataset
public class FundamentalDiagram
extends AbstractBoundedPlot<FundamentalDiagram.FdPaintState>
implements org.jfree.data.xy.XYDataset
Fundamental diagram from various sources.
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 interfaceDefines a line plot for a fundamental diagram.static final recordPaint state for fundamental diagram.static final recordOne data series within a fundamental diagram paint state.static enumQuantity enum defining density, flow and speed. -
Field Summary
Fields inherited from class org.opentrafficsim.animation.graphs.AbstractPlot
DEFAULT_INITIAL_UPPER_TIME_BOUND, GRAPH_ADD_EVENT, GRAPH_REMOVE_EVENT -
Constructor Summary
ConstructorsConstructorDescriptionFundamentalDiagram(String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, FdDataSource source, FundamentalDiagram.FdLine fdLine) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(EventListener listener, EventType eventType) Add listener to synchronize UI element when another UI element changes a setting, or the setting is changed programmatically.protected voidcalculatePaintState(org.djunits.value.vdouble.scalar.Duration time) Calculates the paint state object and offers it throughAbstractPlot.offerPaintState(S), or delegates this work to a delegate.protected FundamentalDiagram.FdPaintStateReturns an empty paint state.org.djunits.value.vdouble.scalar.DurationReturns the default aggregation period.intReturns the default updates per period.org.jfree.data.DomainOrderReturn the domain quantity.Return the graph type for transceiver.intgetItemCount(int series) Return the list of lane visibility flags.org.jfree.chart.LegendItemCollectionRetrieve the legend of this FundamentalDiagram.intReturns the number of series.Get the other (non domain; vertical axis) quantity.ImmutableList<org.djunits.value.vdouble.scalar.Duration>Returns the possible aggregation period values.Returns the possible updates per period values.Get the range quantity.intgetSeriesKey(int series) getStatusLabel(double domainValue, double rangeValue) Returns the status label when the mouse is over the given location.Retrieve the time info.org.djunits.value.vdouble.scalar.DurationReturns the update interval.getX(int series, int item) doublegetXValue(int series, int item) getY(int series, int item) doublegetYValue(int series, int item) booleanReturn whether the plot has a fundamental diagram line.intindexOf(Comparable seriesKey) voidsetAggregationPeriod(org.djunits.value.vdouble.scalar.Duration period) Sets the aggregation period.voidsetDomainQuantity(FundamentalDiagram.Quantity domainQuantity) Set the domain quantity.voidsetOtherQuantity(FundamentalDiagram.Quantity otherQuantity) Set the other (non domain; vertical axis) quantity.protected voidSets the paint state in a thread safe manner and notifies the listeners.voidsetRangeQuantity(FundamentalDiagram.Quantity rangeQuantity) Set the range quantity.voidsetTimeInfo(String timeInfo) Set the time info.voidsetUpdatesPerPeriod(int n) Sets the number of updates per period.toString()Methods inherited from class org.opentrafficsim.animation.graphs.AbstractBoundedPlot
setAutoBoundDomain, setAutoBoundRange, setChart, setLowerDomainBound, setLowerRangeBound, setUpperDomainBound, setUpperRangeBoundMethods inherited from class org.opentrafficsim.animation.graphs.AbstractPlot
addChangeListener, encodeAsPng, getAvailableTime, getCaption, getChart, getGroup, getId, getPaintState, invalidate, notifyPlotChange, offerPaintState, offerUpdateInterval, removeChangeListener, setGroup, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
FundamentalDiagram
public FundamentalDiagram(String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, FdDataSource source, FundamentalDiagram.FdLine fdLine) Constructor.- Parameters:
caption- captiondomainQuantity- initial quantity on the domain axisrangeQuantity- initial quantity on the range axissource- source providing the datafdLine- fundamental diagram line, may benull
-
-
Method Details
-
getPossibleUpdatesPerPeriod
Returns the possible updates per period values.- Returns:
- possible update per period values
-
getDefaultUpdatesPerPeriod
public int getDefaultUpdatesPerPeriod()Returns the default updates per period.- Returns:
- default updates per period
-
getPossibleAggregationPeriods
Returns the possible aggregation period values.- Returns:
- possible aggregation period values
-
getDefaultAggregationPeriod
public org.djunits.value.vdouble.scalar.Duration getDefaultAggregationPeriod()Returns the default aggregation period.- Returns:
- default aggregation period
-
addListener
Add listener to synchronize UI element when another UI element changes a setting, or the setting is changed programmatically.- Parameters:
listener- listenereventType- event type (i.e.UPDATES_PER_PERIODorAGGREGATION_PERIOD)
-
getNumberOfSeries
public int getNumberOfSeries()Returns the number of series.- Returns:
- number of series
-
getUpdateInterval
public org.djunits.value.vdouble.scalar.Duration getUpdateInterval()Returns the update interval.- Returns:
- update interval
-
setUpdatesPerPeriod
public void setUpdatesPerPeriod(int n) Sets the number of updates per period.- Parameters:
n- number of updates per period
-
setAggregationPeriod
public void setAggregationPeriod(org.djunits.value.vdouble.scalar.Duration period) Sets the aggregation period.- Parameters:
period- aggregation period
-
emptyPaintState
Description copied from class:AbstractPlotReturns an empty paint state. This is used at plot initialization.- Specified by:
emptyPaintStatein classAbstractPlot<FundamentalDiagram.FdPaintState>- Returns:
- empty paint state.
-
calculatePaintState
protected void calculatePaintState(org.djunits.value.vdouble.scalar.Duration time) Description copied from class:AbstractPlotCalculates the paint state object and offers it throughAbstractPlot.offerPaintState(S), or delegates this work to a delegate. This method is invoked by the worker thread and can thus perform heavy calculations outside of the Swing EDT. Intermediate paint states during long calculations may also be offered. It is up to the implementation to either calculate a complete paint state, or cumulatively built on the results from previous calls. It is also up to the implementation to know when the whole time span needs to be recalculated due to property changes.- Specified by:
calculatePaintStatein classAbstractPlot<FundamentalDiagram.FdPaintState>- Parameters:
time- time until which data in the paint state should be calculated
-
setPaintState
protected void setPaintState()Description copied from class:AbstractPlotSets the paint state in a thread safe manner and notifies the listeners. This method is always invoked on the Swing EDT. This method may be overridden to use a newly set paint state (after callingsuper.setPaintState()) to set internal properties. For example, setting the block size of an internal block renderer based on the granularity of the data.- Overrides:
setPaintStatein classAbstractPlot<FundamentalDiagram.FdPaintState>
-
getSeriesCount
public int getSeriesCount()- Specified by:
getSeriesCountin interfaceorg.jfree.data.general.SeriesDataset
-
getSeriesKey
- Specified by:
getSeriesKeyin interfaceorg.jfree.data.general.SeriesDataset
-
indexOf
- Specified by:
indexOfin interfaceorg.jfree.data.general.SeriesDataset
-
getDomainOrder
public org.jfree.data.DomainOrder getDomainOrder()- Specified by:
getDomainOrderin interfaceorg.jfree.data.xy.XYDataset
-
getItemCount
public int getItemCount(int series) - Specified by:
getItemCountin interfaceorg.jfree.data.xy.XYDataset
-
getX
- Specified by:
getXin interfaceorg.jfree.data.xy.XYDataset
-
getXValue
public double getXValue(int series, int item) - Specified by:
getXValuein interfaceorg.jfree.data.xy.XYDataset
-
getY
- Specified by:
getYin interfaceorg.jfree.data.xy.XYDataset
-
getYValue
public double getYValue(int series, int item) - Specified by:
getYValuein interfaceorg.jfree.data.xy.XYDataset
-
getGraphType
Description copied from class:AbstractPlotReturn the graph type for transceiver.- Specified by:
getGraphTypein classAbstractPlot<FundamentalDiagram.FdPaintState>- Returns:
- the graph type.
-
getStatusLabel
Description copied from class:AbstractPlotReturns the status label when the mouse is over the given location.- Specified by:
getStatusLabelin classAbstractPlot<FundamentalDiagram.FdPaintState>- Parameters:
domainValue- domain value (x-axis)rangeValue- range value (y-axis)- Returns:
- status label when the mouse is over the given location
-
getLegend
public org.jfree.chart.LegendItemCollection getLegend()Retrieve the legend of this FundamentalDiagram.- Returns:
- the legend
-
getLaneVisible
Return the list of lane visibility flags.- Returns:
- the list of lane visibility flags
-
getDomainQuantity
Return the domain quantity.- Returns:
- the domain quantity
-
setDomainQuantity
Set the domain quantity.- Parameters:
domainQuantity- the new domain quantity
-
getOtherQuantity
Get the other (non domain; vertical axis) quantity.- Returns:
- the quantity for the vertical axis
-
setOtherQuantity
Set the other (non domain; vertical axis) quantity.- Parameters:
otherQuantity- the quantity for the vertical axis
-
getRangeQuantity
Get the range quantity.- Returns:
- the range quantity
-
setRangeQuantity
Set the range quantity.- Parameters:
rangeQuantity- the new range quantity
-
getTimeInfo
Retrieve the time info.- Returns:
- the time info
-
setTimeInfo
Set the time info.- Parameters:
timeInfo- the new time info
-
hasLineFD
public boolean hasLineFD()Return whether the plot has a fundamental diagram line.- Returns:
- whether the plot has a fundamental diagram line
-
toString
-