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
,Identifiable
public class FundamentalDiagram extends AbstractBoundedPlot implements XYDataset
Fundamental diagram from various sources.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 14 okt. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FundamentalDiagram.FdSource
Data source for a fundamental diagram.static class
FundamentalDiagram.Quantity
Quantity enum defining density, flow and speed. -
Field Summary
Fields Modifier and Type Field Description static double[]
DEFAULT_PERIODS
Aggregation periods.static int[]
DEFAULT_UPDATE_FREQUENCIES
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
Constructors Constructor Description FundamentalDiagram(java.lang.String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, OTSSimulatorInterface simulator, FundamentalDiagram.FdSource source)
Constructor.FundamentalDiagram(java.lang.String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, OTSSimulatorInterface simulator, Sampler<?> sampler, GraphCrossSection<KpiLaneDirection> crossSection, boolean aggregateLanes, Duration aggregationTime, boolean harmonic)
Constructor using a sampler as source.FundamentalDiagram(java.lang.String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, OTSSimulatorInterface simulator, Sampler<?> sampler, GraphPath<KpiLaneDirection> path, boolean aggregateLanes, Duration aggregationTime)
Constructor using a sampler as source. -
Method Summary
Modifier and Type Method Description DomainOrder
getDomainOrder()
FundamentalDiagram.Quantity
getDomainQuantity()
Return the domain quantity.GraphType
getGraphType()
Return the graph type for transceiver.int
getItemCount(int series)
java.util.List<java.lang.Boolean>
getLaneVisible()
Return the list of lane visibility flags.LegendItemCollection
getLegend()
Retrievee the legend of this FundamentalDiagram.FundamentalDiagram.Quantity
getOtherQuantity()
Get the other (non domain; vertical axis) quantity.FundamentalDiagram.Quantity
getRangeQuantity()
Get the range quantity.int
getSeriesCount()
java.lang.Comparable<java.lang.String>
getSeriesKey(int series)
FundamentalDiagram.FdSource
getSource()
Get the data source.java.lang.String
getStatusLabel(double domainValue, double rangeValue)
Returns the status label when the mouse is over the given location.java.lang.String
getTimeInfo()
Retrieve the time info.java.lang.Number
getX(int series, int item)
double
getXValue(int series, int item)
java.lang.Number
getY(int series, int item)
double
getYValue(int series, int item)
protected void
increaseTime(Time time)
Increase the simulated time span.int
indexOf(java.lang.Comparable seriesKey)
void
setDomainQuantity(FundamentalDiagram.Quantity domainQuantity)
Set the domain quantity.void
setOtherQuantity(FundamentalDiagram.Quantity otherQuantity)
Set the other (non domain; vertical axis) quantity.void
setRangeQuantity(FundamentalDiagram.Quantity rangeQuantity)
Set the range quantity.void
setTimeInfo(java.lang.String timeInfo)
Set the time info.static FundamentalDiagram.FdSource
sourceFromSampler(Sampler<?> sampler, GraphCrossSection<KpiLaneDirection> crossSection, boolean aggregateLanes, Duration aggregationTime, boolean harmonic)
Creates aSource
from a sampler and positions.static FundamentalDiagram.FdSource
sourceFromSampler(Sampler<?> sampler, GraphPath<KpiLaneDirection> path, boolean aggregateLanes, Duration aggregationTime)
Creates aSource
from a sampler and positions.java.lang.String
toString()
Methods inherited from class org.opentrafficsim.draw.graphs.AbstractBoundedPlot
setAutoBoundDomain, setAutoBoundRange, setChart, setLowerDomainBound, setLowerRangeBound, setUpperDomainBound, setUpperRangeBound
Methods inherited from class org.opentrafficsim.draw.graphs.AbstractPlot
addChangeListener, encodeAsPng, getCaption, getChart, getGroup, getId, getSimulator, getUpdateTime, notifyPlotChange, removeChangeListener, setGroup, setUpdateInterval, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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(java.lang.String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, OTSSimulatorInterface simulator, FundamentalDiagram.FdSource source)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 data
-
FundamentalDiagram
public FundamentalDiagram(java.lang.String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, OTSSimulatorInterface simulator, Sampler<?> sampler, GraphCrossSection<KpiLaneDirection> crossSection, boolean aggregateLanes, Duration aggregationTime, boolean harmonic)Constructor using a sampler as source.- Parameters:
caption
- String; captiondomainQuantity
- Quantity; initial quantity on the domain axisrangeQuantity
- Quantity; initial quantity on the range axissimulator
- OTSSimulatorInterface; simulatorsampler
- Sampler<?>; samplercrossSection
- GraphCrossSection<KpiLaneDirection>; lanesaggregateLanes
- boolean; whether to aggregate the positionsaggregationTime
- Duration; aggregation time (and update time)harmonic
- boolean; harmonic mean
-
FundamentalDiagram
public FundamentalDiagram(java.lang.String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, OTSSimulatorInterface simulator, Sampler<?> sampler, GraphPath<KpiLaneDirection> path, boolean aggregateLanes, Duration aggregationTime)Constructor using a sampler as source.- Parameters:
caption
- String; captiondomainQuantity
- Quantity; initial quantity on the domain axisrangeQuantity
- Quantity; initial quantity on the range axissimulator
- OTSSimulatorInterface; simulatorsampler
- Sampler<?>; samplerpath
- GraphPath<KpiLaneDirection>; lanesaggregateLanes
- boolean; whether to aggregate the positionsaggregationTime
- Duration; aggregation time (and update time)
-
-
Method Details
-
increaseTime
Increase the simulated time span.- Specified by:
increaseTime
in classAbstractPlot
- Parameters:
time
- Time; time to increase to
-
getSeriesCount
public int getSeriesCount()- Specified by:
getSeriesCount
in interfaceSeriesDataset
-
getSeriesKey
public java.lang.Comparable<java.lang.String> getSeriesKey(int series)- Specified by:
getSeriesKey
in interfaceSeriesDataset
-
indexOf
public int indexOf(java.lang.Comparable seriesKey)- Specified by:
indexOf
in interfaceSeriesDataset
-
getDomainOrder
- Specified by:
getDomainOrder
in interfaceXYDataset
-
getItemCount
public int getItemCount(int series)- Specified by:
getItemCount
in interfaceXYDataset
-
getX
public java.lang.Number getX(int series, int item) -
getXValue
public double getXValue(int series, int item) -
getY
public java.lang.Number getY(int series, int item) -
getYValue
public double getYValue(int series, int item) -
getGraphType
Return the graph type for transceiver.- Specified by:
getGraphType
in classAbstractPlot
- Returns:
- GraphType; the graph type.
-
getStatusLabel
public java.lang.String getStatusLabel(double domainValue, double rangeValue)Returns the status label when the mouse is over the given location.- Specified by:
getStatusLabel
in 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(Sampler<?> sampler, GraphCrossSection<KpiLaneDirection> crossSection, boolean aggregateLanes, Duration aggregationTime, boolean harmonic)Creates aSource
from a sampler and positions.- Parameters:
sampler
- Sampler<?>; samplercrossSection
- GraphCrossSection<KpiLaneDirection>; 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(Sampler<?> sampler, GraphPath<KpiLaneDirection> path, boolean aggregateLanes, Duration aggregationTime)Creates aSource
from a sampler and positions.- Parameters:
sampler
- Sampler<?>; samplerpath
- GraphPath<KpiLaneDirection>; 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
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getSource
Get the data source.- Returns:
- FdSource; the data source
-
getLegend
Retrievee the legend of this FundamentalDiagram.- Returns:
- LegendItemCollection; the legend
-
getLaneVisible
public java.util.List<java.lang.Boolean> 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
public java.lang.String getTimeInfo()Retrieve the time info.- Returns:
- String; the time info
-
setTimeInfo
public void setTimeInfo(java.lang.String timeInfo)Set the time info.- Parameters:
timeInfo
- String; the new time info
-