Class CustomCompassPlot
- java.lang.Object
- 
- org.jfree.chart.plot.Plot
- 
- com.inductiveautomation.factorypmi.application.components.chart.CustomCompassPlot
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- java.util.EventListener,- org.jfree.chart.event.AxisChangeListener,- org.jfree.chart.event.MarkerChangeListener,- org.jfree.chart.LegendItemSource,- org.jfree.data.general.DatasetChangeListener,- org.jfree.util.PublicCloneable
 
 public class CustomCompassPlot extends org.jfree.chart.plot.Plot implements java.lang.Cloneable, java.io.SerializableA specialised plot that draws a compass to indicate a direction based on the value from aValueDataset.Unfortunately, I had to cut-and-paste this class so that I could customize the drawing and fix the font bug (the orig doesn't have a customizable font) - See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.awt.FontDEFAULT_LABEL_FONTThe default label font.protected java.lang.Stringeastprotected static java.util.ResourceBundlelocalizationResourcesThe resourceBundle for the localization.static intNO_LABELSA constant for the label type.protected java.lang.StringnorthNames of the directionsprotected doublerevolutionDistanceThe count to complete one revolution.protected java.lang.Stringsouthstatic intVALUE_LABELSA constant for the label type.protected java.lang.Stringwest
 - 
Constructor SummaryConstructors Constructor Description CustomCompassPlot()Default constructor.CustomCompassPlot(org.jfree.data.general.ValueDataset dataset)Constructs a new compass plot.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataset(org.jfree.data.general.ValueDataset dataset)Adds a dataset to the compass.voidaddDataset(org.jfree.data.general.ValueDataset dataset, org.jfree.chart.needle.MeterNeedle needle)Adds a dataset to the compass.java.lang.Objectclone()Returns a clone of the annotation.voiddraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, org.jfree.chart.plot.PlotState parentState, org.jfree.chart.plot.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.org.jfree.data.general.ValueDataset[]getDatasets()Returns the dataset.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.org.jfree.chart.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.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, org.jfree.chart.needle.MeterNeedle needle)Sets the needle for a series.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.voidupdateCardinalStrings(java.lang.String north, java.lang.String south, java.lang.String east, java.lang.String west)Updates the strings for the compass directions.voidzoom(double percent)No zooming is implemented for compass plot, so this method is empty.- 
Methods inherited from class org.jfree.chart.plot.PlotaddChangeListener, axisChanged, datasetChanged, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fillBackground, fillBackground, fireChangeEvent, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setDatasetGroup, setDrawingSupplier, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent
 
- 
 
- 
- 
- 
Field Detail- 
DEFAULT_LABEL_FONTpublic static final java.awt.Font DEFAULT_LABEL_FONT The default label font.
 - 
NO_LABELSpublic static final int NO_LABELS A constant for the label type.- See Also:
- Constant Field Values
 
 - 
VALUE_LABELSpublic static final int VALUE_LABELS A constant for the label type.- See Also:
- Constant Field Values
 
 - 
localizationResourcesprotected static java.util.ResourceBundle localizationResources The resourceBundle for the localization.
 - 
revolutionDistanceprotected 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
 - 
northprotected java.lang.String north Names of the directions
 - 
southprotected java.lang.String south 
 - 
eastprotected java.lang.String east 
 - 
westprotected java.lang.String west 
 
- 
 - 
Method Detail- 
getLabelTypepublic int getLabelType() Returns the label type. Defined by the constants:NO_LABELSandVALUE_LABELS.- Returns:
- The label type.
 
 - 
setLabelTypepublic void setLabelType(int type) Sets the label type (eitherNO_LABELSorVALUE_LABELS.- Parameters:
- type- the type.
 
 - 
getLabelFontpublic java.awt.Font getLabelFont() Returns the label font.- Returns:
- The label font.
 
 - 
setLabelFontpublic void setLabelFont(java.awt.Font font) Sets the label font and sends aPlotChangeEventto all registered listeners.- Parameters:
- font- the new label font.
 
 - 
getRosePaintpublic java.awt.Paint getRosePaint() Returns the paint used to fill the outer circle of the compass.- Returns:
- The paint (never null).
 
 - 
setRosePaintpublic 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).
 
 - 
getRoseCenterPaintpublic java.awt.Paint getRoseCenterPaint() Returns the paint used to fill the inner background area of the compass.- Returns:
- The paint (never null).
 
 - 
setRoseCenterPaintpublic 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).
 
 - 
getRoseHighlightPaintpublic java.awt.Paint getRoseHighlightPaint() Returns the paint used to draw the circles, symbols and labels on the compass.- Returns:
- The paint (never null).
 
 - 
