org.jfree.chart.plot.dial

Class DialPlot

Implemented Interfaces:
AxisChangeListener, Cloneable, DatasetChangeListener, DialLayerChangeListener, EventListener, LegendItemSource, MarkerChangeListener, PublicCloneable, Serializable

public class DialPlot
extends Plot
implements DialLayerChangeListener

A dial plot.

Field Summary

Fields inherited from class org.jfree.chart.plot.Plot

DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_LEGEND_ITEM_BOX, DEFAULT_LEGEND_ITEM_CIRCLE, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO

Constructor Summary

DialPlot()
Creates a new instance of DialPlot.
DialPlot(ValueDataset dataset)
Creates a new instance of DialPlot.

Method Summary

void
addLayer(DialLayer layer)
Adds a layer to the plot and sends a PlotChangeEvent to all registered listeners.
void
addPointer(DialPointer pointer)
Adds a pointer to the plot and sends a PlotChangeEvent to all registered listeners.
void
addScale(int index, DialScale scale)
Adds a dial scale to the plot and sends a PlotChangeEvent to all registered listeners.
void
dialLayerChanged(DialLayerChangeEvent event)
Receives notification when a layer has changed, and responds by forwarding a PlotChangeEvent to all registered listeners.
void
draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot.
boolean
equals(Object obj)
Tests this DialPlot instance for equality with an arbitrary object.
DialLayer
getBackground()
Returns the background.
DialLayer
getCap()
Returns the cap.
ValueDataset
getDataset()
Returns the primary dataset for the plot.
ValueDataset
getDataset(int index)
Returns the dataset at the given index.
int
getDatasetCount()
Returns the number of datasets.
DialFrame
getDialFrame()
Returns the dial's frame.
int
getLayerIndex(DialLayer layer)
Returns the index for the specified layer.
String
getPlotType()
Returns the plot type.
DialPointer
getPointerForDataset(int datasetIndex)
Returns the dial pointer that is associated with the specified dataset, or null.
int
getPointerIndex(DialPointer pointer)
Returns the index for the specified pointer.
DialScale
getScale(int index)
Returns the scale at the given index.
DialScale
getScaleForDataset(int datasetIndex)
Returns the dial scale for a specific dataset.
double
getValue(int datasetIndex)
Returns the value from the specified dataset.
double
getViewHeight()
Returns the height of the viewing rectangle.
double
getViewWidth()
Returns the width of the viewing rectangle.
double
getViewX()
Returns the x-coordinate of the viewing rectangle.
double
getViewY()
Returns the y-coordinate of the viewing rectangle.
int
hashCode()
Returns a hash code for this instance.
void
mapDatasetToScale(int index, int scaleIndex)
Maps a dataset to a particular scale.
static Rectangle2D
rectangleByRadius(Rectangle2D rect, double radiusW, double radiusH)
A utility method that computes a rectangle using relative radius values.
void
removeLayer(int index)
Removes the layer at the specified index and sends a PlotChangeEvent to all registered listeners.
void
removeLayer(DialLayer layer)
Removes the specified layer and sends a PlotChangeEvent to all registered listeners.
void
removePointer(int index)
Removes the pointer at the specified index and sends a PlotChangeEvent to all registered listeners.
void
removePointer(DialPointer pointer)
Removes the specified pointer and sends a PlotChangeEvent to all registered listeners.
void
setBackground(DialLayer background)
Sets the background layer and sends a PlotChangeEvent to all registered listeners.
void
setCap(DialLayer cap)
Sets the cap and sends a PlotChangeEvent to all registered listeners.
void
setDataset(int index, ValueDataset dataset)
Sets a dataset for the plot.
void
setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset, if there is one, and sends a PlotChangeEvent to all registered listeners.
void
setDialFrame(DialFrame frame)
Sets the dial's frame and sends a PlotChangeEvent to all registered listeners.
void
setView(double x, double y, double w, double h)
Sets the viewing rectangle, relative to the dial's framing rectangle, and sends a PlotChangeEvent to all registered listeners.

Methods inherited from class org.jfree.chart.plot.Plot

addChangeListener, axisChanged, clone, datasetChanged, draw, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, equals, fillBackground, fillBackground, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getLegendItems, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getPlotType, getRectX, getRectY, getRootPlot, handleClick, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setDatasetGroup, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent, zoom

Constructor Details

DialPlot

public DialPlot()
Creates a new instance of DialPlot.

DialPlot

public DialPlot(ValueDataset dataset)
Creates a new instance of DialPlot.
Parameters:
dataset - the dataset (null permitted).

Method Details

addLayer

public void addLayer(DialLayer layer)
Adds a layer to the plot and sends a PlotChangeEvent to all registered listeners.
Parameters:
layer - the layer (null not permitted).

addPointer

public void addPointer(DialPointer pointer)
Adds a pointer to the plot and sends a PlotChangeEvent to all registered listeners.
Parameters:
pointer - the pointer (null not permitted).

addScale

public void addScale(int index,
                     DialScale scale)
Adds a dial scale to the plot and sends a PlotChangeEvent to all registered listeners.
Parameters:
index - the scale index.
scale - the scale (null not permitted).

dialLayerChanged

public void dialLayerChanged(DialLayerChangeEvent event)
Receives notification when a layer has changed, and responds by forwarding a PlotChangeEvent to all registered listeners.
Specified by:
dialLayerChanged in interface DialLayerChangeListener
Parameters:
event - the event.

draw

public void draw(Graphics2D g2,
                 Rectangle2D area,
                 Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info)
