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 PaintDEFAULT_GRIDLINE_PAINTThe default grid line paint.static StrokeDEFAULT_GRIDLINE_STROKEThe 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 voidaddCornerTextItem(String text)Add text to be displayed in the lower right hand corner.voidclearCornerTextItem()Clear the list of corner text items.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 plotArea, PlotState parentState, PlotRenderingInfo info)Draws the plot on a Java 2D graphics device (such as the screen or a printer).voiddrawCornerTextItems(Graphics2D g2, Rectangle2D area)Draws the corner text items.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.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.StringgetPlotType()Returns the plot type as a string.ValueAxisgetRadialAxis()Returns the radius axis for the plot.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()Returnstrueif the angular gridlines are visible, andfalseotherwise.booleanisAngleLabelsVisible()Returns a flag that controls whether or not the angle labels are visible.booleanisRadiusGridlinesVisible()Returnstrueif the radius axis grid is visible, andfalseotherwise.voidremoveCornerTextItem(String text)Remove the given text from the list of corner text items.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.voidsetAngleGridlineStroke(Stroke stroke)Sets the stroke 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.voidsetAngleLabelFont(Font font)Sets the font used to display the angle labels and sends aPlotChangeEventto all registered listeners.voidsetAngleLabelPaint(Paint paint)Sets the paint used to display the angle labels and sends aPlotChangeEventto all registered listeners.voidsetAngleLabelsVisible(boolean visible)Sets the flag that controls whether or not the angle labels are visible, and sends aPlotChangeEventto all registered listeners.voidsetDataset(XYDataset dataset)Sets the dataset for the plot, replacing the existing dataset if there is one.voidsetRadialAxis(ValueAxis axis)Sets the radius axis for the plot.voidsetRadiusGridlinePaint(Paint paint)Sets the paint for the grid lines plotted against the radius axis.voidsetRadiusGridlineStroke(Stroke stroke)Sets the stroke for the grid lines plotted against the radius axis.voidsetRadiusGridlinesVisible(boolean visible)Sets the flag that controls whether or not the radius axis grid lines are visible.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.voidzoomHorizontalAxes(double factor)Multiplies the range on the horizontal axis/axes by the specified factor.voidzoomHorizontalAxes(double lowerPercent, double upperPercent)Zooms in on the horizontal axes.voidzoomVerticalAxes(double factor)Multiplies the range on the vertical axis/axes by the specified factor.voidzoomVerticalAxes(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 (nullpermitted).radiusAxis- the radius axis (nullpermitted).renderer- the m_Renderer (nullpermitted).
-
-
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:
getPlotTypein 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 (nullpermitted).
-
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 (nullpermitted).
-
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 aPlotChangeEventto 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 aPlotChangeEventto 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 aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint.
-
isAngleGridlinesVisible
public boolean isAngleGridlinesVisible()Returnstrueif the angular gridlines are visible, andfalseotherwise. @returntrueorfalse. -
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
PlotChangeEventis 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 (nullpermitted).
-
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 (nullpermitted).
-
isRadiusGridlinesVisible
public boolean isRadiusGridlinesVisible()Returnstrueif the radius axis grid is visible, andfalseotherwise. @returntrueorfalse. -
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
PlotChangeEventis 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 (nullpermitted).
-
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 (nullpermitted).
-
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
DefaultPolarItemRendererto 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
nullif 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 (nullpermitted).
-
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:
getDataRangein 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:
datasetChangedin interfaceDatasetChangeListener- Overrides:
datasetChangedin 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:
rendererChangedin 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:
getLegendItemsin classPlot- Returns:
- the legend items.
-
equals
Tests this plot for equality with another object. -
clone
Returns a clone of the plot.- Overrides:
clonein 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:
zoomHorizontalAxesin interfaceValueAxisPlot- Parameters:
factor- the zoom factor.
-
zoomHorizontalAxes
public void zoomHorizontalAxes(double lowerPercent, double upperPercent)Zooms in on the horizontal axes.- Specified by:
zoomHorizontalAxesin 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:
zoomVerticalAxesin interfaceValueAxisPlot- Parameters:
factor- the zoom factor.
-
zoomVerticalAxes
public void zoomVerticalAxes(double lowerPercent, double upperPercent)Zooms in on the vertical axes.- Specified by:
zoomVerticalAxesin 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.
-