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:
org.djutils.base.Identifiable
,org.jfree.data.general.Dataset
,org.jfree.data.general.SeriesDataset
,org.jfree.data.xy.XYDataset
Fundamental diagram from various sources.
Copyright (c) 2013-2024 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
Modifier and TypeClassDescription(package private) static class
Abstract implementation to link to fundamental diagrams.static interface
Defines a line plot for a fundamental diagram.static interface
Data source for a fundamental diagram.static enum
Quantity enum defining density, flow and speed. -
Field Summary
Modifier 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
ConstructorDescriptionFundamentalDiagram
(String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, PlotScheduler scheduler, FundamentalDiagram.FdSource source, FundamentalDiagram.FdLine fdLine) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic FundamentalDiagram.FdSource
combinedSource
(Map<String, FundamentalDiagram.FdSource> sources) Combines multiple sources in to one source.org.jfree.data.DomainOrder
Return the domain quantity.Return the graph type for transceiver.int
getItemCount
(int series) Return the list of lane visibility flags.org.jfree.chart.LegendItemCollection
Retrievee the legend of this FundamentalDiagram.Get the other (non domain; vertical axis) quantity.Get the range quantity.int
getSeriesKey
(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) double
getXValue
(int series, int item) getY
(int series, int item) double
getYValue
(int series, int item) boolean
Return whether the plot has a fundamental diagram line.protected void
increaseTime
(org.djunits.value.vdouble.scalar.Time time) Increase the simulated time span.int
indexOf
(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
(String timeInfo) Set the time info.static <L extends LaneData<L>>
FundamentalDiagram.FdSourcesourceFromSampler
(Sampler<?, L> sampler, GraphCrossSection<L> crossSection, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime, boolean harmonic) Creates aSource
from a sampler and positions.static <L extends LaneData<L>>
FundamentalDiagram.FdSourcesourceFromSampler
(Sampler<?, L> sampler, GraphPath<L> path, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime) Creates aSource
from a sampler and positions.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, 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(String caption, FundamentalDiagram.Quantity domainQuantity, FundamentalDiagram.Quantity rangeQuantity, PlotScheduler scheduler, FundamentalDiagram.FdSource source, FundamentalDiagram.FdLine fdLine) Constructor.- Parameters:
caption
- String; captiondomainQuantity
- Quantity; initial quantity on the domain axisrangeQuantity
- Quantity; initial quantity on the range axisscheduler
- PlotScheduler; scheduler.source
- FdSource; source providing the datafdLine
- fundamental diagram line, may benull
-
-
Method Details
-
increaseTime
protected void increaseTime(org.djunits.value.vdouble.scalar.Time time) 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 interfaceorg.jfree.data.general.SeriesDataset
-
getSeriesKey
- Specified by:
getSeriesKey
in interfaceorg.jfree.data.general.SeriesDataset
-
indexOf
- Specified by:
indexOf
in interfaceorg.jfree.data.general.SeriesDataset
-
getDomainOrder
public org.jfree.data.DomainOrder getDomainOrder()- Specified by:
getDomainOrder
in interfaceorg.jfree.data.xy.XYDataset
-
getItemCount
public int getItemCount(int series) - Specified by:
getItemCount
in interfaceorg.jfree.data.xy.XYDataset
-
getX
- Specified by:
getX
in interfaceorg.jfree.data.xy.XYDataset
-
getXValue
public double getXValue(int series, int item) - Specified by:
getXValue
in interfaceorg.jfree.data.xy.XYDataset
-
getY
- Specified by:
getY
in interfaceorg.jfree.data.xy.XYDataset
-
getYValue
public double getYValue(int series, int item) - Specified by:
getYValue
in interfaceorg.jfree.data.xy.XYDataset
-
getGraphType
Return the graph type for transceiver.- Specified by:
getGraphType
in classAbstractPlot
- Returns:
- GraphType; the graph type.
-
getStatusLabel
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 <L extends LaneData<L>> FundamentalDiagram.FdSource sourceFromSampler(Sampler<?, L> sampler, GraphCrossSection<L> crossSection, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime, boolean harmonic) Creates aSource
from a sampler and positions.- Type Parameters:
L
- LaneData- Parameters:
sampler
- Sampler<?, L>; 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 <L extends LaneData<L>> FundamentalDiagram.FdSource sourceFromSampler(Sampler<?, L> sampler, GraphPath<L> path, boolean aggregateLanes, org.djunits.value.vdouble.scalar.Duration aggregationTime) Creates aSource
from a sampler and positions.- Type Parameters:
L
- LaneData- Parameters:
sampler
- Sampler<?, L>; 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
public org.jfree.chart.LegendItemCollection 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
-