Class PolarPlot
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AxisChangeListener
,RendererChangeListener
,ValueAxisPlot
,DatasetChangeListener
public class PolarPlot extends Plot implements ValueAxisPlot, RendererChangeListener, Cloneable, Serializable
- Author:
- Daniel Bridenbecker, Solution Engineering, Inc.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static Paint
DEFAULT_GRIDLINE_PAINT
The default grid line paint.static Stroke
DEFAULT_GRIDLINE_STROKE
The default grid line stroke.Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO
-
Constructor Summary
Constructors Constructor Description PolarPlot()
Default constructor.PolarPlot(XYDataset dataset, ValueAxis radiusAxis, PolarItemRenderer renderer)
Creates a new plot. -
Method Summary
Modifier and Type Method Description void
addCornerTextItem(String text)
Add text to be displayed in the lower right hand corner.void
clearCornerTextItem()
Clear the list of corner text items.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(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).void
drawCornerTextItems(Graphics2D g2, Rectangle2D area)
Draws the corner text items.boolean
equals(Object obj)
Tests this plot for equality with another object.Paint
getAngleGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the angular axis.Stroke
getAngleGridlineStroke()
Returns the stroke for the grid-lines (if any) plotted against the angular axis.Font
getAngleLabelFont()
Returns the font used to display the angle labels.Paint
getAngleLabelPaint()
Returns the paint used to display the angle labels.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.String
getPlotType()
Returns the plot type as a string.ValueAxis
getRadialAxis()
Returns the radius axis for the plot.Paint
getRadiusGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the radius axis.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()
Returnstrue
if the angular gridlines are visible, andfalse
otherwise.
boolean
isAngleLabelsVisible()
Returns a flag that controls whether or not the angle labels are visible.boolean
isRadiusGridlinesVisible()
Returnstrue
if the radius axis grid is visible, andfalse
otherwise.
void
removeCornerTextItem(String text)
Remove the given text from the list of corner text items.void
render(Graphics2D g2, 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(Paint paint)
Sets the paint for the grid lines plotted against the angular axis.void
setAngleGridlineStroke(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(Font font)
Sets the font used to display the angle labels and sends aPlotChangeEvent
to all registered listeners.void
setAngleLabelPaint(Paint paint)
Sets the paint used to display the angle labels and sends aPlotChangeEvent
to all registered listeners.void
setAngleLabelsVisible(boolean visible)
Sets the flag that controls whether or not the angle labels are visible, and sends aPlotChangeEvent
to all registered listeners.void
setDataset(XYDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.void
setRadialAxis(ValueAxis axis)
Sets the radius axis for the plot.void
setRadiusGridlinePaint(Paint paint)
Sets the paint for the grid lines plotted against the radius axis.void
setRadiusGridlineStroke(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.Point
translateValueThetaRadiusToJava2D(double angleDegrees, double radius, 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
zoomHorizontalAxes(double factor)
Multiplies the range on the horizontal axis/axes by the specified factor.void
zoomHorizontalAxes(double lowerPercent, double upperPercent)
Zooms in on the horizontal axes.void
zoomVerticalAxes(double factor)
Multiplies the range on the vertical axis/axes by the specified factor.void
zoomVerticalAxes(double lowerPercent, double upperPercent)
Zooms in on the vertical axes.Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, draw, drawBackground, drawOutline, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRootPlot, handleClick, isPlotShowing, isSubplot, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent, setPlotShowing
-
Field Details
-
DEFAULT_GRIDLINE_STROKE
The default grid line stroke. -
DEFAULT_GRIDLINE_PAINT
The default grid line paint.
-
-
Constructor Details
-
PolarPlot
public PolarPlot()Default constructor. -
PolarPlot
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
Add text to be displayed in the lower right hand corner.- Parameters:
text
- the text to display.
-
removeCornerTextItem
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
Returns the plot type as a string.- Specified by:
getPlotType
in classPlot
- Returns:
- A short string describing the type of plot.
-
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
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
Returns the primary dataset for the plot.- Returns:
- The primary dataset (possibly
null
).
-
setDataset
Sets the dataset for the plot, replacing the existing dataset if there is one.- Parameters:
dataset
- the dataset (null
permitted).
-
getRenderer
Returns the item renderer.- Returns:
- The renderer (possibly
null
).
-
setRenderer
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 aPlotChangeEvent
to all registered listeners.- Parameters:
visible
- the flag.
-
getAngleLabelFont
Returns the font used to display the angle labels.- Returns:
- A font.
-
setAngleLabelFont
Sets the font used to display the angle labels and sends aPlotChangeEvent
to all registered listeners.- Parameters:
font
- the font.
-
getAngleLabelPaint
Returns the paint used to display the angle labels.- Returns:
- A paint.
-
setAngleLabelPaint
Sets the paint used to display the angle labels and sends aPlotChangeEvent
to all registered listeners.- Parameters:
paint
- the paint.
-
isAngleGridlinesVisible
public boolean isAngleGridlinesVisible()Returnstrue
if the angular gridlines are visible, andfalse
otherwise. @return
true
orfalse
. -
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
Returns the stroke for the grid-lines (if any) plotted against the angular axis.- Returns:
- the stroke.
-
setAngleGridlineStroke
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
Returns the paint for the grid lines (if any) plotted against the angular axis.- Returns:
- the paint.
-
setAngleGridlinePaint
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()Returnstrue
if the radius axis grid is visible, andfalse
otherwise. @return
true
orfalse
. -
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
Returns the stroke for the grid lines (if any) plotted against the radius axis.- Returns:
- the stroke.
-
setRadiusGridlineStroke
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
Returns the paint for the grid lines (if any) plotted against the radius axis.- Returns:
- the paint.
-
setRadiusGridlinePaint
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. -
drawCornerTextItems
Draws the corner text items.- Parameters:
g2
- the drawing surface.area
- the area.
-
render
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. -
getDataRange
Returns the range for the specified axis.- Specified by:
getDataRange
in interfaceValueAxisPlot
- Parameters:
axis
- the axis.- Returns:
- the range.
-
datasetChanged
Receives notification of a change to the plot's m_Dataset.The axis ranges are updated if necessary.
- Specified by:
datasetChanged
in interfaceDatasetChangeListener
- Overrides:
datasetChanged
in classPlot
- Parameters:
event
- information about the event (not used here).
-
rendererChanged
Notifies all registered listeners of a property change.One source of property change events is the plot's m_Renderer.
- Specified by:
rendererChanged
in interfaceRendererChangeListener
- 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 isnull
, the method returns 0.- Returns:
- The series count.
-
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 classPlot
- Returns:
- the legend items.
-
equals
Tests this plot for equality with another object. -
clone
Returns a clone of the plot.- Overrides:
clone
in classPlot
- 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 interfaceValueAxisPlot
- Parameters:
factor
- the zoom factor.
-
zoomHorizontalAxes
public void zoomHorizontalAxes(double lowerPercent, double upperPercent)Zooms in on the horizontal axes.- Specified by:
zoomHorizontalAxes
in interfaceValueAxisPlot
- 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 interfaceValueAxisPlot
- Parameters:
factor
- the zoom factor.
-
zoomVerticalAxes
public void zoomVerticalAxes(double lowerPercent, double upperPercent)Zooms in on the vertical axes.- Specified by:
zoomVerticalAxes
in interfaceValueAxisPlot
- 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.
-