Package org.opentrafficsim.draw.graphs
Class AbstractContourPlot<Z extends java.lang.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:
java.awt.event.ActionListener
,java.util.EventListener
,Dataset
,SeriesDataset
,XYDataset
,XYZDataset
,Identifiable
- Direct Known Subclasses:
ContourPlotAcceleration
,ContourPlotDelay
,ContourPlotDensity
,ContourPlotFlow
,ContourPlotSpeed
public abstract class AbstractContourPlot<Z extends java.lang.Number> extends AbstractSamplerPlot implements java.awt.event.ActionListener
Class for contour plots. The data that is plotted is stored in aContourDataSource
, 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-2020 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 4 okt. 2018
- 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
Constructors Constructor Description AbstractContourPlot(java.lang.String caption, OTSSimulatorInterface simulator, ContourDataSource<?> dataPool, BoundsPaintScale paintScale, Z legendStep, java.lang.String legendFormat, java.lang.String valueFormat)
Constructor with specified paint scale.AbstractContourPlot(java.lang.String caption, OTSSimulatorInterface simulator, ContourDataSource<?> dataPool, Z legendStep, java.lang.String legendFormat, Z minValue, Z maxValue, java.lang.String valueFormat)
Constructor with default paint scale.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent actionEvent)
XYInterpolatedBlockRenderer
getBlockRenderer()
Returns the block renderer.protected abstract ContourDataSource.ContourDataType<Z,?>
getContourDataType()
Returns the contour data type for use in aContourDataSource
.ContourDataSource<?>
getDataPool()
Returns the data pool for sub classes.DomainOrder
getDomainOrder()
int
getItemCount(int series)
int
getRangeBinCount()
int
getSeriesCount()
java.lang.Comparable<java.lang.String>
getSeriesKey(int series)
double
getSpaceGranularity()
Returns the space granularity, just for information.java.lang.String
getStatusLabel(double domainValue, double rangeValue)
Returns the status label when the mouse is over the given location.double
getTimeGranularity()
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.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)
java.lang.Number
getZ(int series, int item)
double
getZValue(int series, int item)
protected void
increaseTime(Time time)
Increase the simulated time span.int
indexOf(java.lang.Comparable seriesKey)
protected abstract double
scale(double si)
Scale the value from SI to the desired unit for users.void
setInterpolation(boolean interpolate)
Sets the check box for interpolated rendering and block renderer setting.void
setSpaceGranularity(double granularity)
Sets the correct space granularity radio button to selected.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, getSimulator, 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 Detail
-
AbstractContourPlot
public AbstractContourPlot(java.lang.String caption, OTSSimulatorInterface simulator, ContourDataSource<?> dataPool, BoundsPaintScale paintScale, Z legendStep, java.lang.String legendFormat, java.lang.String valueFormat)
Constructor with specified paint scale.- Parameters:
caption
- String; captionsimulator
- OTSSimulatorInterface; simulatordataPool
- 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(java.lang.String caption, OTSSimulatorInterface simulator, ContourDataSource<?> dataPool, Z legendStep, java.lang.String legendFormat, Z minValue, Z maxValue, java.lang.String valueFormat)
Constructor with default paint scale.- Parameters:
caption
- String; captionsimulator
- OTSSimulatorInterface; simulatordataPool
- 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 Detail
-
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
public final ContourDataSource<?> 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 interfaceXYDataset
-
getX
public final java.lang.Number getX(int series, int item)
-
getXValue
public final double getXValue(int series, int item)
-
getY
public final java.lang.Number getY(int series, int item)
-
getYValue
public final double getYValue(int series, int item)
-
getZ
public final java.lang.Number getZ(int series, int item)
- Specified by:
getZ
in interfaceXYZDataset
-
getSeriesKey
public final java.lang.Comparable<java.lang.String> getSeriesKey(int series)
- Specified by:
getSeriesKey
in interfaceSeriesDataset
-
indexOf
public final int indexOf(java.lang.Comparable seriesKey)
- Specified by:
indexOf
in interfaceSeriesDataset
-
getDomainOrder
public final DomainOrder getDomainOrder()
- Specified by:
getDomainOrder
in interfaceXYDataset
-
getZValue
public final double getZValue(int series, int item)
- Specified by:
getZValue
in interfaceXYZDataset
-
getSeriesCount
public final int getSeriesCount()
- Specified by:
getSeriesCount
in interfaceSeriesDataset
-
getRangeBinCount
public int getRangeBinCount()
-
getStatusLabel
public final 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
-
increaseTime
protected final void increaseTime(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
protected abstract ContourDataSource.ContourDataType<Z,?> getContourDataType()
Returns the contour data type for use in aContourDataSource
.- Returns:
- CountorDataType; contour data type
-
getBlockRenderer
public XYInterpolatedBlockRenderer getBlockRenderer()
Returns the block renderer.- Returns:
- block renderer
-
actionPerformed
public final void actionPerformed(java.awt.event.ActionEvent actionEvent)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
-