org.jfree.chart.plot

Class PolarPlot

public class PolarPlot extends Plot implements ValueAxisPlot, Zoomable, RendererChangeListener, Cloneable, Serializable

Plots data that is in (theta, radius) pairs where theta equal to zero is due north and increases clockwise.
Field Summary
static doubleDEFAULT_ANGLE_TICK_UNIT_SIZE
The default angle tick unit size.
static PaintDEFAULT_GRIDLINE_PAINT
The default grid line paint.
static StrokeDEFAULT_GRIDLINE_STROKE
The default grid line stroke.
protected static ResourceBundlelocalizationResources
The resourceBundle for the localization.
Constructor Summary
PolarPlot()
Default constructor.
PolarPlot(XYDataset dataset, ValueAxis radiusAxis, PolarItemRenderer renderer)
Creates a new plot.
Method Summary
voidaddCornerTextItem(String text)
Add text to be displayed in the lower right hand corner and sends a PlotChangeEvent to all registered listeners.
voidclearCornerTextItems()
Clear the list of corner text items and sends a PlotChangeEvent to all registered listeners.
Objectclone()
Returns a clone of the plot.
voiddatasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's m_Dataset.
voiddraw(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).
protected AxisStatedrawAxis(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea)
A utility method for drawing the axes.
protected voiddrawCornerTextItems(Graphics2D g2, Rectangle2D area)
Draws the corner text items.
protected voiddrawGridlines(Graphics2D g2, Rectangle2D dataArea, List angularTicks, List radialTicks)
Draws the gridlines for the plot, if they are visible.
booleanequals(Object obj)
Tests this plot for equality with another object.
PaintgetAngleGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the angular axis.
StrokegetAngleGridlineStroke()
Returns the stroke for the grid-lines (if any) plotted against the angular axis.
FontgetAngleLabelFont()
Returns the font used to display the angle labels.
PaintgetAngleLabelPaint()
Returns the paint used to display the angle labels.
TickUnitgetAngleTickUnit()
Returns the tick unit that controls the spacing of the angular grid lines.
ValueAxisgetAxis()
Returns the axis for the plot.
RangegetDataRange(ValueAxis axis)
Returns the range for the specified axis.
XYDatasetgetDataset()
Returns the primary dataset for the plot.
LegendItemCollectiongetLegendItems()
Returns the legend items for the plot.
doublegetMaxRadius()
Returns the upper bound of the radius axis.
PlotOrientationgetOrientation()
Returns the orientation of the plot.
StringgetPlotType()
Returns the plot type as a string.
PaintgetRadiusGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the radius axis.
StrokegetRadiusGridlineStroke()
Returns the stroke for the grid lines (if any) plotted against the radius axis.
PolarItemRenderergetRenderer()
Returns the item renderer.
intgetSeriesCount()
Returns the number of series in the dataset for this plot.
booleanisAngleGridlinesVisible()
Returns true if the angular gridlines are visible, and false otherwise.
booleanisAngleLabelsVisible()
Returns a flag that controls whether or not the angle labels are visible.
booleanisDomainZoomable()
Returns false always.
booleanisRadiusGridlinesVisible()
Returns true if the radius axis grid is visible, and false otherwise.
booleanisRangeZoomable()
Returns true to indicate that the range axis is zoomable.
protected ListrefreshAngleTicks()
Generates a list of tick values for the angular tick marks.
voidremoveCornerTextItem(String text)
Remove the given text from the list of corner text items and sends a PlotChangeEvent to all registered listeners.
protected voidrender(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info)
Draws a representation of the data within the dataArea region, using the current m_Renderer.
voidrendererChanged(RendererChangeEvent event)
Notifies all registered listeners of a property change.
voidsetAngleGridlinePaint(Paint paint)
Sets the paint for the grid lines plotted against the angular axis.
voidsetAngleGridlinesVisible(boolean visible)
Sets the flag that controls whether or not the angular grid-lines are visible.
voidsetAngleGridlineStroke(Stroke stroke)
Sets the stroke for the grid lines plotted against the angular axis and sends a PlotChangeEvent to all registered listeners.
voidsetAngleLabelFont(Font font)
Sets the font used to display the angle labels and sends a PlotChangeEvent to all registered listeners.
voidsetAngleLabelPaint(Paint paint)
Sets the paint used to display the angle labels and sends a PlotChangeEvent to all registered listeners.
voidsetAngleLabelsVisible(boolean visible)
Sets the flag that controls whether or not the angle labels are visible, and sends a PlotChangeEvent to all registered listeners.
voidsetAngleTickUnit(TickUnit unit)
Sets the tick unit that controls the spacing of the angular grid lines, and sends a PlotChangeEvent to all registered listeners.
voidsetAxis(ValueAxis axis)
Sets the axis for the plot and sends a PlotChangeEvent to all registered listeners.
voidsetDataset(XYDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.
voidsetRadiusGridlinePaint(Paint paint)
Sets the paint for the grid lines plotted against the radius axis and sends a PlotChangeEvent to all registered listeners.
voidsetRadiusGridlinesVisible(boolean visible)
Sets the flag that controls whether or not the radius axis grid lines are visible.
voidsetRadiusGridlineStroke(Stroke stroke)
Sets the stroke for the grid lines plotted against the radius axis and sends a PlotChangeEvent to all registered listeners.
voidsetRenderer(PolarItemRenderer renderer)
Sets the item renderer, and notifies all listeners of a change to the plot.
PointtranslateValueThetaRadiusToJava2D(double angleDegrees, double radius, Rectangle2D dataArea)
Translates a (theta, radius) pair into Java2D coordinates.
voidzoom(double percent)
Zooms the axis ranges by the specified percentage about the anchor point.
voidzoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source)
This method is required by the Zoomable interface, but since the plot does not have any domain axes, it does nothing.
voidzoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor)
This method is required by the Zoomable interface, but since the plot does not have any domain axes, it does nothing.
voidzoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
This method is required by the Zoomable interface, but since the plot does not have any domain axes, it does nothing.
voidzoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source)
Multiplies the range on the range axis/axes by the specified factor.
voidzoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor)
Multiplies the range on the range axis by the specified factor.
voidzoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
Zooms in on the range axes.

