org.jfree.chart.plot

Class CompassPlot

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

public class CompassPlot
extends Plot
implements Cloneable, Serializable

A specialised plot that draws a compass to indicate a direction based on the value from a ValueDataset.

Field Summary

static Font
DEFAULT_LABEL_FONT
The default label font.
static int
NO_LABELS
A constant for the label type.
static int
VALUE_LABELS
A constant for the label type.
protected static ResourceBundle
localizationResources
The resourceBundle for the localization.
protected double
revolutionDistance
The count to complete one revolution.

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

CompassPlot()
Default constructor.
CompassPlot(ValueDataset dataset)
Constructs a new compass plot.

Method Summary

void
addDataset(ValueDataset dataset)
Adds a dataset to the compass.
void
addDataset(ValueDataset dataset, MeterNeedle needle)
Adds a dataset to the compass.
Object
clone()
Returns a clone of the plot.
void
draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).
boolean
equals(Object obj)
Tests an object for equality with this plot.
protected Font
getCompassFont(int radius)
Returns the font for the compass, adjusted for the size of the plot.
ValueDataset[]
getDatasets()
Returns an array of dataset references for the plot.
boolean
getDrawBorder()
Returns a flag that controls whether or not a border is drawn.
Font
getLabelFont()
Returns the label font.
int
getLabelType()
Returns the label type.
LegendItemCollection
getLegendItems()
Returns the legend items for the plot.
String
getPlotType()
Returns a short string describing the type of plot.
double
getRevolutionDistance()
Gets the count to complete one revolution.
Paint
getRoseCenterPaint()
Returns the paint used to fill the inner background area of the compass.
Paint
getRoseHighlightPaint()
Returns the paint used to draw the circles, symbols and labels on the compass.
Paint
getRosePaint()
Returns the paint used to fill the outer circle of the compass.
void
setDrawBorder(boolean status)
Sets a flag that controls whether or not a border is drawn.
void
setLabelFont(Font font)
Sets the label font and sends a PlotChangeEvent to all registered listeners.
void
setLabelType(int type)
Sets the label type (either NO_LABELS or VALUE_LABELS.
void
setRevolutionDistance(double size)
Sets the count to complete one revolution.
void
setRoseCenterPaint(Paint paint)
Sets the paint used to fill the inner background area of the compass, and sends a PlotChangeEvent to all registered listeners.
void
setRoseHighlightPaint(Paint paint)
Sets the paint used to draw the circles, symbols and labels of the compass, and sends a PlotChangeEvent to all registered listeners.
void
setRosePaint(Paint paint)
Sets the paint used to fill the outer circle of the compass, and sends a PlotChangeEvent to all registered listeners.
void
setSeriesNeedle(int type)
Sets the needle type.
void
setSeriesNeedle(int index, int type)
Sets the needle for a series.
void
setSeriesNeedle(int index, MeterNeedle needle)
Sets the needle for a series and sends a PlotChangeEvent to all registered listeners.
void
setSeriesOutlinePaint(int series, Paint p)
Sets the series outline paint.
void
setSeriesOutlineStroke(int series, Stroke stroke)
Sets the series outline stroke.
void
setSeriesPaint(int series, Paint paint)
Sets the series paint.
void
zoom(double percent)
No zooming is implemented for compass plot, so this method is empty.

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

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

Field Details

DEFAULT_LABEL_FONT

public static final Font DEFAULT_LABEL_FONT
The default label font.

NO_LABELS

public static final int NO_LABELS
A constant for the label type.
Field Value:
0

VALUE_LABELS

public static final int VALUE_LABELS
A constant for the label type.
Field Value:
1

localizationResources

protected static ResourceBundle localizationResources
The resourceBundle for the localization.

revolutionDistance

protected double revolutionDistance
The count to complete one revolution. Can be arbitrarily set For degrees (the default) it is 360, for radians this is 2*Pi, etc

Constructor Details

CompassPlot

public CompassPlot()
Default constructor.

CompassPlot

public CompassPlot(ValueDataset dataset)
Constructs a new compass plot.
Parameters:
dataset - the dataset for the plot (null permitted).

Method Details

addDataset

public void addDataset(ValueDataset dataset)
Adds a dataset to the compass.
Parameters:
dataset - the new dataset (null ignored).

addDataset

public void addDataset(ValueDataset dataset,
                       MeterNeedle needle)
Adds a dataset to the compass.
Parameters:
dataset - the new dataset (null ignored).
needle - the needle (null permitted).

clone

public Object clone()
            throws CloneNotSupportedException
Returns a clone of the plot.
Overrides:
clone in interface Plot
Returns:
A clone.

draw

public void draw(Graphics2D g2,
                 Rectangle2D area,
                 Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).
Overrides:
draw in interface Plot
Parameters:
g2 - the graphics device.
area - the area within which the plot should be drawn.
anchor - the anchor point (null permitted).
parentState - the state from the parent plot, if there is one.
info - collects info about the drawing.

equals

public boolean equals(Object obj)
Tests an object for equality with this plot.
Overrides:
equals in interface Plot
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

getCompassFont

protected Font getCompassFont(int radius)
Returns the font for the compass, adjusted for the size of the plot.
Parameters:
radius - the radius.
Returns:
The font.

getDatasets

public ValueDataset[] getDatasets()
Returns an array of dataset references for the plot.
Returns:
The dataset for the plot, cast as a ValueDataset.

getDrawBorder

public boolean getDrawBorder()
Returns a flag that controls whether or not a border is drawn.
Returns:
The flag.

getLabelFont

public Font getLabelFont()
Returns the label font.
Returns:
The label font.

getLabelType

public int getLabelType()
Returns the label type. Defined by the constants: NO_LABELS and VALUE_LABELS.
Returns:
The label type.

getLegendItems

public LegendItemCollection getLegendItems()
Returns the legend items for the plot. For now, no legend is available - this method returns null.
Specified by:
getLegendItems in interface LegendItemSource
Overrides:
getLegendItems in interface Plot
Returns:
The legend items.

getPlotType

public String getPlotType()
Returns a short string describing the type of plot.
Overrides:
getPlotType in interface Plot
Returns:
A string describing the plot.

getRevolutionDistance

public double getRevolutionDistance()
Gets the count to complete one revolution.
Returns:
The count to complete one revolution.

getRoseCenterPaint

public Paint getRoseCenterPaint()
Returns the paint used to fill the inner background area of the compass.
Returns:
The paint (never null).

getRoseHighlightPaint

public Paint getRoseHighlightPaint()
Returns the paint used to draw the circles, symbols and labels on the compass.
Returns:
The paint (never null).

getRosePaint

public Paint getRosePaint()
Returns the paint used to fill the outer circle of the compass.
Returns:
The paint (never null).

setDrawBorder

public void setDrawBorder(boolean status)
Sets a flag that controls whether or not a border is drawn.
Parameters:
status - the flag status.

setLabelFont

public void setLabelFont(Font font)
Sets the label font and sends a PlotChangeEvent to all registered listeners.
Parameters:
font - the new label font.

setLabelType

public void setLabelType(int type)
Sets the label type (either NO_LABELS or VALUE_LABELS.
Parameters:
type - the type.

setRevolutionDistance

public void setRevolutionDistance(double size)
Sets the count to complete one revolution. Can be arbitrarily set For degrees (the default) it is 360, for radians this is 2*Pi, etc
Parameters:
size - the count to complete one revolution.

setRoseCenterPaint

public void setRoseCenterPaint(Paint paint)
Sets the paint used to fill the inner background area of the compass, and sends a PlotChangeEvent to all registered listeners.
Parameters:
paint - the paint (null not permitted).

setRoseHighlightPaint

public void setRoseHighlightPaint(Paint paint)
Sets the paint used to draw the circles, symbols and labels of the compass, and sends a PlotChangeEvent to all registered listeners.
Parameters:
paint - the paint (null not permitted).

setRosePaint

public void setRosePaint(Paint paint)
Sets the paint used to fill the outer circle of the compass, and sends a PlotChangeEvent to all registered listeners.
Parameters:
paint - the paint (null not permitted).

setSeriesNeedle

public void setSeriesNeedle(int type)
Sets the needle type.
Parameters:
type - the type.

setSeriesNeedle

public void setSeriesNeedle(int index,
                            int type)
Sets the needle for a series. The needle type is one of the following:
Parameters:
index - the series index.
type - the needle type.

setSeriesNeedle

public void setSeriesNeedle(int index,
                            MeterNeedle needle)
Sets the needle for a series and sends a PlotChangeEvent to all registered listeners.
Parameters:
index - the series index.
needle - the needle.

setSeriesOutlinePaint

public void setSeriesOutlinePaint(int series,
                                  Paint p)
Sets the series outline paint.
Parameters:
series - the series index.
p - the paint.

setSeriesOutlineStroke

public void setSeriesOutlineStroke(int series,
                                   Stroke stroke)
Sets the series outline stroke.
Parameters:
series - the series index.
stroke - the stroke.

setSeriesPaint

public void setSeriesPaint(int series,
                           Paint paint)
Sets the series paint.
Parameters:
series - the series index.
paint - the paint.

zoom

public void zoom(double percent)
No zooming is implemented for compass plot, so this method is empty.
Overrides:
zoom in interface Plot
Parameters:
percent - the zoom amount.