Class AbstractContourPlot<Z extends Number>
java.lang.Object
org.opentrafficsim.animation.graphs.AbstractPlot<S>
org.opentrafficsim.animation.graphs.AbstractBoundedPlot<S>
org.opentrafficsim.animation.graphs.AbstractSpaceTimePlot<AbstractContourPlot.ContourPaintState>
org.opentrafficsim.animation.graphs.AbstractContourPlot<Z>
- Type Parameters:
Z- z-value type
- All Implemented Interfaces:
Identifiable,org.jfree.data.general.Dataset,org.jfree.data.general.SeriesDataset,org.jfree.data.xy.XYDataset,org.jfree.data.xy.XYZDataset
- Direct Known Subclasses:
ContourPlotAcceleration,ContourPlotDelay,ContourPlotDensity,ContourPlotExtendedData,ContourPlotFlow,ContourPlotSpeed
public abstract class AbstractContourPlot<Z extends Number>
extends AbstractSpaceTimePlot<AbstractContourPlot.ContourPaintState>
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 source.
Sub-classes only need to specify a few plot specific variables and functionalities.
Copyright (c) 2013-2026 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 TypeClassDescriptionstatic final recordAbstractContourPlot.Bounds<Z extends Number>Bounds for the color bounds scale.static final recordPaint state for contour plots.static final recordAbstractContourPlot.LabelData<Z extends Number>Input container for label input. -
Field Summary
Fields inherited from class org.opentrafficsim.animation.graphs.AbstractPlot
DEFAULT_INITIAL_UPPER_TIME_BOUND, GRAPH_ADD_EVENT, GRAPH_REMOVE_EVENT -
Constructor Summary
ConstructorsConstructorDescriptionAbstractContourPlot(String caption, ContourDataSource source, ContourDataSource.ContourAdditionalDataType<Z, ?> contourDataType, AbstractContourPlot.Bounds<Z> bounds, AbstractContourPlot.LabelData<Z> labelData) Constructor with default paint scale (red at minimum, yellow at mid-point, green at maximum).AbstractContourPlot(String caption, ContourDataSource source, ContourDataSource.ContourDataType<Z> contourDataType, BoundsPaintScale paintScale, AbstractContourPlot.LabelData<Z> labelData) Constructor with specified paint scale. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(EventListener listener, EventType eventType) Add listener to synchronize UI element when another UI element changes a setting, or the setting is changed programmatically.protected voidcalculatePaintState(org.djunits.value.vdouble.scalar.Duration time) Calculates the paint state object and offers it throughAbstractPlot.offerPaintState(S), or delegates this work to a delegate.protected AbstractContourPlot.ContourPaintStateReturns an empty paint state.protected ContourDataSource.ContourDataType<Z>Returns the contour data type for use in aContourDataSource.org.jfree.data.DomainOrderprotected org.djunits.value.vdouble.scalar.LengthReturns the total space.double[]getGranularities(ContourDataSource.Dimension dimension) Returns the available granularities that a linked plot may use.doublegetGranularity(ContourDataSource.Dimension dimension) Returns the selected granularity that a linked plot should use.intgetItemCount(int series) intintgetSeriesKey(int series) getStatusLabel(double domainValue, double rangeValue) Returns the status label when the mouse is over the given location.getX(int series, int item) doublegetXValue(int series, int item) getY(int series, int item) doublegetYValue(int series, int item) getZ(int series, int item) doublegetZValue(int series, int item) intindexOf(Comparable seriesKey) protected abstract doublescale(double si) Scale the z-value from SI to the desired unit for users, in line with unit inAbstractContourPlot.LabelData.labelFormat.voidsetGranularity(ContourDataSource.Dimension dimension, double granularity) Sets the granularity of the plot.voidsetInterpolate(boolean interpolate) Sets bi-linear interpolation enabled or disabled.protected voidSets the paint state in a thread safe manner and notifies the listeners.voidsetSmooth(boolean smooth) Sets the adaptive smoothing enabled or disabled.Methods inherited from class org.opentrafficsim.animation.graphs.AbstractSpaceTimePlot
setAutoBoundDomain, setAutoBoundRange, setChart, updateFixedDomainRangeMethods inherited from class org.opentrafficsim.animation.graphs.AbstractBoundedPlot
setLowerDomainBound, setLowerRangeBound, setUpperDomainBound, setUpperRangeBoundMethods inherited from class org.opentrafficsim.animation.graphs.AbstractPlot
addChangeListener, encodeAsPng, getAvailableTime, getCaption, getChart, getGraphType, getGroup, getId, getPaintState, invalidate, notifyPlotChange, offerPaintState, offerUpdateInterval, removeChangeListener, setGroup, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
AbstractContourPlot
public AbstractContourPlot(String caption, ContourDataSource source, ContourDataSource.ContourDataType<Z> contourDataType, BoundsPaintScale paintScale, AbstractContourPlot.LabelData<Z> labelData) Constructor with specified paint scale.- Parameters:
caption- captionsource- data sourcecontourDataType- contour data typepaintScale- paint scalelabelData- label data
-
AbstractContourPlot
public AbstractContourPlot(String caption, ContourDataSource source, ContourDataSource.ContourAdditionalDataType<Z, ?> contourDataType, AbstractContourPlot.Bounds<Z> bounds, AbstractContourPlot.LabelData<Z> labelData) Constructor with default paint scale (red at minimum, yellow at mid-point, green at maximum).- Parameters:
caption- captionsource- data sourcecontourDataType- contour data typebounds- paint scale boundslabelData- label data
-
-
Method Details
-
emptyPaintState
Description copied from class:AbstractPlotReturns an empty paint state. This is used at plot initialization.- Specified by:
emptyPaintStatein classAbstractPlot<AbstractContourPlot.ContourPaintState>- Returns:
- empty paint state.
-
getContourDataType
Returns the contour data type for use in aContourDataSource.- Returns:
- contour data type
-
scale
protected abstract double scale(double si) Scale the z-value from SI to the desired unit for users, in line with unit inAbstractContourPlot.LabelData.labelFormat.- Parameters:
si- SI value- Returns:
- scaled value
-
setPaintState
protected void setPaintState()Description copied from class:AbstractPlotSets the paint state in a thread safe manner and notifies the listeners. This method is always invoked on the Swing EDT. This method may be overridden to use a newly set paint state (after callingsuper.setPaintState()) to set internal properties. For example, setting the block size of an internal block renderer based on the granularity of the data.- Overrides:
setPaintStatein classAbstractSpaceTimePlot<AbstractContourPlot.ContourPaintState>
-
getStatusLabel
Returns the status label when the mouse is over the given location.- Specified by:
getStatusLabelin classAbstractPlot<AbstractContourPlot.ContourPaintState>- Parameters:
domainValue- domain value (x-axis)rangeValue- range value (y-axis)- Returns:
- status label when the mouse is over the given location
-
getItemCount
public int getItemCount(int series) - Specified by:
getItemCountin interfaceorg.jfree.data.xy.XYDataset
-
getX
- Specified by:
getXin interfaceorg.jfree.data.xy.XYDataset
-
getXValue
public double getXValue(int series, int item) - Specified by:
getXValuein interfaceorg.jfree.data.xy.XYDataset
-
getY
- Specified by:
getYin interfaceorg.jfree.data.xy.XYDataset
-
getYValue
public double getYValue(int series, int item) - Specified by:
getYValuein interfaceorg.jfree.data.xy.XYDataset
-
getZ
- Specified by:
getZin interfaceorg.jfree.data.xy.XYZDataset
-
getSeriesKey
- Specified by:
getSeriesKeyin interfaceorg.jfree.data.general.SeriesDataset
-
indexOf
- Specified by:
indexOfin interfaceorg.jfree.data.general.SeriesDataset
-
getDomainOrder
public org.jfree.data.DomainOrder getDomainOrder()- Specified by:
getDomainOrderin interfaceorg.jfree.data.xy.XYDataset
-
getZValue
public double getZValue(int series, int item) - Specified by:
getZValuein interfaceorg.jfree.data.xy.XYZDataset
-
getSeriesCount
public int getSeriesCount()- Specified by:
getSeriesCountin interfaceorg.jfree.data.general.SeriesDataset
-
getRangeBinCount
public int getRangeBinCount() -
addListener
Add listener to synchronize UI element when another UI element changes a setting, or the setting is changed programmatically.- Parameters:
listener- listenereventType- event type (i.e.ContourDataSource.GRANULARITY,ContourDataSource.INTERPOLATEorContourDataSource.SMOOTH)
-
getGranularities
Returns the available granularities that a linked plot may use.- Parameters:
dimension- space or time- Returns:
- available granularities that a linked plot may use
-
getGranularity
Returns the selected granularity that a linked plot should use.- Parameters:
dimension- space or time- Returns:
- granularity that a linked plot should use
-
setGranularity
Sets the granularity of the plot. This will invalidate the plot triggering a redraw.- Parameters:
dimension- space or timegranularity- granularity in space or time (SI unit)
-
setInterpolate
public void setInterpolate(boolean interpolate) Sets bi-linear interpolation enabled or disabled. This will invalidate the plot triggering a redraw.- Parameters:
interpolate- whether to enable interpolation
-
setSmooth
public void setSmooth(boolean smooth) Sets the adaptive smoothing enabled or disabled. This will invalidate the plot triggering a redraw.- Parameters:
smooth- whether to smooth the plot
-
calculatePaintState
protected void calculatePaintState(org.djunits.value.vdouble.scalar.Duration time) Description copied from class:AbstractPlotCalculates the paint state object and offers it throughAbstractPlot.offerPaintState(S), or delegates this work to a delegate. This method is invoked by the worker thread and can thus perform heavy calculations outside of the Swing EDT. Intermediate paint states during long calculations may also be offered. It is up to the implementation to either calculate a complete paint state, or cumulatively built on the results from previous calls. It is also up to the implementation to know when the whole time span needs to be recalculated due to property changes.- Specified by:
calculatePaintStatein classAbstractPlot<AbstractContourPlot.ContourPaintState>- Parameters:
time- time until which data in the paint state should be calculated
-
getEndLocation
protected org.djunits.value.vdouble.scalar.Length getEndLocation()Description copied from class:AbstractSpaceTimePlotReturns the total space.- Specified by:
getEndLocationin classAbstractSpaceTimePlot<AbstractContourPlot.ContourPaintState>- Returns:
- total space
-