Draws the plot. This method is usually called by the JFreeChart instance that manages the plot.
Overrides:
draw in interface Plot
Parameters:
g2 - the graphics target.
area - the area in which the plot should be drawn.
anchor - the anchor point (typically the last point that the mouse clicked on, null is permitted).
parentState - the state for the parent plot (if any).
info - used to collect plot rendering info (null permitted).

equals

public boolean equals(Object obj)
Tests this DialPlot instance for equality with an arbitrary object. The plot's dataset(s) is (are) not included in the test.
Overrides:
equals in interface Plot
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

getBackground

public DialLayer getBackground()
Returns the background.
Returns:
The background (possibly null).

getCap

public DialLayer getCap()
Returns the cap.
Returns:
The cap (possibly null).

getDataset

public ValueDataset getDataset()
Returns the primary dataset for the plot.
Returns:
The primary dataset (possibly null).

getDataset

public ValueDataset getDataset(int index)
Returns the dataset at the given index.
Parameters:
index - the dataset index.
Returns:
The dataset (possibly null).

getDatasetCount

public int getDatasetCount()
Returns the number of datasets.
Returns:
The number of datasets.

getDialFrame

public DialFrame getDialFrame()
Returns the dial's frame.
Returns:
The dial's frame (never null).

getLayerIndex

public int getLayerIndex(DialLayer layer)
Returns the index for the specified layer.
Parameters:
layer - the layer (null not permitted).
Returns:
The layer index.

getPlotType

public String getPlotType()
Returns the plot type.
Overrides:
getPlotType in interface Plot
Returns:
"DialPlot"

getPointerForDataset

public DialPointer getPointerForDataset(int datasetIndex)
Returns the dial pointer that is associated with the specified dataset, or null.
Parameters:
datasetIndex - the dataset index.
Returns:
The pointer.

getPointerIndex

public int getPointerIndex(DialPointer pointer)
Returns the index for the specified pointer.
Parameters:
pointer - the pointer (null not permitted).
Returns:
The pointer index.

getScale

public DialScale getScale(int index)
Returns the scale at the given index.
Parameters:
index - the scale index.
Returns:
The scale (possibly null).

getScaleForDataset

public DialScale getScaleForDataset(int datasetIndex)
Returns the dial scale for a specific dataset.
Parameters:
datasetIndex - the dataset index.
Returns:
The dial scale.

getValue

public double getValue(int datasetIndex)
Returns the value from the specified dataset.
Parameters:
datasetIndex - the dataset index.
Returns:
The data value.

getViewHeight

public double getViewHeight()
Returns the height of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
Returns:
The height of the viewing rectangle.

getViewWidth

public double getViewWidth()
Returns the width of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
Returns:
The width of the viewing rectangle.

getViewX

public double getViewX()
Returns the x-coordinate of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
Returns:
The x-coordinate of the viewing rectangle.

getViewY

public double getViewY()
Returns the y-coordinate of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
Returns:
The y-coordinate of the viewing rectangle.

hashCode

public int hashCode()
Returns a hash code for this instance.
Returns:
The hash code.

mapDatasetToScale

public void mapDatasetToScale(int index,
                              int scaleIndex)
Maps a dataset to a particular scale.
Parameters:
index - the dataset index (zero-based).
scaleIndex - the scale index (zero-based).

rectangleByRadius

public static Rectangle2D rectangleByRadius(Rectangle2D rect,
                                            double radiusW,
                                            double radiusH)
A utility method that computes a rectangle using relative radius values.
Parameters:
rect - the reference rectangle (null not permitted).
radiusW - the width radius (must be > 0.0)
radiusH - the height radius.
Returns:
A new rectangle.

removeLayer

public void removeLayer(int index)
Removes the layer at the specified index and sends a PlotChangeEvent to all registered listeners.
Parameters:
index - the index.

removeLayer

public void removeLayer(DialLayer layer)
Removes the specified layer and sends a PlotChangeEvent to all registered listeners.
Parameters:
layer - the layer (null not permitted).

removePointer

public void removePointer(int index)
Removes the pointer at the specified index and sends a PlotChangeEvent to all registered listeners.
Parameters:
index - the index.

removePointer

public void removePointer(DialPointer pointer)
Removes the specified pointer and sends a PlotChangeEvent to all registered listeners.
Parameters:
pointer - the pointer (null not permitted).

setBackground

public void setBackground(DialLayer background)
Sets the background layer and sends a PlotChangeEvent to all registered listeners.
Parameters:
background - the background layer (null permitted).

setCap

public void setCap(DialLayer cap)
Sets the cap and sends a PlotChangeEvent to all registered listeners.
Parameters:
cap - the cap (null permitted).
See Also:
getCap()

setDataset

public void setDataset(int index,
                       ValueDataset dataset)
Sets a dataset for the plot.
Parameters:
index - the dataset index.
dataset - the dataset (null permitted).

setDataset

public void setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset, if there is one, and sends a PlotChangeEvent to all registered listeners.
Parameters:
dataset - the dataset (null permitted).

setDialFrame

public void setDialFrame(DialFrame frame)
Sets the dial's frame and sends a PlotChangeEvent to all registered listeners.
Parameters:
frame - the frame (null not permitted).

setView

public void setView(double x,
                    double y,
                    double w,
                    double h)
Sets the viewing rectangle, relative to the dial's framing rectangle, and sends a PlotChangeEvent to all registered listeners.
Parameters:
x - the x-coordinate (in the range 0.0 to 1.0).
y - the y-coordinate (in the range 0.0 to 1.0).
w - the width (in the range 0.0 to 1.0).
h - the height (in the range 0.0 to 1.0).