Field Detail

DEFAULT_ANGLE_TICK_UNIT_SIZE

public static final double DEFAULT_ANGLE_TICK_UNIT_SIZE
The default angle tick unit size.

Since: 1.0.10

DEFAULT_GRIDLINE_PAINT

public static final Paint DEFAULT_GRIDLINE_PAINT
The default grid line paint.

DEFAULT_GRIDLINE_STROKE

public static final Stroke DEFAULT_GRIDLINE_STROKE
The default grid line stroke.

localizationResources

protected static 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(String text)
Add text to be displayed in the lower right hand corner and sends a PlotChangeEvent to all registered listeners.

Parameters: text the text to display (null not permitted).

See Also: removeCornerTextItem

clearCornerTextItems

public void clearCornerTextItems()
Clear the list of corner text items and sends a PlotChangeEvent to all registered listeners.

See Also: addCornerTextItem removeCornerTextItem

clone

public Object clone()
Returns a clone of the plot.

Returns: A clone.

Throws: CloneNotSupportedException this can occur if some component of the plot cannot be cloned.

datasetChanged

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

The axis ranges are updated if necessary.

Parameters: event information about the event (not used here).

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).

This plot relies on a PolarItemRenderer 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.

Parameters: g2 the graphics device. area the area within which the plot (including axes and labels) should be drawn. anchor the anchor point (null permitted). parentState ignored. info collects chart drawing information (null permitted).

drawAxis

