org.jfree.chart.plot
Class PolarPlot

java.lang.Object
  extended byorg.jfree.chart.plot.Plot
      extended byorg.jfree.chart.plot.PolarPlot
All Implemented Interfaces:
AxisChangeListener, java.lang.Cloneable, DatasetChangeListener, java.util.EventListener, LegendItemSource, RendererChangeListener, java.io.Serializable, ValueAxisPlot

public class PolarPlot
extends Plot
implements ValueAxisPlot, RendererChangeListener, java.lang.Cloneable, java.io.Serializable

Plots data that is in (theta, radius) pairs where theta equal to zero is due north and and increases clockwise.

Author:
Daniel Bridenbecker, Solution Engineering, Inc.
See Also:
Serialized Form

Field Summary
static java.awt.Paint DEFAULT_GRIDLINE_PAINT
          The default grid line paint.
static java.awt.Stroke DEFAULT_GRIDLINE_STROKE
          The default grid line stroke.
protected static java.util.ResourceBundle localizationResources
          The resourceBundle for the localization.
 
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
PolarPlot()
          Default constructor.
PolarPlot(XYDataset dataset, ValueAxis radiusAxis, PolarItemRenderer renderer)
          Creates a new plot.
 
Method Summary
 void addCornerTextItem(java.lang.String text)
          Add text to be displayed in the lower right hand corner.
 void clearCornerTextItem()
          Clear the list of corner text items.
 java.lang.Object clone()
          Returns a clone of the plot.
 void datasetChanged(DatasetChangeEvent event)
          Receives notification of a change to the plot's m_Dataset.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info)
          Draws the plot on a Java 2D graphics device (such as the screen or a printer).
