Package org.jfree.chart.plot
Class CompassPlot
- java.lang.Object
-
- org.jfree.chart.plot.Plot
-
- org.jfree.chart.plot.CompassPlot
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.EventListener,AnnotationChangeListener,AxisChangeListener,MarkerChangeListener,LegendItemSource,PublicCloneable,DatasetChangeListener
public class CompassPlot extends Plot implements java.lang.Cloneable, java.io.Serializable
A specialised plot that draws a compass to indicate a direction based on the value from aValueDataset.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.geom.Areaa1A working area.private java.awt.geom.Areaa2A working area.private java.awt.geom.Ellipse2Dcircle1A working shape.private java.awt.geom.Ellipse2Dcircle2A working shape.private java.awt.FontcompassFontThe compass font.private ValueDataset[]datasetsAn array of value datasets.static java.awt.FontDEFAULT_LABEL_FONTThe default label font.private booleandrawBorderA flag that controls whether or not a border is drawn.private java.awt.FontlabelFontThe label font.private intlabelTypeThe label type (NO_LABELS, VALUE_LABELS).protected static java.util.ResourceBundlelocalizationResourcesThe resourceBundle for the localization.static intNO_LABELSA constant for the label type.private java.awt.geom.Rectangle2Drect1A working shape.protected doublerevolutionDistanceThe count to complete one revolution.private java.awt.PaintroseCenterPaintThe rose center paint.private java.awt.PaintroseHighlightPaintThe rose highlight paint.private java.awt.PaintrosePaintThe rose paint.private static longserialVersionUIDFor serialization.private MeterNeedle[]seriesNeedleAn array of needles.static intVALUE_LABELSA constant for the label type.-
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
Constructors Constructor Description CompassPlot()Default constructor.CompassPlot(ValueDataset dataset)Constructs a new compass plot.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataset(ValueDataset dataset)Adds a dataset to the compass.voidaddDataset(ValueDataset dataset, MeterNeedle needle)Adds a dataset to the compass.java.lang.Objectclone()Returns a clone of the plot.voiddraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, PlotState parentState, PlotRenderingInfo info)Draws the plot on a Java 2D graphics device (such as the screen or a printer).booleanequals(java.lang.Object obj)Tests an object for equality with this plot.protected java.awt.FontgetCompassFont(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.booleangetDrawBorder()Returns a flag that controls whether or not a border is drawn.java.awt.FontgetLabelFont()Returns the label font.intgetLabelType()Returns the label type.LegendItemCollectiongetLegendItems()Returns the legend items for the plot.java.lang.StringgetPlotType()Returns a short string describing the type of plot.doublegetRevolutionDistance()Gets the count to complete one revolution.java.awt.PaintgetRoseCenterPaint()Returns the paint used to fill the inner background area of the compass.java.awt.PaintgetRoseHighlightPaint()Returns the paint used to draw the circles, symbols and labels on the compass.java.awt.PaintgetRosePaint()Returns the paint used to fill the outer circle of the compass.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetDrawBorder(boolean status)Sets a flag that controls whether or not a border is drawn.voidsetLabelFont(java.awt.Font font)Sets the label font and sends aPlotChangeEventto all registered listeners.voidsetLabelType(int type)Sets the label type (eitherNO_LABELSorVALUE_LABELS.voidsetRevolutionDistance(double size)Sets the count to complete one revolution.voidsetRoseCenterPaint(java.awt.Paint paint)Sets the paint used to fill the inner background area of the compass, and sends aPlotChangeEventto all registered listeners.voidsetRoseHighlightPaint(java.awt.Paint paint)Sets the paint used to draw the circles, symbols and labels of the compass, and sends aPlotChangeEventto all registered listeners.voidsetRosePaint(java.awt.Paint paint)Sets the paint used to fill the outer circle of the compass, and sends aPlotChangeEventto all registered listeners.voidsetSeriesNeedle(int type)Sets the needle type.voidsetSeriesNeedle(int index, int type)Sets the needle for a series.voidsetSeriesNeedle(int index, MeterNeedle needle)Sets the needle for a series and sends aPlotChangeEventto all registered listeners.voidsetSeriesOutlinePaint(int series, java.awt.Paint p)Sets the series outline paint.voidsetSeriesOutlineStroke(int series, java.awt.Stroke stroke)Sets the series outline stroke.voidsetSeriesPaint(int series, java.awt.Paint paint)Sets the series paint.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.voidzoom(double percent)No zooming is implemented for compass plot, so this method is empty.-
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, annotationChanged, axisChanged, canEqual, createAndAddEntity, datasetChanged, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fetchElementHintingFlag, fillBackground, fillBackground, fireChangeEvent, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getChart, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, hashCode, isNotify, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setChart, setDatasetGroup, setDrawingSupplier, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setNotify, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
DEFAULT_LABEL_FONT
public static final java.awt.Font DEFAULT_LABEL_FONT
The default label font.
-
NO_LABELS
public static final int NO_LABELS
A constant for the label type.- See Also:
- Constant Field Values
-
VALUE_LABELS
public static final int VALUE_LABELS
A constant for the label type.- See Also:
- Constant Field Values
-
labelType
private int labelType
The label type (NO_LABELS, VALUE_LABELS).
-
labelFont
private java.awt.Font labelFont
The label font.
-
drawBorder
private boolean drawBorder
A flag that controls whether or not a border is drawn.
-
roseHighlightPaint
private transient java.awt.Paint roseHighlightPaint
The rose highlight paint.
-
rosePaint
private transient java.awt.Paint rosePaint
The rose paint.
-
roseCenterPaint
private transient java.awt.Paint roseCenterPaint
The rose center paint.
-
compassFont
private java.awt.Font compassFont
The compass font.
-
circle1
private transient java.awt.geom.Ellipse2D circle1
A working shape.
-
circle2
private transient java.awt.geom.Ellipse2D circle2
A working shape.
-
a1
private transient java.awt.geom.Area a1
A working area.
-
a2
private transient java.awt.geom.Area a2
A working area.
-
rect1
private transient java.awt.geom.Rectangle2D rect1
A working shape.
-
datasets
private ValueDataset[] datasets
An array of value datasets.
-
seriesNeedle
private MeterNeedle[] seriesNeedle
An array of needles.
-
localizationResources
protected static java.util.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 Detail
-
CompassPlot
public CompassPlot()
Default constructor.
-
CompassPlot
public CompassPlot(ValueDataset dataset)
Constructs a new compass plot.- Parameters:
dataset- the dataset for the plot (nullpermitted).
-
-
Method Detail
-
getLabelType
public int getLabelType()
Returns the label type. Defined by the constants:NO_LABELSandVALUE_LABELS.- Returns:
- The label type.
- See Also:
setLabelType(int)
-
setLabelType
public void setLabelType(int type)
Sets the label type (eitherNO_LABELSorVALUE_LABELS.- Parameters:
type- the type.- See Also:
getLabelType()
-
getLabelFont
public java.awt.Font getLabelFont()
Returns the label font.- Returns:
- The label font.
- See Also:
setLabelFont(Font)
-
setLabelFont
public void setLabelFont(java.awt.Font font)
Sets the label font and sends aPlotChangeEventto all registered listeners.- Parameters:
font- the new label font.- See Also:
getLabelFont()
-
getRosePaint
public java.awt.Paint getRosePaint()
Returns the paint used to fill the outer circle of the compass.- Returns:
- The paint (never
null). - See Also:
setRosePaint(Paint)
-
setRosePaint
public void setRosePaint(java.awt.Paint paint)
Sets the paint used to fill the outer circle of the compass, and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getRosePaint()
-
getRoseCenterPaint
public java.awt.Paint getRoseCenterPaint()
Returns the paint used to fill the inner background area of the compass.- Returns:
- The paint (never
null). - See Also:
setRoseCenterPaint(Paint)
-
setRoseCenterPaint
public void setRoseCenterPaint(java.awt.Paint paint)
Sets the paint used to fill the inner background area of the compass, and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getRoseCenterPaint()
-
getRoseHighlightPaint
public java.awt.Paint getRoseHighlightPaint()
Returns the paint used to draw the circles, symbols and labels on the compass.- Returns:
- The paint (never
null). - See Also:
setRoseHighlightPaint(Paint)
-
setRoseHighlightPaint
public void setRoseHighlightPaint(java.awt.Paint paint)
Sets the paint used to draw the circles, symbols and labels of the compass, and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getRoseHighlightPaint()
-
getDrawBorder
public boolean getDrawBorder()
Returns a flag that controls whether or not a border is drawn.- Returns:
- The flag.
- See Also:
setDrawBorder(boolean)
-
setDrawBorder
public void setDrawBorder(boolean status)
Sets a flag that controls whether or not a border is drawn.- Parameters:
status- the flag status.- See Also:
getDrawBorder()
-
setSeriesPaint
public void setSeriesPaint(int series, java.awt.Paint paint)Sets the series paint.- Parameters:
series- the series index.paint- the paint.- See Also:
setSeriesOutlinePaint(int, Paint)
-
setSeriesOutlinePaint
public void setSeriesOutlinePaint(int series, java.awt.Paint p)Sets the series outline paint.- Parameters:
series- the series index.p- the paint.- See Also:
setSeriesPaint(int, Paint)
-
setSeriesOutlineStroke
public void setSeriesOutlineStroke(int series, java.awt.Stroke stroke)Sets the series outline stroke.- Parameters:
series- the series index.stroke- the stroke.- See Also:
setSeriesOutlinePaint(int, Paint)
-
setSeriesNeedle
public void setSeriesNeedle(int type)
Sets the needle type.- Parameters:
type- the type.- See Also:
setSeriesNeedle(int, int)
-
setSeriesNeedle
public void setSeriesNeedle(int index, int type)Sets the needle for a series. The needle type is one of the following:- 0 =
ArrowNeedle; - 1 =
LineNeedle; - 2 =
LongNeedle; - 3 =
PinNeedle; - 4 =
PlumNeedle; - 5 =
PointerNeedle; - 6 =
ShipNeedle; - 7 =
WindNeedle; - 8 =
ArrowNeedle; - 9 =
MiddlePinNeedle;
- Parameters:
index- the series index.type- the needle type.- See Also:
setSeriesNeedle(int)
- 0 =
-
setSeriesNeedle
public void setSeriesNeedle(int index, MeterNeedle needle)Sets the needle for a series and sends aPlotChangeEventto all registered listeners.- Parameters:
index- the series index.needle- the needle.
-
getDatasets
public ValueDataset[] getDatasets()
Returns an array of dataset references for the plot.- Returns:
- The dataset for the plot, cast as a ValueDataset.
- See Also:
addDataset(ValueDataset)
-
addDataset
public void addDataset(ValueDataset dataset)
Adds a dataset to the compass.- Parameters:
dataset- the new dataset (nullignored).- See Also:
addDataset(ValueDataset, MeterNeedle)
-
addDataset
public void addDataset(ValueDataset dataset, MeterNeedle needle)
Adds a dataset to the compass.- Parameters:
dataset- the new dataset (nullignored).needle- the needle (nullpermitted).
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, PlotState parentState, PlotRenderingInfo info)Draws the plot on a Java 2D graphics device (such as the screen or a printer).
-
getPlotType
public java.lang.String getPlotType()
Returns a short string describing the type of plot.- Specified by:
getPlotTypein classPlot- Returns:
- A string describing the plot.
-
getLegendItems
public LegendItemCollection getLegendItems()
Returns the legend items for the plot. For now, no legend is available - this method returns null.- Specified by:
getLegendItemsin interfaceLegendItemSource- Overrides:
getLegendItemsin classPlot- Returns:
- The legend items.
-
zoom
public void zoom(double percent)
No zooming is implemented for compass plot, so this method is empty.
-
getCompassFont
protected java.awt.Font getCompassFont(int radius)
Returns the font for the compass, adjusted for the size of the plot.- Parameters:
radius- the radius.- Returns:
- The font.
-
equals
public boolean equals(java.lang.Object obj)
Tests an object for equality with this plot.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the plot.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classPlot- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- this class will not throw this exception, but subclasses (if any) might.
-
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.- See Also:
getRevolutionDistance()
-
getRevolutionDistance
public double getRevolutionDistance()
Gets the count to complete one revolution.- Returns:
- The count to complete one revolution.
- See Also:
setRevolutionDistance(double)
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides serialization support.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionProvides serialization support.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O error.java.lang.ClassNotFoundException- if there is a classpath problem.
-
-