protected AxisState drawAxis(Graphics2D g2, Rectangle2D plotArea, 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.

drawCornerTextItems

protected void drawCornerTextItems(Graphics2D g2, Rectangle2D area)
Draws the corner text items.

Parameters: g2 the drawing surface. area the area.

drawGridlines

protected void drawGridlines(Graphics2D g2, Rectangle2D dataArea, List angularTicks, 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.

equals

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

Parameters: obj the object (null permitted).

Returns: true or false.

getAngleGridlinePaint

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

Returns: The paint (possibly null).

See Also: setAngleGridlinePaint

getAngleGridlineStroke

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

Returns: The stroke (possibly null).

See Also: setAngleGridlineStroke

getAngleLabelFont

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

Returns: A font (never null).

See Also: setAngleLabelFont

getAngleLabelPaint

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

Returns: A paint (never null).

See Also: setAngleLabelPaint

getAngleTickUnit

public TickUnit getAngleTickUnit()
Returns the tick unit that controls the spacing of the angular grid lines.

Returns: The tick unit (never null).

Since: 1.0.10

getAxis

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

Returns: The radius axis (possibly null).

See Also: setAxis

getDataRange

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

Parameters: axis the axis.

Returns: The range.

getDataset

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

Returns: The primary dataset (possibly null).

See Also: setDataset

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.

Returns: The legend items.

getMaxRadius

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

Returns: The upper bound.

getOrientation

public PlotOrientation getOrientation()
Returns the orientation of the plot.

Returns: The orientation.

getPlotType

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

Returns: A short string describing the type of plot.

getRadiusGridlinePaint

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

Returns: The paint (possibly null).

See Also: setRadiusGridlinePaint

getRadiusGridlineStroke

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

Returns: The stroke (possibly null).

See Also: setRadiusGridlineStroke

getRenderer

public PolarItemRenderer getRenderer()
Returns the item renderer.

Returns: The renderer (possibly null).

See Also: setRenderer

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.

isAngleGridlinesVisible

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

Returns: true or false.

See Also: PolarPlot

isAngleLabelsVisible

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

Returns: A boolean.

See Also: PolarPlot

isDomainZoomable

public boolean isDomainZoomable()
Returns false always.

Returns: false always.

isRadiusGridlinesVisible

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

Returns: true or false.

See Also: PolarPlot

isRangeZoomable

public boolean isRangeZoomable()
Returns true to indicate that the range axis is zoomable.

Returns: true.

refreshAngleTicks

protected List refreshAngleTicks()
Generates a list of tick values for the angular tick marks.

Returns: A list of NumberTick instances.

Since: 1.0.10

removeCornerTextItem

public void removeCornerTextItem(String text)
Remove the given text from the list of corner text items and sends a PlotChangeEvent to all registered listeners.

Parameters: text the text to remove (null ignored).

See Also: addCornerTextItem

render

protected void render(Graphics2D g2, 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).

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.

Parameters: event information about the property change.

setAngleGridlinePaint

public void setAngleGridlinePaint(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).

See Also: getAngleGridlinePaint

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.

See Also: isAngleGridlinesVisible

setAngleGridlineStroke

public void setAngleGridlineStroke(Stroke stroke)
Sets the stroke for the grid lines plotted against the angular axis and sends a PlotChangeEvent to all registered listeners.

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

Parameters: stroke the stroke (null permitted).

See Also: getAngleGridlineStroke

setAngleLabelFont

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

Parameters: font the font (null not permitted).

See Also: getAngleLabelFont

setAngleLabelPaint

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

Parameters: paint the paint (null not permitted).

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.

See Also: isAngleLabelsVisible

setAngleTickUnit

public void setAngleTickUnit(TickUnit unit)
Sets the tick unit that controls the spacing of the angular grid lines, and sends a PlotChangeEvent to all registered listeners.

Parameters: unit the tick unit (null not permitted).

Since: 1.0.10

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).

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).

See Also: getDataset

setRadiusGridlinePaint

public void setRadiusGridlinePaint(Paint paint)
Sets the paint for the grid lines plotted against the radius axis and sends a PlotChangeEvent to all registered listeners.

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

Parameters: paint the paint (null permitted).

See Also: getRadiusGridlinePaint

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.

See Also: isRadiusGridlinesVisible

setRadiusGridlineStroke

public void setRadiusGridlineStroke(Stroke stroke)
Sets the stroke for the grid lines plotted against the radius axis and sends a PlotChangeEvent to all registered listeners.

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

Parameters: stroke the stroke (null permitted).

See Also: getRadiusGridlineStroke

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).

See Also: getRenderer

translateValueThetaRadiusToJava2D

public Point translateValueThetaRadiusToJava2D(double angleDegrees, double radius, Rectangle2D dataArea)
Translates a (theta, radius) pair into Java2D coordinates. If radius is less than the lower bound of the axis, then this method returns the centre point.

Parameters: angleDegrees the angle in degrees. radius the radius. dataArea the data area.

Returns: A point in Java2D space.

zoom

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

Parameters: percent the amount of the zoom.

zoomDomainAxes

public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source)
This method is required by the Zoomable interface, but since the plot does not have any domain axes, it does nothing.

Parameters: factor the zoom factor. state the plot state. source the source point (in Java2D coordinates).

zoomDomainAxes

public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor)
This method is required by the Zoomable interface, but since the plot does not have any domain axes, it does nothing.

Parameters: factor the zoom factor. state the plot state. source the source point (in Java2D coordinates). useAnchor use source point as zoom anchor?

Since: 1.0.7

zoomDomainAxes

public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
This method is required by the Zoomable interface, but since the plot does not have any domain axes, it does nothing.

Parameters: lowerPercent the new lower bound. upperPercent the new upper bound. state the plot state. source the source point (in Java2D coordinates).

zoomRangeAxes

public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source)
Multiplies the range on the range axis/axes by the specified factor.

Parameters: factor the zoom factor. state the plot state. source the source point (in Java2D coordinates).

zoomRangeAxes

public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor)
Multiplies the range on the range axis by the specified factor.

Parameters: factor the zoom factor. info the plot rendering info. source the source point (in Java2D space). useAnchor use source point as zoom anchor?

Since: 1.0.7

See Also:

zoomRangeAxes

public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
Zooms in on the range axes.

Parameters: lowerPercent the new lower bound. upperPercent the new upper bound. state the plot state. source the source point (in Java2D coordinates).

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.