setRoseHighlightPaintpublic 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).
 
 - 
getDrawBorderpublic boolean getDrawBorder() Returns a flag that controls whether or not a border is drawn.- Returns:
- The flag.
 
 - 
setDrawBorderpublic void setDrawBorder(boolean status) Sets a flag that controls whether or not a border is drawn.- Parameters:
- status- the flag status.
 
 - 
setSeriesPaintpublic void setSeriesPaint(int series, java.awt.Paint paint)Sets the series paint.- Parameters:
- series- the series index.
- paint- the paint.
 
 - 
setSeriesOutlinePaintpublic void setSeriesOutlinePaint(int series, java.awt.Paint p)Sets the series outline paint.- Parameters:
- series- the series index.
- p- the paint.
 
 - 
setSeriesOutlineStrokepublic void setSeriesOutlineStroke(int series, java.awt.Stroke stroke)Sets the series outline stroke.- Parameters:
- series- the series index.
- stroke- the stroke.
 
 - 
setSeriesNeedlepublic void setSeriesNeedle(int type) Sets the needle type.- Parameters:
- type- the type.
 
 - 
setSeriesNeedlepublic 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.
 
- 0 = 
 - 
setSeriesNeedlepublic void setSeriesNeedle(int index, org.jfree.chart.needle.MeterNeedle needle)Sets the needle for a series.- Parameters:
- index- the series index.
- needle- the needle.
 
 - 
getDatasetspublic org.jfree.data.general.ValueDataset[] getDatasets() Returns the dataset.Provided for convenience. - Returns:
- The dataset for the plot, cast as a ValueDataset.
 
 - 
addDatasetpublic void addDataset(org.jfree.data.general.ValueDataset dataset) Adds a dataset to the compass.- Parameters:
- dataset- the new dataset.
 
 - 
addDatasetpublic void addDataset(org.jfree.data.general.ValueDataset dataset, org.jfree.chart.needle.MeterNeedle needle)Adds a dataset to the compass.- Parameters:
- dataset- the new dataset.
- needle- the needle.
 
 - 
drawpublic void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, org.jfree.chart.plot.PlotState parentState, org.jfree.chart.plot.PlotRenderingInfo info)Draws the plot on a Java 2D graphics device (such as the screen or a printer).- Specified by:
- drawin class- org.jfree.chart.plot.Plot
- Parameters:
- g2- the graphics device.
- area- the area within which the plot should be drawn.
- anchor- the anchor point (- nullpermitted).
- parentState- the state from the parent plot, if there is one.
- info- collects info about the drawing.
 
 - 
getPlotTypepublic java.lang.String getPlotType() Returns a short string describing the type of plot.- Specified by:
- getPlotTypein class- org.jfree.chart.plot.Plot
- Returns:
- A string describing the plot.
 
 - 
getLegendItemspublic org.jfree.chart.LegendItemCollection getLegendItems() Returns the legend items for the plot. For now, no legend is available - this method returns null.- Specified by:
- getLegendItemsin interface- org.jfree.chart.LegendItemSource
- Overrides:
- getLegendItemsin class- org.jfree.chart.plot.Plot
- Returns:
- The legend items.
 
 - 
zoompublic void zoom(double percent) No zooming is implemented for compass plot, so this method is empty.- Overrides:
- zoomin class- org.jfree.chart.plot.Plot
- Parameters:
- percent- the zoom amount.
 
 - 
getCompassFontprotected 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.
 
 - 
equalspublic boolean equals(java.lang.Object obj) Tests an object for equality with this plot.- Overrides:
- equalsin class- org.jfree.chart.plot.Plot
- Parameters:
- obj- the object (- nullpermitted).
 
 - 
clonepublic java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the annotation.- Specified by:
- clonein interface- org.jfree.util.PublicCloneable
- Overrides:
- clonein class- org.jfree.chart.plot.Plot
- Returns:
- A clone.
- Throws:
- java.lang.CloneNotSupportedException- this class will not throw this exception, but subclasses (if any) might.
 
 - 
setRevolutionDistancepublic void setRevolutionDistance(double size) Sets the count to complete one revolution. Can be arbitaly set For degrees (the default) it is 360, for radians this is 2*Pi, etc- Parameters:
- size- the count to complete one revolution.
 
 - 
getRevolutionDistancepublic double getRevolutionDistance() Gets the count to complete one revolution.- Returns:
- The count to complete one revolution
 
 - 
updateCardinalStringspublic void updateCardinalStrings(java.lang.String north, java.lang.String south, java.lang.String east, java.lang.String west)Updates the strings for the compass directions. It's up to the caller to make sure it's not something stupidly long
 
- 
 
-