protected  AxisState drawAxis(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea)
          A utility method for drawing the axes.
 void drawCornerTextItems(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
          Draws the corner text items.
protected  void drawGridlines(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, java.util.List angularTicks, java.util.List radialTicks)
          Draws the gridlines for the plot, if they are visible.
 boolean equals(java.lang.Object obj)
          Tests this plot for equality with another object.
 java.awt.Paint getAngleGridlinePaint()
          Returns the paint for the grid lines (if any) plotted against the angular axis.
 java.awt.Stroke getAngleGridlineStroke()
          Returns the stroke for the grid-lines (if any) plotted against the angular axis.
 java.awt.Font getAngleLabelFont()
          Returns the font used to display the angle labels.
 java.awt.Paint getAngleLabelPaint()
          Returns the paint used to display the angle labels.
 ValueAxis getAxis()
          Returns the axis for the plot.
 Range getDataRange(ValueAxis axis)
          Returns the range for the specified axis.
 XYDataset getDataset()
          Returns the primary dataset for the plot.
 LegendItemCollection getLegendItems()
          Returns the legend items for the plot.
 double getMaxRadius()
          Returns the upper bound of the radius axis.
 java.lang.String getPlotType()
          Returns the plot type as a string.
 java.awt.Paint getRadiusGridlinePaint()
          Returns the paint for the grid lines (if any) plotted against the radius axis.
 java.awt.Stroke getRadiusGridlineStroke()
          Returns the stroke for the grid lines (if any) plotted against the radius axis.
 PolarItemRenderer getRenderer()
          Returns the item renderer.
 int getSeriesCount()
          Returns the number of series in the dataset for this plot.
 boolean isAngleGridlinesVisible()
          Returns true if the angular gridlines are visible, and false otherwise.
 boolean isAngleLabelsVisible()
          Returns a flag that controls whether or not the angle labels are visible.
 boolean isDomainZoomable()
          Returns true.
 boolean isRadiusGridlinesVisible()
          Returns true if the radius axis grid is visible, and false otherwise.
 boolean isRangeZoomable()
          Returns true.
 void removeCornerTextItem(java.lang.String text)
          Remove the given text from the list of corner text items.
 void render(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info)
          Draws a representation of the data within the dataArea region, using the current m_Renderer.
 void rendererChanged(RendererChangeEvent event)
          Notifies all registered listeners of a property change.
 void setAngleGridlinePaint(java.awt.Paint paint)
          Sets the paint for the grid lines plotted against the angular axis.
 void setAngleGridlineStroke(java.awt.Stroke stroke)
          Sets the stroke for the grid lines plotted against the angular axis.
 void setAngleGridlinesVisible(boolean visible)
          Sets the flag that controls whether or not the angular grid-lines are visible.
 void setAngleLabelFont(java.awt.Font font)
          Sets the font used to display the angle labels and sends a PlotChangeEvent to all registered listeners.
 void setAngleLabelPaint(java.awt.Paint paint)
          Sets the paint used to display the angle labels and sends a PlotChangeEvent to all registered listeners.
 void setAngleLabelsVisible(boolean visible)
          Sets the flag that controls whether or not the angle labels are visible, and sends a PlotChangeEvent to all registered listeners.
 void setAxis(ValueAxis axis)
          Sets the axis for the plot and sends a PlotChangeEvent to all registered listeners.
 void setDataset(XYDataset dataset)
          Sets the dataset for the plot, replacing the existing dataset if there is one.
 void setRadiusGridlinePaint(java.awt.Paint paint)
          Sets the paint for the grid lines plotted against the radius axis.
 void setRadiusGridlineStroke(java.awt.Stroke stroke)
          Sets the stroke for the grid lines plotted against the radius axis.
 void setRadiusGridlinesVisible(boolean visible)
          Sets the flag that controls whether or not the radius axis grid lines are visible.
 void setRenderer(PolarItemRenderer renderer)
          Sets the item renderer, and notifies all listeners of a change to the plot.
 java.awt.Point translateValueThetaRadiusToJava2D(double angleDegrees, double radius, java.awt.geom.Rectangle2D dataArea)
          Translates a (theta, radius) pair into Java2D coordinates.
 void zoom(double percent)
          Zooms the axis ranges by the specified percentage about the anchor point.
 void zoomDomainAxes(double x, double y, double factor)
          Multiplies the range on the domain axis/axes by the specified factor.
 void zoomDomainAxes(double x, double y, double lowerPercent, double upperPercent)
          Zooms in on the domain axes.
 void zoomRangeAxes(double x, double y, double factor)
          Multiplies the range on the range axis/axes by the specified factor.
 void zoomRangeAxes(double x, double y, double lowerPercent, double upperPercent)
          Zooms in on the range axes.
 
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, draw, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fillBackground, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, isSubplot, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDatasetGroup, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_GRIDLINE_STROKE

public static final java.awt.Stroke DEFAULT_GRIDLINE_STROKE
The default grid line stroke.


DEFAULT_GRIDLINE_PAINT

public static final java.awt.Paint DEFAULT_GRIDLINE_PAINT
The default grid line paint.


localizationResources

protected static java.util.ResourceBundle localizationResources
The resourceBundle for the localization.

Constructor Detail

PolarPlot

public PolarPlot()
Default constructor.


PolarPlot

public PolarPlot(XYDataset dataset,
                 ValueAxis radiusAxis,
                 PolarItemRenderer renderer)
Creates a new plot.

Parameters:
dataset - the dataset (null permitted).
radiusAxis - the radius axis (null permitted).
renderer - the renderer (null permitted).
Method Detail

addCornerTextItem

public void addCornerTextItem(java.lang.String text)
Add text to be displayed in the lower right hand corner.

Parameters:
text - the text to display.

removeCornerTextItem

public void removeCornerTextItem(java.lang.String text)
Remove the given text from the list of corner text items.

Parameters:
text - the text to remove.

clearCornerTextItem

public void clearCornerTextItem()
Clear the list of corner text items.


getPlotType

public java.lang.String getPlotType()
Returns the plot type as a string.

Specified by:
getPlotType in class Plot
Returns:
A short string describing the type of plot.

getAxis

public ValueAxis getAxis()
Returns the axis for the plot.

Returns:
The radius axis.

setAxis

public void setAxis(ValueAxis axis)
Sets the axis for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
axis - the new axis (null permitted).

getDataset

public XYDataset getDataset()
Returns the primary dataset for the plot.

Returns:
The primary dataset (possibly null).

setDataset

public void setDataset(XYDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.

Parameters:
dataset - the dataset (null permitted).

getRenderer

public PolarItemRenderer getRenderer()
Returns the item renderer.

Returns:
The renderer (possibly null).

setRenderer

public void setRenderer(PolarItemRenderer renderer)
Sets the item renderer, and notifies all listeners of a change to the plot.

If the renderer is set to null, no chart will be drawn.

Parameters:
renderer - the new renderer (null permitted).

isAngleLabelsVisible

public boolean isAngleLabelsVisible()
Returns a flag that controls whether or not the angle labels are visible.

Returns:
A boolean.

setAngleLabelsVisible

public void setAngleLabelsVisible(boolean visible)
Sets the flag that controls whether or not the angle labels are visible, and sends a PlotChangeEvent to all registered listeners.

Parameters:
visible - the flag.

getAngleLabelFont

public java.awt.Font getAngleLabelFont()
Returns the font used to display the angle labels.

Returns:
A font.

setAngleLabelFont

public void setAngleLabelFont(java.awt.Font font)
Sets the font used to display the angle labels and sends a PlotChangeEvent to all registered listeners.

Parameters:
font - the font.

getAngleLabelPaint

public java.awt.Paint getAngleLabelPaint()
Returns the paint used to display the angle labels.

Returns:
A paint.

setAngleLabelPaint

public void setAngleLabelPaint(java.awt.Paint paint)
Sets the paint used to display the angle labels and sends a PlotChangeEvent to all registered listeners.

Parameters:
paint - the paint.

isAngleGridlinesVisible

public boolean isAngleGridlinesVisible()
Returns true if the angular gridlines are visible, and false otherwise.

Returns:
true or false.

setAngleGridlinesVisible

public void setAngleGridlinesVisible(boolean visible)
Sets the flag that controls whether or not the angular grid-lines are visible.

If the flag value is changed, a PlotChangeEvent is sent to all registered listeners.

Parameters:
visible - the new value of the flag.

getAngleGridlineStroke

public java.awt.Stroke getAngleGridlineStroke()
Returns the stroke for the grid-lines (if any) plotted against the angular axis.

Returns:
the stroke.

setAngleGridlineStroke

public void setAngleGridlineStroke(java.awt.Stroke stroke)
Sets the stroke for the grid lines plotted against the angular axis.

If you set this to null, no grid lines will be drawn.

Parameters:
stroke - the stroke (null permitted).

getAngleGridlinePaint

public java.awt.Paint getAngleGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the angular axis.

Returns:
The paint.

setAngleGridlinePaint

public void setAngleGridlinePaint(java.awt.Paint paint)
Sets the paint for the grid lines plotted against the angular axis.

If you set this to null, no grid lines will be drawn.

Parameters:
paint - the paint (null permitted).

isRadiusGridlinesVisible

public boolean isRadiusGridlinesVisible()
Returns true if the radius axis grid is visible, and false otherwise.

Returns:
true or false.

setRadiusGridlinesVisible

public void setRadiusGridlinesVisible(boolean visible)
Sets the flag that controls whether or not the radius axis grid lines are visible.

If the flag value is changed, a PlotChangeEvent is sent to all registered listeners.

Parameters:
visible - the new value of the flag.

getRadiusGridlineStroke

public java.awt.Stroke getRadiusGridlineStroke()
Returns the stroke for the grid lines (if any) plotted against the radius axis.

Returns:
the stroke.

setRadiusGridlineStroke

public void setRadiusGridlineStroke(java.awt.Stroke stroke)
Sets the stroke for the grid lines plotted against the radius axis.

If you set this to null, no grid lines will be drawn.

Parameters:
stroke - the stroke (null permitted).

getRadiusGridlinePaint

public java.awt.Paint getRadiusGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the radius axis.

Returns:
the paint.

setRadiusGridlinePaint

public void setRadiusGridlinePaint(java.awt.Paint paint)
Sets the paint for the grid lines plotted against the radius axis.

If you set this to null, no grid lines will be drawn.

Parameters:
paint - the paint (null permitted).

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 PlotState parentState,
                 PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

This plot relies on an DefaultPolarItemRenderer to draw each item in the plot. This allows the visual representation of the data to be changed easily.

The optional info argument collects information about the rendering of the plot (dimensions, tooltip information etc). Just pass in null if you do not need this information.

Specified by:
draw in class Plot
Parameters:
g2 - the graphics device.
plotArea - the area within which the plot (including axes and labels) should be drawn.
parentState - ignored.
info - collects chart drawing information (null permitted).

drawCornerTextItems

public void drawCornerTextItems(java.awt.Graphics2D g2,
                                java.awt.geom.Rectangle2D area)
Draws the corner text items.

Parameters:
g2 - the drawing surface.
area - the area.

drawAxis

protected AxisState drawAxis(java.awt.Graphics2D g2,
                             java.awt.geom.Rectangle2D plotArea,
                             java.awt.geom.Rectangle2D dataArea)
A utility method for drawing the axes.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
dataArea - the data area.
Returns:
A map containing the axis states.

render

public void render(java.awt.Graphics2D g2,
                   java.awt.geom.Rectangle2D dataArea,
                   PlotRenderingInfo info)
Draws a representation of the data within the dataArea region, using the current m_Renderer.

Parameters:
g2 - the graphics device.
dataArea - the region in which the data is to be drawn.
info - an optional object for collection dimension information (null permitted).

drawGridlines

protected void drawGridlines(java.awt.Graphics2D g2,
                             java.awt.geom.Rectangle2D dataArea,
                             java.util.List angularTicks,
                             java.util.List radialTicks)
Draws the gridlines for the plot, if they are visible.

Parameters:
g2 - the graphics device.
dataArea - the data area.
angularTicks - the ticks for the angular axis.
radialTicks - the ticks for the radial axis.

zoom

public void zoom(double percent)
Zooms the axis ranges by the specified percentage about the anchor point.

Overrides:
zoom in class Plot
Parameters:
percent - the amount of the zoom.

getDataRange

public Range getDataRange(ValueAxis axis)
Returns the range for the specified axis.

Specified by:
getDataRange in interface ValueAxisPlot
Parameters:
axis - the axis.
Returns:
The range.

datasetChanged

public void datasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's m_Dataset.

The axis ranges are updated if necessary.

Specified by:
datasetChanged in interface DatasetChangeListener
Overrides:
datasetChanged in class Plot
Parameters:
event - information about the event (not used here).

rendererChanged

public void rendererChanged(RendererChangeEvent event)
Notifies all registered listeners of a property change.

One source of property change events is the plot's m_Renderer.

Specified by:
rendererChanged in interface RendererChangeListener
Parameters:
event - information about the property change.

getSeriesCount

public int getSeriesCount()
Returns the number of series in the dataset for this plot. If the dataset is null, the method returns 0.

Returns:
The series count.

getLegendItems

public LegendItemCollection getLegendItems()
Returns the legend items for the plot. Each legend item is generated by the plot's m_Renderer, since the m_Renderer is responsible for the visual representation of the data.

Specified by:
getLegendItems in interface LegendItemSource
Overrides:
getLegendItems in class Plot
Returns:
the legend items.

equals

public boolean equals(java.lang.Object obj)
Tests this plot for equality with another object.

Overrides:
equals in class Plot
Parameters:
obj - the object.
Returns:
true or false.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the plot.

Overrides:
clone in class Plot
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - this can occur if some component of the plot cannot be cloned.

zoomDomainAxes

public void zoomDomainAxes(double x,
                           double y,
                           double factor)
Multiplies the range on the domain axis/axes by the specified factor.

Parameters:
x - the x-coordinate (in Java2D space).
y - the y-coordinate (in Java2D space).
factor - the zoom factor.

zoomDomainAxes

public void zoomDomainAxes(double x,
                           double y,
                           double lowerPercent,
                           double upperPercent)
Zooms in on the domain axes.

Parameters:
x - the x-coordinate (in Java2D space).
y - the y-coordinate (in Java2D space).
lowerPercent - the new lower bound.
upperPercent - the new upper bound.

zoomRangeAxes

public void zoomRangeAxes(double x,
                          double y,
                          double factor)
Multiplies the range on the range axis/axes by the specified factor.

Parameters:
x - the x-coordinate (in Java2D space).
y - the y-coordinate (in Java2D space).
factor - the zoom factor.

zoomRangeAxes

public void zoomRangeAxes(double x,
                          double y,
                          double lowerPercent,
                          double upperPercent)
Zooms in on the range axes.

Parameters:
x - the x-coordinate (in Java2D space).
y - the y-coordinate (in Java2D space).
lowerPercent - the new lower bound.
upperPercent - the new upper bound.

isDomainZoomable

public boolean isDomainZoomable()
Returns true.

Returns:
A boolean.

isRangeZoomable

public boolean isRangeZoomable()
Returns true.

Returns:
A boolean.

getMaxRadius

public double getMaxRadius()
Returns the upper bound of the radius axis.

Returns:
The upper bound.

translateValueThetaRadiusToJava2D

public java.awt.Point translateValueThetaRadiusToJava2D(double angleDegrees,
                                                        double radius,
                                                        java.awt.geom.Rectangle2D dataArea)
Translates a (theta, radius) pair into Java2D coordinates.

Parameters:
angleDegrees - the angle in degrees.
radius - the radius.
dataArea - the data area.
Returns:
A point in Java2D space.