Package org.opentrafficsim.draw.graphs
Class AbstractContourPlot<Z extends Number>
java.lang.Object
org.opentrafficsim.draw.graphs.AbstractPlot
org.opentrafficsim.draw.graphs.AbstractBoundedPlot
org.opentrafficsim.draw.graphs.AbstractSpaceTimePlot
org.opentrafficsim.draw.graphs.AbstractSamplerPlot
org.opentrafficsim.draw.graphs.AbstractContourPlot<Z>
- Type Parameters:
Z
- z-value type
- All Implemented Interfaces:
ActionListener
,EventListener
,org.djutils.base.Identifiable
,org.jfree.data.general.Dataset
,org.jfree.data.general.SeriesDataset
,org.jfree.data.xy.XYDataset
,org.jfree.data.xy.XYZDataset
,XyInterpolatedDataset
- Direct Known Subclasses:
ContourPlotAcceleration
,ContourPlotDelay
,ContourPlotDensity
,ContourPlotFlow
,ContourPlotSpeed
public abstract class AbstractContourPlot<Z extends Number>
extends AbstractSamplerPlot
implements XyInterpolatedDataset, ActionListener
Class for contour plots. The data that is plotted is stored in a
ContourDataSource
, which may be shared among several
contour plots along the same path. This abstract class takes care of the interactions between the plot and the data pool. Sub
classes only need to specify a few plot specific variables and functionalities.
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
-
Field Summary
Fields inherited from class org.opentrafficsim.draw.graphs.AbstractPlot
DEFAULT_INITIAL_UPPER_TIME_BOUND, GRAPH_ADD_EVENT, GRAPH_REMOVE_EVENT
-
Constructor Summary
ConstructorDescriptionAbstractContourPlot
(String caption, PlotScheduler scheduler, ContourDataSource dataPool, BoundsPaintScale paintScale, Z legendStep, String legendFormat, String valueFormat) Constructor with specified paint scale.AbstractContourPlot
(String caption, PlotScheduler scheduler, ContourDataSource dataPool, Z legendStep, String legendFormat, Z minValue, Z maxValue, String valueFormat) Constructor with default paint scale. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
actionPerformed
(ActionEvent actionEvent) Returns the block renderer.protected abstract ContourDataSource.ContourDataType<Z,
?> Returns the contour data type for use in aContourDataSource
.final ContourDataSource
Returns the data pool for sub classes.final org.jfree.data.DomainOrder
final int
getItemCount
(int series) int
Returns the number of items in each column.final int
final Comparable<String>
getSeriesKey
(int series) double
Returns the space granularity, just for information.final String
getStatusLabel
(double domainValue, double rangeValue) Returns the status label when the mouse is over the given location.double
Returns the time granularity, just for information.protected abstract double
getValue
(int item, double cellLength, double cellSpan) Obtain value for cell from the data pool.final Number
getX
(int series, int item) final double
getXValue
(int series, int item) final Number
getY
(int series, int item) final double
getYValue
(int series, int item) final Number
getZ
(int series, int item) final double
getZValue
(int series, int item) protected final void
increaseTime
(org.djunits.value.vdouble.scalar.Time time) Increase the simulated time span.final int
indexOf
(Comparable seriesKey) protected abstract double
scale
(double si) Scale the value from SI to the desired unit for users.final void
setInterpolation
(boolean interpolate) Sets the check box for interpolated rendering and block renderer setting.final void
setSpaceGranularity
(double granularity) Sets the correct space granularity radio button to selected.final void
setTimeGranularity
(double granularity) Sets the correct time granularity radio button to selected.Methods inherited from class org.opentrafficsim.draw.graphs.AbstractSamplerPlot
getEndLocation, getPath, getSamplerData, getTrajectories
Methods inherited from class org.opentrafficsim.draw.graphs.AbstractSpaceTimePlot
setAutoBoundDomain, setAutoBoundRange, setChart, update, updateFixedDomainRange
Methods inherited from class org.opentrafficsim.draw.graphs.AbstractBoundedPlot
setLowerDomainBound, setLowerRangeBound, setUpperDomainBound, setUpperRangeBound
Methods inherited from class org.opentrafficsim.draw.graphs.AbstractPlot
addChangeListener, encodeAsPng, getCaption, getChart, getGraphType, getGroup, getId, getUpdateTime, notifyPlotChange, removeChangeListener, setGroup, setUpdateInterval
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
AbstractContourPlot
public AbstractContourPlot(String caption, PlotScheduler scheduler, ContourDataSource dataPool, BoundsPaintScale paintScale, Z legendStep, String legendFormat, String valueFormat) Constructor with specified paint scale.- Parameters:
caption
- String; captionscheduler
- PlotScheduler; scheduler.dataPool
- ContourDataSource; data poolpaintScale
- BoundsPaintScale; paint scalelegendStep
- Z; increment between color legend entrieslegendFormat
- String; format string for the captions in the color legendvalueFormat
- String; format string used to create status label (under the mouse)
-
AbstractContourPlot
public AbstractContourPlot(String caption, PlotScheduler scheduler, ContourDataSource dataPool, Z legendStep, String legendFormat, Z minValue, Z maxValue, String valueFormat) Constructor with default paint scale.- Parameters:
caption
- String; captionscheduler
- PlotScheduler; scheduler.dataPool
- ContourDataSource; data poollegendStep
- Z; increment between color legend entrieslegendFormat
- String; format string for the captions in the color legendminValue
- Z; minimum valuemaxValue
- Z; maximum valuevalueFormat
- String; format string used to create status label (under the mouse)
-
-
Method Details
-
getTimeGranularity
public double getTimeGranularity()Returns the time granularity, just for information.- Returns:
- double; time granularity
-
getSpaceGranularity
public double getSpaceGranularity()Returns the space granularity, just for information.- Returns:
- double; space granularity
-
setSpaceGranularity
public final void setSpaceGranularity(double granularity) Sets the correct space granularity radio button to selected. This is done from aDataPool
to keep multiple plots consistent.- Parameters:
granularity
- double; space granularity
-
setTimeGranularity
public final void setTimeGranularity(double granularity) Sets the correct time granularity radio button to selected. This is done from aDataPool
to keep multiple plots consistent.- Parameters:
granularity
- double; time granularity
-
setInterpolation
public final void setInterpolation(boolean interpolate) Sets the check box for interpolated rendering and block renderer setting. This is done from aDataPool
to keep multiple plots consistent.- Parameters:
interpolate
- boolean; selected or not
-
getDataPool
Returns the data pool for sub classes.- Returns:
- ContourDataSource; data pool for subclasses
-
getItemCount
public final 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 final 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 final double getYValue(int series, int item) - Specified by:
getYValue
in interfaceorg.jfree.data.xy.XYDataset
-
getZ
- Specified by:
getZ
in interfaceorg.jfree.data.xy.XYZDataset
-
getSeriesKey
- Specified by:
getSeriesKey
in interfaceorg.jfree.data.general.SeriesDataset
-
indexOf
- Specified by:
indexOf
in interfaceorg.jfree.data.general.SeriesDataset
-
getDomainOrder
public final org.jfree.data.DomainOrder getDomainOrder()- Specified by:
getDomainOrder
in interfaceorg.jfree.data.xy.XYDataset
-
getZValue
public final double getZValue(int series, int item) - Specified by:
getZValue
in interfaceorg.jfree.data.xy.XYZDataset
-
getSeriesCount
public final int getSeriesCount()- Specified by:
getSeriesCount
in interfaceorg.jfree.data.general.SeriesDataset
-
getRangeBinCount
public int getRangeBinCount()Returns the number of items in each column.- Specified by:
getRangeBinCount
in interfaceXyInterpolatedDataset
- Returns:
- int; number of items in each column
-
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
-
increaseTime
protected final 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
-
getValue
protected abstract double getValue(int item, double cellLength, double cellSpan) Obtain value for cell from the data pool.- Parameters:
item
- int; item numbercellLength
- double; cell lengthcellSpan
- double; cell duration- Returns:
- double; value for cell from the data pool
-
scale
protected abstract double scale(double si) Scale the value from SI to the desired unit for users.- Parameters:
si
- double; SI value- Returns:
- double; scaled value
-
getContourDataType
Returns the contour data type for use in aContourDataSource
.- Returns:
- CountorDataType; contour data type
-
getBlockRenderer
Returns the block renderer.- Returns:
- block renderer
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-