public abstract class AbstractPlot extends Object implements Identifiable, Dataset
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.
| Modifier and Type | Field and Description |
|---|---|
static Time |
DEFAULT_INITIAL_UPPER_TIME_BOUND
Initial upper bound for the time scale.
|
static nl.tudelft.simulation.event.EventType |
GRAPH_ADD_EVENT
The (regular, not timed) event type for pub/sub indicating the addition of a graph.
|
static nl.tudelft.simulation.event.EventType |
GRAPH_REMOVE_EVENT
The (regular, not timed) event type for pub/sub indicating the removal of a graph.
|
| Constructor and Description |
|---|
AbstractPlot(OTSSimulatorInterface simulator,
String caption,
Duration updateInterval,
Duration delay)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(DatasetChangeListener listener) |
byte[] |
encodeAsPng(int width,
int height,
double fontSize)
Returns the chart as a byte array representing a png image.
|
String |
getCaption()
Retrieve the caption.
|
JFreeChart |
getChart()
Returns the chart.
|
abstract GraphType |
getGraphType()
Return the graph type for transceiver.
|
DatasetGroup |
getGroup() |
String |
getId() |
OTSSimulatorInterface |
getSimulator()
Retrieve the simulator.
|
abstract String |
getStatusLabel(double domainValue,
double rangeValue)
Returns the status label when the mouse is over the given location.
|
Time |
getUpdateTime()
Returns time until which data should be plotted.
|
protected abstract void |
increaseTime(Time time)
Increase the simulated time span.
|
void |
notifyPlotChange()
Notify all change listeners.
|
void |
removeChangeListener(DatasetChangeListener listener) |
void |
setAutoBoundDomain(XYPlot plot)
Overridable; activates auto bounds on domain axis from user input.
|
void |
setAutoBoundRange(XYPlot plot)
Overridable; activates auto bounds on range axis from user input.
|
protected void |
setChart(JFreeChart chart)
Sets the chart and adds menus and listeners.
|
void |
setGroup(DatasetGroup group) |
void |
setUpdateInterval(Duration interval)
Sets a new update interval.
|
protected void |
update()
Redraws the plot and schedules the next update.
|
public static final nl.tudelft.simulation.event.EventType GRAPH_ADD_EVENT
public static final nl.tudelft.simulation.event.EventType GRAPH_REMOVE_EVENT
public static final Time DEFAULT_INITIAL_UPPER_TIME_BOUND
public AbstractPlot(OTSSimulatorInterface simulator, String caption, Duration updateInterval, Duration delay)
simulator - OTSSimulatorInterface; simulatorcaption - String; captionupdateInterval - Duration; regular update interval (simulation time)delay - Duration; amount of time that chart runs behind simulation to prevent gaps in the charted dataprotected void setChart(JFreeChart chart)
chart - JFreeChart; chartpublic byte[] encodeAsPng(int width,
int height,
double fontSize)
throws IOException
width - int; widthheight - int; heightfontSize - double; font size (16 is the original on screen size)IOException - on IO exceptionpublic final DatasetGroup getGroup()
public final void setGroup(DatasetGroup group)
public void setAutoBoundDomain(XYPlot plot)
XYPlots,
but the auto bounds command comes from the ChartPanel that this class creates. In case the used plot is a
XYPlot, this method is then invoked. Sub classes with auto domain bounds that work with an XYPlot should
implement this. The method is not abstract as the use of XYPlot is not obligated.plot - XYPlot; plotpublic void setAutoBoundRange(XYPlot plot)
XYPlots,
but the auto bounds command comes from the ChartPanel that this class creates. In case the used plot is a
XYPlot, this method is then invoked. Sub classes with auto range bounds that work with an XYPlot should
implement this. The method is not abstract as the use of XYPlot is not obligated.plot - XYPlot; plotpublic abstract GraphType getGraphType()
public abstract String getStatusLabel(double domainValue, double rangeValue)
domainValue - double; domain value (x-axis)rangeValue - double; range value (y-axis)protected abstract void increaseTime(Time time)
time - Time; time to increase topublic final void notifyPlotChange()
public final JFreeChart getChart()
public final String getId()
getId in interface Identifiablepublic final void addChangeListener(DatasetChangeListener listener)
addChangeListener in interface Datasetpublic final void removeChangeListener(DatasetChangeListener listener)
removeChangeListener in interface Datasetpublic OTSSimulatorInterface getSimulator()
public final void setUpdateInterval(Duration interval)
interval - Duration; update intervalpublic final Time getUpdateTime()
protected void update()
public String getCaption()
Copyright © 2014–2019 Delft University of Technology. All rights reserved.