Package org.opentrafficsim.draw.graphs
Class FundamentalDiagram
java.lang.Object
org.opentrafficsim.draw.graphs.AbstractPlot
org.opentrafficsim.draw.graphs.AbstractBoundedPlot
org.opentrafficsim.draw.graphs.FundamentalDiagram
- All Implemented Interfaces:
Dataset,SeriesDataset,XYDataset,org.opentrafficsim.base.Identifiable
Fundamental diagram from various sources.
Copyright (c) 2013-2023 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 TypeClassDescription(package private) static classAbstract implementation to link to fundamental diagrams.static interfaceDefines a line plot for a fundamental diagram.static interfaceData source for a fundamental diagram.static enumQuantity enum defining density, flow and speed. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double[]Aggregation periods.static final int[]Update frequencies (n * 1/period).Fields inherited from class org.opentrafficsim.draw.graphs.AbstractPlot
DEFAULT_INITIAL_UPPER_TIME_BOUND, GRAPH_ADD_EVENT, GRAPH_REMOVE_EVENT -
Constructor Summary
ConstructorsConstructorDescriptionFundamentalDiagram(String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, org.opentrafficsim.core.dsol.OtsSimulatorInterface simulator, FundamentalDiagram.FdSource source, FundamentalDiagram.FdLine fdLine) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic FundamentalDiagram.FdSourcecombinedSource(Map<String, FundamentalDiagram.FdSource> sources) Combines multiple sources in to one source.Return the domain quantity.Return the graph type for transceiver.intgetItemCount(int series) Return the list of lane visibility flags.Retrievee the legend of this FundamentalDiagram.Get the other (non domain; vertical axis) quantity.Get the range quantity.intgetSeriesKey(int series) Get the data source.getStatusLabel(double domainValue, double rangeValue) Returns the status label when the mouse is over the given location.Retrieve the time info.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.protected voidincreaseTime(Time time) Increase the simulated time span.intindexOf(Comparable seriesKey) voidsetDomainQuantity(FundamentalDiagram.Quantity domainQuantity) Set the domain quantity.voidsetOtherQuantity(FundamentalDiagram.Quantity otherQuantity) Set the other (non domain; vertical axis) quantity.voidsetRangeQuantity(FundamentalDiagram.Quantity rangeQuantity) Set the range quantity.voidsetTimeInfo(String timeInfo) Set the time info.static FundamentalDiagram.FdSourcesourceFromSampler(RoadSampler sampler, GraphCrossSection<LaneDataRoad> crossSection, boolean aggregateLanes, Duration aggregationTime, boolean harmonic) Creates aSourcefrom a sampler and positions.static FundamentalDiagram.FdSourcesourceFromSampler(RoadSampler sampler, GraphPath<LaneDataRoad> path, boolean aggregateLanes, Duration aggregationTime) Creates aSourcefrom a sampler and positions.toString()Methods inherited from class org.opentrafficsim.draw.graphs.AbstractBoundedPlot
setAutoBoundDomain, setAutoBoundRange, setChart, setLowerDomainBound, setLowerRangeBound, setUpperDomainBound, setUpperRangeBoundMethods inherited from class org.opentrafficsim.draw.graphs.AbstractPlot
addChangeListener, encodeAsPng, getCaption, getChart, getGroup, getId, getSimulator, getUpdateTime, notifyPlotChange, removeChangeListener, setGroup, setUpdateInterval, 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
-
Field Details
-
DEFAULT_PERIODS
public static final double[] DEFAULT_PERIODSAggregation periods. -
DEFAULT_UPDATE_FREQUENCIES
public static final int[] DEFAULT_UPDATE_FREQUENCIESUpdate frequencies (n * 1/period).
-
-
Constructor Details
-
FundamentalDiagram
public FundamentalDiagram(String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, org.opentrafficsim.core.dsol.OtsSimulatorInterface simulator, FundamentalDiagram.FdSource source, FundamentalDiagram.FdLine fdLine) Constructor.- Parameters:
caption- String; captiondomainQuantity- Quantity; initial quantity on the domain axisrangeQuantity- Quantity; initial quantity on the range axissimulator- OtsSimulatorInterface; simulatorsource- FdSource; source providing the datafdLine- fundamental diagram line, may benull
-
-
Method Details
-
increaseTime
Increase the simulated time span.- Specified by:
increaseTimein classAbstractPlot- Parameters:
time- Time; time to increase to
-
getSeriesCount
public int getSeriesCount()- Specified by:
getSeriesCountin interfaceSeriesDataset
-
getSeriesKey
- Specified by:
getSeriesKeyin interfaceSeriesDataset
-
indexOf
- Specified by:
indexOfin interfaceSeriesDataset
-
getDomainOrder
- Specified by:
getDomainOrderin interfaceXYDataset
-
getItemCount
public int getItemCount(int series) - Specified by:
getItemCountin interfaceXYDataset
-
getX
-
getXValue
public double getXValue(int series, int item) -
getY
-
getYValue
public double getYValue(int series, int item) -
getGraphType
Return the graph type for transceiver.- Specified by:
getGraphTypein classAbstractPlot- Returns:
- GraphType; the graph type.
-
getStatusLabel
Returns the status label when the mouse is over the given location.- Specified by:
getStatusLabelin classAbstractPlot- Parameters:
domainValue- double; domain value (x-axis)rangeValue- double; range value (y-axis)- Returns:
- String; status label when the mouse is over the given location
-
sourceFromSampler
public static FundamentalDiagram.FdSource sourceFromSampler(RoadSampler sampler, GraphCrossSection<LaneDataRoad> crossSection, boolean aggregateLanes, Duration aggregationTime, boolean harmonic) Creates aSourcefrom a sampler and positions.- Parameters:
sampler- RoadSampler; samplercrossSection- GraphCrossSection<LaneData>; cross sectionaggregateLanes- boolean; whether to aggregate the positionsaggregationTime- Duration; aggregation time (and update time)harmonic- boolean; harmonic mean- Returns:
- Source; source for a fundamental diagram from a sampler and positions
-
sourceFromSampler
public static FundamentalDiagram.FdSource sourceFromSampler(RoadSampler sampler, GraphPath<LaneDataRoad> path, boolean aggregateLanes, Duration aggregationTime) Creates aSourcefrom a sampler and positions.- Parameters:
sampler- RoadSampler; samplerpath- GraphPath<LaneData>; cross sectionaggregateLanes- boolean; whether to aggregate the positionsaggregationTime- Duration; aggregation time (and update time)- Returns:
- Source; source for a fundamental diagram from a sampler and positions
-
combinedSource
public static FundamentalDiagram.FdSource combinedSource(Map<String, FundamentalDiagram.FdSource> sources) Combines multiple sources in to one source.- Parameters:
sources- Map<String, FdSource>; sources coupled to their names for in the legend- Returns:
- FdSource; combined source
-
toString
-
getSource
Get the data source.- Returns:
- FdSource; the data source
-
getLegend
Retrievee the legend of this FundamentalDiagram.- Returns:
- LegendItemCollection; the legend
-
getLaneVisible
Return the list of lane visibility flags.- Returns:
- List<Boolean>; the list of lane visibility flags
-
getDomainQuantity
Return the domain quantity.- Returns:
- Quantity; the domain quantity
-
setDomainQuantity
Set the domain quantity.- Parameters:
domainQuantity- Quantity; the new domain quantity
-
getOtherQuantity
Get the other (non domain; vertical axis) quantity.- Returns:
- Quantity; the quantity for the vertical axis
-
setOtherQuantity
Set the other (non domain; vertical axis) quantity.- Parameters:
otherQuantity- Quantity; the quantity for the vertical axis
-
getRangeQuantity
Get the range quantity.- Returns:
- Quantity; the range quantity
-
setRangeQuantity
Set the range quantity.- Parameters:
rangeQuantity- Quantity; the new range quantity
-
getTimeInfo
Retrieve the time info.- Returns:
- String; the time info
-
setTimeInfo
Set the time info.- Parameters:
timeInfo- String; the new time info
-
hasLineFD
public boolean hasLineFD()Return whether the plot has a fundamental diagram line.- Returns:
- boolean; whether the plot has a fundamental diagram line
-