Class PolarPlot

java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.PolarPlot
All Implemented Interfaces:
Serializable, Cloneable, EventListener, AxisChangeListener, RendererChangeListener, ValueAxisPlot, DatasetChangeListener

public class PolarPlot
extends Plot
implements ValueAxisPlot, RendererChangeListener, Cloneable, 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 Details

    • DEFAULT_GRIDLINE_STROKE

      public static final Stroke DEFAULT_GRIDLINE_STROKE
      The default grid line stroke.
    • DEFAULT_GRIDLINE_PAINT

      public static final Paint DEFAULT_GRIDLINE_PAINT
      The default grid line paint.
  • Constructor Details

    • PolarPlot

      public PolarPlot()
      Default constructor.
    • PolarPlot

      public PolarPlot​(XYDataset dataset, ValueAxis radiusAxis, PolarItemRenderer renderer)
      Creates a new plot.
      Parameters:
      dataset - the m_Dataset (null permitted).
      radiusAxis - the radius axis (null permitted).
      renderer - the m_Renderer (null permitted).
  • Method Details

    • addCornerTextItem

      public void addCornerTextItem​(String text)
      Add text to be displayed in the lower right hand corner.
      Parameters:
      text - the text to display.
    • removeCornerTextItem

      public void removeCornerTextItem​(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 String getPlotType()
      Returns the plot type as a string.
      Specified by:
      getPlotType in class Plot
      Returns:
      A short string describing the type of plot.
    • getRadialAxis

      public ValueAxis getRadialAxis()
      Returns the radius axis for the plot. If the radius axis for this plot is null, then the method will return the parent plot's radius axis (if there is a parent plot).
      Returns:
      the radius axis.
    • setRadialAxis

      public void setRadialAxis​(ValueAxis axis)
      Sets the radius axis for the plot.

      An exception is thrown if the new axis and the plot are not mutually compatible.

      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 Font getAngleLabelFont()
      Returns the font used to display the angle labels.
      Returns:
      A font.
    • 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.
    • getAngleLabelPaint

      public Paint getAngleLabelPaint()
      Returns the paint used to display the angle labels.
      Returns:
      A paint.
    • 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.
    • isAngleGridlinesVisible

      public boolean isAngleGridlinesVisible()
      Returns true if the angular gridlines are visible, and false otherwise. @return 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 Stroke getAngleGridlineStroke()
      Returns the stroke for the grid-lines (if any) plotted against the angular axis.
      Returns:
      the stroke.
    • setAngleGridlineStroke

      public void setAngleGridlineStroke​(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 Paint getAngleGridlinePaint()
      Returns the paint for the grid lines (if any) plotted against the angular axis.
      Returns:
      the paint.
    • 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).
    • isRadiusGridlinesVisible

      public boolean isRadiusGridlinesVisible()
      Returns true if the radius axis grid is visible, and false otherwise. @return 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 Stroke getRadiusGridlineStroke()
      Returns the stroke for the grid lines (if any) plotted against the radius axis.
      Returns:
      the stroke.
    • setRadiusGridlineStroke

      public void setRadiusGridlineStroke​(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 Paint getRadiusGridlinePaint()
      Returns the paint for the grid lines (if any) plotted against the radius axis.
      Returns:
      the paint.
    • setRadiusGridlinePaint

      public void setRadiusGridlinePaint​(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​(Graphics2D g2, 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​(Graphics2D g2, Rectangle2D area)
      Draws the corner text items.
      Parameters:
      g2 - the drawing surface.
      area - the area.
    • render

      public 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).
    • 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.
      Overrides:
      getLegendItems in class Plot
      Returns:
      the legend items.
    • equals

      public boolean equals​(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 Object clone() throws CloneNotSupportedException
      Returns a clone of the plot.
      Overrides:
      clone in class Plot
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - this can occur if some component of the plot cannot be cloned.
    • zoomHorizontalAxes

      public void zoomHorizontalAxes​(double factor)
      Multiplies the range on the horizontal axis/axes by the specified factor.
      Specified by:
      zoomHorizontalAxes in interface ValueAxisPlot
      Parameters:
      factor - the zoom factor.
    • zoomHorizontalAxes

      public void zoomHorizontalAxes​(double lowerPercent, double upperPercent)
      Zooms in on the horizontal axes.
      Specified by:
      zoomHorizontalAxes in interface ValueAxisPlot
      Parameters:
      lowerPercent - the new lower bound.
      upperPercent - the new upper bound.
    • zoomVerticalAxes

      public void zoomVerticalAxes​(double factor)
      Multiplies the range on the vertical axis/axes by the specified factor.
      Specified by:
      zoomVerticalAxes in interface ValueAxisPlot
      Parameters:
      factor - the zoom factor.
    • zoomVerticalAxes

      public void zoomVerticalAxes​(double lowerPercent, double upperPercent)
      Zooms in on the vertical axes.
      Specified by:
      zoomVerticalAxes in interface ValueAxisPlot
      Parameters:
      lowerPercent - the new lower bound.
      upperPercent - the new upper bound.
    • getMaxRadius

      public double getMaxRadius()
      Returns the upper bound of the radius axis.
      Returns:
      The upper bound.
    • translateValueThetaRadiusToJava2D

      public Point translateValueThetaRadiusToJava2D​(double angleDegrees, double radius, 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.