Package org.jfree.chart.plot
Class RingPlot
- java.lang.Object
-
- org.jfree.chart.plot.Plot
-
- org.jfree.chart.plot.PiePlot
-
- org.jfree.chart.plot.RingPlot
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,AnnotationChangeListener
,AxisChangeListener
,MarkerChangeListener
,LegendItemSource
,PublicCloneable
,DatasetChangeListener
public class RingPlot extends PiePlot implements java.lang.Cloneable, java.io.Serializable
A customised pie plot that leaves a hole in the middle.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
centerText
Text to display in the middle of the chart (used for CenterTextMode.FIXED).private java.awt.Color
centerTextColor
The color used to display the center text.private java.awt.Font
centerTextFont
The font used to display the center text.private java.text.Format
centerTextFormatter
The formatter used when displaying the first data value from the dataset (CenterTextMode.VALUE).private CenterTextMode
centerTextMode
The center text mode.private double
innerSeparatorExtension
The length of the inner separator extension (as a percentage of the depth of the sections).private double
outerSeparatorExtension
The length of the outer separator extension (as a percentage of the depth of the sections).private double
sectionDepth
The depth of the section as a percentage of the diameter.private java.awt.Paint
separatorPaint
The paint used to draw separators.private java.awt.Stroke
separatorStroke
The stroke used to draw separators.private boolean
separatorsVisible
A flag that controls whether or not separators are drawn between the sections of the chart.private static long
serialVersionUID
For serialization.-
Fields inherited from class org.jfree.chart.plot.PiePlot
DEBUG_DRAW_INTERIOR, DEBUG_DRAW_LINK_AREA, DEBUG_DRAW_PIE_AREA, DEFAULT_INTERIOR_GAP, DEFAULT_LABEL_BACKGROUND_PAINT, DEFAULT_LABEL_FONT, DEFAULT_LABEL_OUTLINE_PAINT, DEFAULT_LABEL_OUTLINE_STROKE, DEFAULT_LABEL_PAINT, DEFAULT_LABEL_SHADOW_PAINT, DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW, DEFAULT_START_ANGLE, localizationResources, MAX_INTERIOR_GAP
-
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
Constructors Constructor Description RingPlot()
Creates a new plot with anull
dataset.RingPlot(PieDataset dataset)
Creates a new plot for the specified dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
drawItem(java.awt.Graphics2D g2, int section, java.awt.geom.Rectangle2D dataArea, PiePlotState state, int currentPass)
Draws a single data item.boolean
equals(java.lang.Object obj)
Tests this plot for equality with an arbitrary object.java.lang.String
getCenterText()
Returns the text to display in the center of the plot when the mode isCenterTextMode.FIXED
.java.awt.Color
getCenterTextColor()
Returns the color for the center text.java.awt.Font
getCenterTextFont()
Returns the font used to display the center text.java.text.Format
getCenterTextFormatter()
Returns the formatter used to format the center text value for the modeCenterTextMode.VALUE
.CenterTextMode
getCenterTextMode()
Returns the mode for displaying text in the center of the plot.double
getInnerSeparatorExtension()
Returns the length of the inner extension of the separator line that is drawn between sections, expressed as a percentage of the depth of the section.protected double
getLabelLinkDepth()
This method overrides the default value for cases where the ring plot is very thin.double
getOuterSeparatorExtension()
Returns the length of the outer extension of the separator line that is drawn between sections, expressed as a percentage of the depth of the section.double
getSectionDepth()
Returns the depth of each section, expressed as a percentage of the plot radius.java.awt.Paint
getSeparatorPaint()
Returns the separator paint.java.awt.Stroke
getSeparatorStroke()
Returns the separator stroke.boolean
getSeparatorsVisible()
Returns a flag that indicates whether or not separators are drawn between the sections in the chart.PiePlotState
initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PiePlot plot, java.lang.Integer index, PlotRenderingInfo info)
Initialises the plot state (which will store the total of all dataset values, among other things).private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setCenterText(java.lang.String text)
Sets the text to display in the center of the plot and sends a change event to all registered listeners.void
setCenterTextColor(java.awt.Color color)
Sets the color for the center text and sends a change event to all registered listeners.void
setCenterTextFont(java.awt.Font font)
Sets the font used to display the center text and sends a change event to all registered listeners.void
setCenterTextFormatter(java.text.Format formatter)
Sets the formatter used to format the center text value and sends a change event to all registered listeners.void
setCenterTextMode(CenterTextMode mode)
Sets the mode for displaying text in the center of the plot and sends a change event to all registered listeners.void
setInnerSeparatorExtension(double percent)
Sets the length of the inner extension of the separator line that is drawn between sections, as a percentage of the depth of the sections, and sends a change event to all registered listeners.void
setOuterSeparatorExtension(double percent)
Sets the length of the outer extension of the separator line that is drawn between sections, as a percentage of the depth of the sections, and sends a change event to all registered listeners.void
setSectionDepth(double sectionDepth)
The section depth is given as percentage of the plot radius.void
setSeparatorPaint(java.awt.Paint paint)
Sets the paint used to draw the separator between sections and sends a change event to all registered listeners.void
setSeparatorStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the separator between sections and sends a change event to all registered listeners.void
setSeparatorsVisible(boolean visible)
Sets the flag that controls whether or not separators are drawn between the sections in the chart, and sends a change event to all registered listeners.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
Methods inherited from class org.jfree.chart.plot.PiePlot
clearSectionOutlinePaints, clearSectionOutlineStrokes, clearSectionPaints, clone, draw, drawLabels, drawLeftLabel, drawLeftLabels, drawPie, drawRightLabel, drawRightLabels, drawSimpleLabels, getArcBounds, getArcCenter, getAutoPopulateSectionOutlinePaint, getAutoPopulateSectionOutlineStroke, getAutoPopulateSectionPaint, getDataset, getDefaultSectionOutlinePaint, getDefaultSectionOutlineStroke, getDefaultSectionPaint, getDirection, getExplodePercent, getIgnoreNullValues, getIgnoreZeroValues, getInteriorGap, getLabelBackgroundPaint, getLabelDistributor, getLabelFont, getLabelGap, getLabelGenerator, getLabelLinkMargin, getLabelLinkPaint, getLabelLinkStroke, getLabelLinkStyle, getLabelLinksVisible, getLabelOutlinePaint, getLabelOutlineStroke, getLabelPadding, getLabelPaint, getLabelShadowPaint, getLegendItems, getLegendItemShape, getLegendLabelGenerator, getLegendLabelToolTipGenerator, getLegendLabelURLGenerator, getMaximumExplodePercent, getMaximumLabelWidth, getMinimumArcAngleToDraw, getPieIndex, getPlotType, getSectionKey, getSectionOutlinePaint, getSectionOutlineStroke, getSectionOutlinesVisible, getSectionPaint, getShadowGenerator, getShadowPaint, getShadowXOffset, getShadowYOffset, getSimpleLabelOffset, getSimpleLabels, getStartAngle, getToolTipGenerator, getURLGenerator, handleMouseWheelRotation, hashCode, isCircular, lookupSectionOutlinePaint, lookupSectionOutlinePaint, lookupSectionOutlineStroke, lookupSectionOutlineStroke, lookupSectionPaint, lookupSectionPaint, lookupSectionPaint, setAutoPopulateSectionOutlinePaint, setAutoPopulateSectionOutlineStroke, setAutoPopulateSectionPaint, setCircular, setCircular, setDataset, setDefaultSectionOutlinePaint, setDefaultSectionOutlineStroke, setDefaultSectionPaint, setDirection, setExplodePercent, setIgnoreNullValues, setIgnoreZeroValues, setInteriorGap, setLabelBackgroundPaint, setLabelDistributor, setLabelFont, setLabelGap, setLabelGenerator, setLabelLinkMargin, setLabelLinkPaint, setLabelLinkStroke, setLabelLinkStyle, setLabelLinksVisible, setLabelOutlinePaint, setLabelOutlineStroke, setLabelPadding, setLabelPaint, setLabelShadowPaint, setLegendItemShape, setLegendLabelGenerator, setLegendLabelToolTipGenerator, setLegendLabelURLGenerator, setMaximumLabelWidth, setMinimumArcAngleToDraw, setPieIndex, setSectionOutlinePaint, setSectionOutlineStroke, setSectionOutlinesVisible, setSectionPaint, setShadowGenerator, setShadowPaint, setShadowXOffset, setShadowYOffset, setSimpleLabelOffset, setSimpleLabels, setStartAngle, setToolTipGenerator, setURLGenerator
-
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, annotationChanged, axisChanged, canEqual, createAndAddEntity, datasetChanged, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fetchElementHintingFlag, fillBackground, fillBackground, fireChangeEvent, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getChart, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, isNotify, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setChart, setDatasetGroup, setDrawingSupplier, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setNotify, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent, zoom
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
centerTextMode
private CenterTextMode centerTextMode
The center text mode.
-
centerText
private java.lang.String centerText
Text to display in the middle of the chart (used for CenterTextMode.FIXED).
-
centerTextFormatter
private java.text.Format centerTextFormatter
The formatter used when displaying the first data value from the dataset (CenterTextMode.VALUE).
-
centerTextFont
private java.awt.Font centerTextFont
The font used to display the center text.
-
centerTextColor
private java.awt.Color centerTextColor
The color used to display the center text.
-
separatorsVisible
private boolean separatorsVisible
A flag that controls whether or not separators are drawn between the sections of the chart.
-
separatorStroke
private transient java.awt.Stroke separatorStroke
The stroke used to draw separators.
-
separatorPaint
private transient java.awt.Paint separatorPaint
The paint used to draw separators.
-
innerSeparatorExtension
private double innerSeparatorExtension
The length of the inner separator extension (as a percentage of the depth of the sections).
-
outerSeparatorExtension
private double outerSeparatorExtension
The length of the outer separator extension (as a percentage of the depth of the sections).
-
sectionDepth
private double sectionDepth
The depth of the section as a percentage of the diameter.
-
-
Constructor Detail
-
RingPlot
public RingPlot()
Creates a new plot with anull
dataset.
-
RingPlot
public RingPlot(PieDataset dataset)
Creates a new plot for the specified dataset.- Parameters:
dataset
- the dataset (null
permitted).
-
-
Method Detail
-
getCenterTextMode
public CenterTextMode getCenterTextMode()
Returns the mode for displaying text in the center of the plot. The default value isCenterTextMode.NONE
therefore no text will be displayed by default.- Returns:
- The mode (never
null
).
-
setCenterTextMode
public void setCenterTextMode(CenterTextMode mode)
Sets the mode for displaying text in the center of the plot and sends a change event to all registered listeners. ForCenterTextMode.FIXED
, the display text will come from thecenterText
attribute (seegetCenterText()
). ForCenterTextMode.VALUE
, the center text will be the value from the first section in the dataset.- Parameters:
mode
- the mode (null
not permitted).
-
getCenterText
public java.lang.String getCenterText()
Returns the text to display in the center of the plot when the mode isCenterTextMode.FIXED
.- Returns:
- The text (possibly
null
).
-
setCenterText
public void setCenterText(java.lang.String text)
Sets the text to display in the center of the plot and sends a change event to all registered listeners. If the text is set tonull
, no text will be displayed.- Parameters:
text
- the text (null
permitted).
-
getCenterTextFormatter
public java.text.Format getCenterTextFormatter()
Returns the formatter used to format the center text value for the modeCenterTextMode.VALUE
. The default value isDecimalFormat("0.00")
.- Returns:
- The formatter (never
null
).
-
setCenterTextFormatter
public void setCenterTextFormatter(java.text.Format formatter)
Sets the formatter used to format the center text value and sends a change event to all registered listeners.- Parameters:
formatter
- the formatter (null
not permitted).
-
getCenterTextFont
public java.awt.Font getCenterTextFont()
Returns the font used to display the center text. The default value isPiePlot.DEFAULT_LABEL_FONT
.- Returns:
- The font (never
null
).
-
setCenterTextFont
public void setCenterTextFont(java.awt.Font font)
Sets the font used to display the center text and sends a change event to all registered listeners.- Parameters:
font
- the font (null
not permitted).
-
getCenterTextColor
public java.awt.Color getCenterTextColor()
Returns the color for the center text. The default value isColor.BLACK
.- Returns:
- The color (never
null
).
-
setCenterTextColor
public void setCenterTextColor(java.awt.Color color)
Sets the color for the center text and sends a change event to all registered listeners.- Parameters:
color
- the color (null
not permitted).
-
getSeparatorsVisible
public boolean getSeparatorsVisible()
Returns a flag that indicates whether or not separators are drawn between the sections in the chart.- Returns:
- A boolean.
- See Also:
setSeparatorsVisible(boolean)
-
setSeparatorsVisible
public void setSeparatorsVisible(boolean visible)
Sets the flag that controls whether or not separators are drawn between the sections in the chart, and sends a change event to all registered listeners.- Parameters:
visible
- the flag.- See Also:
getSeparatorsVisible()
-
getSeparatorStroke
public java.awt.Stroke getSeparatorStroke()
Returns the separator stroke.- Returns:
- The stroke (never
null
). - See Also:
setSeparatorStroke(Stroke)
-
setSeparatorStroke
public void setSeparatorStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the separator between sections and sends a change event to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
getSeparatorStroke()
-
getSeparatorPaint
public java.awt.Paint getSeparatorPaint()
Returns the separator paint.- Returns:
- The paint (never
null
). - See Also:
setSeparatorPaint(Paint)
-
setSeparatorPaint
public void setSeparatorPaint(java.awt.Paint paint)
Sets the paint used to draw the separator between sections and sends a change event to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getSeparatorPaint()
-
getInnerSeparatorExtension
public double getInnerSeparatorExtension()
Returns the length of the inner extension of the separator line that is drawn between sections, expressed as a percentage of the depth of the section.- Returns:
- The inner separator extension (as a percentage).
- See Also:
setInnerSeparatorExtension(double)
-
setInnerSeparatorExtension
public void setInnerSeparatorExtension(double percent)
Sets the length of the inner extension of the separator line that is drawn between sections, as a percentage of the depth of the sections, and sends a change event to all registered listeners.- Parameters:
percent
- the percentage.- See Also:
getInnerSeparatorExtension()
,setOuterSeparatorExtension(double)
-
getOuterSeparatorExtension
public double getOuterSeparatorExtension()
Returns the length of the outer extension of the separator line that is drawn between sections, expressed as a percentage of the depth of the section.- Returns:
- The outer separator extension (as a percentage).
- See Also:
setOuterSeparatorExtension(double)
-
setOuterSeparatorExtension
public void setOuterSeparatorExtension(double percent)
Sets the length of the outer extension of the separator line that is drawn between sections, as a percentage of the depth of the sections, and sends a change event to all registered listeners.- Parameters:
percent
- the percentage.- See Also:
getOuterSeparatorExtension()
-
getSectionDepth
public double getSectionDepth()
Returns the depth of each section, expressed as a percentage of the plot radius.- Returns:
- The depth of each section.
- See Also:
setSectionDepth(double)
-
setSectionDepth
public void setSectionDepth(double sectionDepth)
The section depth is given as percentage of the plot radius. Specifying 1.0 results in a straightforward pie chart.- Parameters:
sectionDepth
- the section depth.- See Also:
getSectionDepth()
-
initialise
public PiePlotState initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PiePlot plot, java.lang.Integer index, PlotRenderingInfo info)
Initialises the plot state (which will store the total of all dataset values, among other things). This method is called once at the beginning of each drawing.- Overrides:
initialise
in classPiePlot
- Parameters:
g2
- the graphics device.plotArea
- the plot area (null
not permitted).plot
- the plot.index
- the secondary index (null
for primary renderer).info
- collects chart rendering information for return to caller.- Returns:
- A state object (maintains state information relevant to one chart drawing).
-
drawItem
protected void drawItem(java.awt.Graphics2D g2, int section, java.awt.geom.Rectangle2D dataArea, PiePlotState state, int currentPass)
Draws a single data item.
-
getLabelLinkDepth
protected double getLabelLinkDepth()
This method overrides the default value for cases where the ring plot is very thin. This fixes bug 2121818.- Overrides:
getLabelLinkDepth
in classPiePlot
- Returns:
- The label link depth, as a percentage of the plot's radius.
-
equals
public boolean equals(java.lang.Object obj)
Tests this plot for equality with an arbitrary object.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
java.io.IOException
- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.
-
-