Package org.jfree.chart.plot
Class PiePlot<K extends Comparable<K>>
java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.PiePlot<K>
- Type Parameters:
K- Key type for PieDataset
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AnnotationChangeListener,AxisChangeListener,MarkerChangeListener,LegendItemSource,PublicCloneable,DatasetChangeListener
A plot that displays data in the form of a pie chart, using data from any
class that implements the
PieDataset interface.
The example shown here is generated by the PieChartDemo2.java
program included in the JFreeChart Demo Collection:
Special notes:
- the default starting point is 12 o'clock and the pie sections proceed in a clockwise direction, but these settings can be changed;
- negative values in the dataset are ignored;
- there are utility methods for creating a
PieDatasetfrom aCategoryDataset;
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default interior gap.static final PaintThe default section label background paint.static final FontThe default section label font.static final PaintThe default section label outline paint.static final StrokeThe default section label outline stroke.static final PaintThe default section label paint.static final PaintThe default section label shadow paint.static final doubleThe default minimum arc angle to draw.static final doubleThe default starting angle for the pie chart.protected static ResourceBundleThe resourceBundle for the localization.static final doubleThe maximum interior gap (currently 40%).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
ConstructorsConstructorDescriptionPiePlot()Creates a new plot.PiePlot(PieDataset<K> dataset) Creates a plot that will draw a pie chart for the specified dataset. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearSectionOutlinePaints(boolean notify) Clears the section outline paint settings for this plot and, if requested, sends aPlotChangeEventto all registered listeners.voidclearSectionOutlineStrokes(boolean notify) Clears the section outline stroke settings for this plot and, if requested, sends aPlotChangeEventto all registered listeners.voidclearSectionPaints(boolean notify) Clears the section paint settings for this plot and, if requested, sends aPlotChangeEventto all registered listeners.clone()Returns a clone of the plot.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 voiddrawItem(Graphics2D g2, int section, Rectangle2D dataArea, PiePlotState state, int currentPass) Draws a single data item.protected voiddrawLabels(Graphics2D g2, List<K> keys, double totalValue, Rectangle2D plotArea, Rectangle2D linkArea, PiePlotState state) Draws the labels for the pie sections.protected voiddrawLeftLabel(Graphics2D g2, PiePlotState state, PieLabelRecord record) Draws a section label on the left side of the pie chart.protected voiddrawLeftLabels(KeyedValues<K> leftKeys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) Draws the left labels.protected voiddrawPie(Graphics2D g2, Rectangle2D plotArea, PlotRenderingInfo info) Draws the pie.protected voiddrawRightLabel(Graphics2D g2, PiePlotState state, PieLabelRecord record) Draws a section label on the right side of the pie chart.protected voiddrawRightLabels(KeyedValues<K> keys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) Draws the right labels.protected voiddrawSimpleLabels(Graphics2D g2, List<K> keys, double totalValue, Rectangle2D plotArea, Rectangle2D pieArea, PiePlotState state) Draws the pie section labels in the simple form.booleanTests this plot for equality with an arbitrary object.protected Rectangle2DgetArcBounds(Rectangle2D unexploded, Rectangle2D exploded, double angle, double extent, double explodePercent) Returns a rectangle that can be used to create a pie section (taking into account the amount by which the pie section is 'exploded').protected Point2DgetArcCenter(PiePlotState state, K key) Returns the center for the specified section.booleanReturns the flag that controls whether or not the section outline paint is auto-populated by thelookupSectionOutlinePaint(Comparable)method.booleanReturns the flag that controls whether or not the section outline stroke is auto-populated by thelookupSectionOutlinePaint(Comparable)method.booleanReturns the flag that controls whether or not the section paint is auto-populated by thelookupSectionPaint(Comparable)method.Returns the dataset.Returns the default section paint.Returns the default section stroke.Returns the default section paint.Returns the direction in which the pie sections are drawn (clockwise or anti-clockwise).doublegetExplodePercent(K key) Returns the amount that the section with the specified key should be exploded.booleanReturns the flag that controls whethernullvalues in the dataset are ignored.booleanReturns the flag that controls whether zero values in the dataset are ignored.doubleReturns the interior gap, measured as a percentage of the available drawing space.Returns the section label background paint.Returns the object responsible for the vertical layout of the pie section labels.Returns the section label font.doubleReturns the gap between the edge of the pie and the labels, expressed as a percentage of the plot width.Returns the section label generator.protected doubleReturns the distance that the end of the label link is embedded into the plot, expressed as a percentage of the plot's radius.doubleReturns the margin (expressed as a percentage of the width or height) between the edge of the pie and the link point.Returns the paint used for the lines that connect pie sections to their corresponding labels.Returns the stroke used for the label linking lines.Returns the label link style.booleanReturns the flag that controls whether or not label linking lines are visible.Returns the section label outline paint.Returns the section label outline stroke.Returns the label padding.Returns the section label paint.Returns the section label shadow paint.Returns a collection of legend items for the pie chart.Returns the shape used for legend items.Returns the legend label generator.Returns the legend label tool tip generator.Returns the legend label URL generator.doubleReturns the maximum explode percent.doubleReturns the maximum label width as a percentage of the plot width.doubleReturns the minimum arc angle that will be drawn.intReturns the pie index (this is used by theMultiplePiePlotclass to track subplots).Returns a short string describing the type of plot.protected KgetSectionKey(int section) Returns a key for the specified section.Returns the outline paint associated with the specified key, ornullif there is no paint associated with the key.Returns the outline stroke associated with the specified key, ornullif there is no stroke associated with the key.booleanReturns the flag that controls whether or not the outline is drawn for each pie section.Returns the paint associated with the specified key, ornullif there is no paint associated with the key.Returns the shadow generator for the plot, if any.Returns the shadow paint.doubleReturns the x-offset for the shadow effect.doubleReturns the y-offset for the shadow effect.Returns the offset used for the simple labels, if they are displayed.booleanReturns the flag that controls whether simple or extended labels are displayed on the plot.doubleReturns the start angle for the first pie section.Returns the tool tip generator, an object that is responsible for generating the text items used for tool tips by the plot.Returns the URL generator.voidhandleMouseWheelRotation(int rotateClicks) Handles a mouse wheel rotation (this method is intended for use by theMouseWheelHandlerclass).inthashCode()Generates a hashcode.initialise(Graphics2D g2, Rectangle2D plotArea, PiePlot<?> plot, Integer index, PlotRenderingInfo info) Initialises the drawing procedure.booleanReturns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape.protected PaintReturns the outline paint for the specified section.protected PaintlookupSectionOutlinePaint(Comparable key, boolean autoPopulate) Returns the outline paint for the specified section.protected StrokeReturns the outline stroke for the specified section.protected StrokelookupSectionOutlineStroke(Comparable key, boolean autoPopulate) Returns the outline stroke for the specified section.protected PaintReturns the paint for the specified section.protected PaintlookupSectionPaint(Comparable key, boolean autoPopulate) Returns the paint for the specified section.protected PaintlookupSectionPaint(K key, PiePlotState state) Returns the paint for the specified section.voidsetAutoPopulateSectionOutlinePaint(boolean auto) Sets the flag that controls whether or not the section outline paint is auto-populated by thelookupSectionOutlinePaint(Comparable)method, and sends aPlotChangeEventto all registered listeners.voidsetAutoPopulateSectionOutlineStroke(boolean auto) Sets the flag that controls whether or not the section outline stroke is auto-populated by thelookupSectionOutlineStroke(Comparable)method, and sends aPlotChangeEventto all registered listeners.voidsetAutoPopulateSectionPaint(boolean auto) Sets the flag that controls whether or not the section paint is auto-populated by thelookupSectionPaint(Comparable)method, and sends aPlotChangeEventto all registered listeners.voidsetCircular(boolean flag) A flag indicating whether the pie chart is circular, or stretched into an elliptical shape.voidsetCircular(boolean circular, boolean notify) Sets the circular attribute and, if requested, sends aPlotChangeEventto all registered listeners.voidsetDataset(PieDataset<K> dataset) Sets the dataset and sends aDatasetChangeEventto 'this'.voidSets the default section paint.voidsetDefaultSectionOutlineStroke(Stroke stroke) Sets the default section stroke.voidsetDefaultSectionPaint(Paint paint) Sets the default section paint and sends aPlotChangeEventto all registered listeners.voidsetDirection(Rotation direction) Sets the direction in which the pie sections are drawn and sends aPlotChangeEventto all registered listeners.voidsetExplodePercent(K key, double percent) Sets the amount that a pie section should be exploded and sends aPlotChangeEventto all registered listeners.voidsetIgnoreNullValues(boolean flag) Sets a flag that controls whethernullvalues are ignored, and sends aPlotChangeEventto all registered listeners.voidsetIgnoreZeroValues(boolean flag) Sets a flag that controls whether zero values are ignored, and sends aPlotChangeEventto all registered listeners.voidsetInteriorGap(double percent) Sets the interior gap and sends aPlotChangeEventto all registered listeners.voidsetLabelBackgroundPaint(Paint paint) Sets the section label background paint and sends aPlotChangeEventto all registered listeners.voidsetLabelDistributor(AbstractPieLabelDistributor distributor) Sets the label distributor and sends aPlotChangeEventto all registered listeners.voidsetLabelFont(Font font) Sets the section label font and sends aPlotChangeEventto all registered listeners.voidsetLabelGap(double gap) Sets the gap between the edge of the pie and the labels (expressed as a percentage of the plot width) and sends aPlotChangeEventto all registered listeners.voidsetLabelGenerator(PieSectionLabelGenerator generator) Sets the section label generator and sends aPlotChangeEventto all registered listeners.voidsetLabelLinkMargin(double margin) Sets the link margin and sends aPlotChangeEventto all registered listeners.voidsetLabelLinkPaint(Paint paint) Sets the paint used for the lines that connect pie sections to their corresponding labels, and sends aPlotChangeEventto all registered listeners.voidsetLabelLinkStroke(Stroke stroke) Sets the link stroke and sends aPlotChangeEventto all registered listeners.voidSets the label link style and sends aPlotChangeEventto all registered listeners.voidsetLabelLinksVisible(boolean visible) Sets the flag that controls whether or not label linking lines are visible and sends aPlotChangeEventto all registered listeners.voidsetLabelOutlinePaint(Paint paint) Sets the section label outline paint and sends aPlotChangeEventto all registered listeners.voidsetLabelOutlineStroke(Stroke stroke) Sets the section label outline stroke and sends aPlotChangeEventto all registered listeners.voidsetLabelPadding(RectangleInsets padding) Sets the padding between each label and its outline and sends aPlotChangeEventto all registered listeners.voidsetLabelPaint(Paint paint) Sets the section label paint and sends aPlotChangeEventto all registered listeners.voidsetLabelShadowPaint(Paint paint) Sets the section label shadow paint and sends aPlotChangeEventto all registered listeners.voidsetLegendItemShape(Shape shape) Sets the shape used for legend items and sends aPlotChangeEventto all registered listeners.voidsetLegendLabelGenerator(PieSectionLabelGenerator generator) Sets the legend label generator and sends aPlotChangeEventto all registered listeners.voidSets the legend label tool tip generator and sends aPlotChangeEventto all registered listeners.voidsetLegendLabelURLGenerator(PieURLGenerator generator) Sets the legend label URL generator and sends aPlotChangeEventto all registered listeners.voidsetMaximumLabelWidth(double width) Sets the maximum label width as a percentage of the plot width and sends aPlotChangeEventto all registered listeners.voidsetMinimumArcAngleToDraw(double angle) Sets the minimum arc angle that will be drawn.voidsetPieIndex(int index) Sets the pie index (this is used by theMultiplePiePlotclass to track subplots).voidsetSectionOutlinePaint(Comparable key, Paint paint) Sets the outline paint associated with the specified key, and sends aPlotChangeEventto all registered listeners.voidsetSectionOutlineStroke(Comparable key, Stroke stroke) Sets the outline stroke associated with the specified key, and sends aPlotChangeEventto all registered listeners.voidsetSectionOutlinesVisible(boolean visible) Sets the flag that controls whether or not the outline is drawn for each pie section, and sends aPlotChangeEventto all registered listeners.voidsetSectionPaint(Comparable key, Paint paint) Sets the paint associated with the specified key, and sends aPlotChangeEventto all registered listeners.voidsetShadowGenerator(ShadowGenerator generator) Sets the shadow generator for the plot and sends aPlotChangeEventto all registered listeners.voidsetShadowPaint(Paint paint) Sets the shadow paint and sends aPlotChangeEventto all registered listeners.voidsetShadowXOffset(double offset) Sets the x-offset for the shadow effect and sends aPlotChangeEventto all registered listeners.voidsetShadowYOffset(double offset) Sets the y-offset for the shadow effect and sends aPlotChangeEventto all registered listeners.voidsetSimpleLabelOffset(RectangleInsets offset) Sets the offset for the simple labels and sends aPlotChangeEventto all registered listeners.voidsetSimpleLabels(boolean simple) Sets the flag that controls whether simple or extended labels are displayed on the plot, and sends aPlotChangeEventto all registered listeners.voidsetStartAngle(double angle) Sets the starting angle and sends aPlotChangeEventto all registered listeners.voidsetToolTipGenerator(PieToolTipGenerator generator) Sets the tool tip generator and sends aPlotChangeEventto all registered listeners.voidsetURLGenerator(PieURLGenerator generator) Sets the URL generator and sends aPlotChangeEventto all registered listeners.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 Details
-
DEFAULT_INTERIOR_GAP
The default interior gap.- See Also:
-
MAX_INTERIOR_GAP
The maximum interior gap (currently 40%).- See Also:
-
DEFAULT_START_ANGLE
The default starting angle for the pie chart.- See Also:
-
DEFAULT_LABEL_FONT
The default section label font. -
DEFAULT_LABEL_PAINT
The default section label paint. -
DEFAULT_LABEL_BACKGROUND_PAINT
The default section label background paint. -
DEFAULT_LABEL_OUTLINE_PAINT
The default section label outline paint. -
DEFAULT_LABEL_OUTLINE_STROKE
The default section label outline stroke. -
DEFAULT_LABEL_SHADOW_PAINT
The default section label shadow paint. -
DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW
The default minimum arc angle to draw.- See Also:
-
localizationResources
The resourceBundle for the localization.
-
-
Constructor Details
-
PiePlot
public PiePlot()Creates a new plot. The dataset is initially set tonull. -
PiePlot
Creates a plot that will draw a pie chart for the specified dataset.- Parameters:
dataset- the dataset (nullpermitted).
-
-
Method Details
-
getDataset
Returns the dataset.- Returns:
- The dataset (possibly
null). - See Also:
-
setDataset
Sets the dataset and sends aDatasetChangeEventto 'this'.- Parameters:
dataset- the dataset (nullpermitted).- See Also:
-
getPieIndex
Returns the pie index (this is used by theMultiplePiePlotclass to track subplots).- Returns:
- The pie index.
- See Also:
-
setPieIndex
Sets the pie index (this is used by theMultiplePiePlotclass to track subplots).- Parameters:
index- the index.- See Also:
-
getStartAngle
Returns the start angle for the first pie section. This is measured in degrees starting from 3 o'clock and measuring anti-clockwise.- Returns:
- The start angle.
- See Also:
-
setStartAngle
Sets the starting angle and sends aPlotChangeEventto all registered listeners. The initial default value is 90 degrees, which corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock... this is the encoding used by Java's Arc2D class.- Parameters:
angle- the angle (in degrees).- See Also:
-
getDirection
Returns the direction in which the pie sections are drawn (clockwise or anti-clockwise).- Returns:
- The direction (never
null). - See Also:
-
setDirection
Sets the direction in which the pie sections are drawn and sends aPlotChangeEventto all registered listeners.- Parameters:
direction- the direction (nullnot permitted).- See Also:
-
getInteriorGap
Returns the interior gap, measured as a percentage of the available drawing space.- Returns:
- The gap (as a percentage of the available drawing space).
- See Also:
-
setInteriorGap
Sets the interior gap and sends aPlotChangeEventto all registered listeners. This controls the space between the edges of the pie plot and the plot area itself (the region where the section labels appear).- Parameters:
percent- the gap (as a percentage of the available drawing space).- See Also:
-
isCircular
Returns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape.- Returns:
- A flag indicating whether the pie chart is circular.
- See Also:
-
setCircular
A flag indicating whether the pie chart is circular, or stretched into an elliptical shape.- Parameters:
flag- the new value.- See Also:
-
setCircular
Sets the circular attribute and, if requested, sends aPlotChangeEventto all registered listeners.- Parameters:
circular- the new value of the flag.notify- notify listeners?- See Also:
-
getIgnoreNullValues
Returns the flag that controls whethernullvalues in the dataset are ignored.- Returns:
- A boolean.
- See Also:
-
setIgnoreNullValues
Sets a flag that controls whethernullvalues are ignored, and sends aPlotChangeEventto all registered listeners. At present, this only affects whether or not the key is presented in the legend.- Parameters:
flag- the flag.- See Also:
-
getIgnoreZeroValues
Returns the flag that controls whether zero values in the dataset are ignored.- Returns:
- A boolean.
- See Also:
-
setIgnoreZeroValues
Sets a flag that controls whether zero values are ignored, and sends aPlotChangeEventto all registered listeners. This only affects whether or not a label appears for the non-visible pie section.- Parameters:
flag- the flag.- See Also:
-
lookupSectionPaint
Returns the paint for the specified section. This is equivalent tolookupSectionPaint(section, getAutoPopulateSectionPaint()).- Parameters:
key- the section key.- Returns:
- The paint for the specified section.
- See Also:
-
lookupSectionPaint
Returns the paint for the specified section. The lookup involves these steps:- if
getSectionPaint(Comparable)is non-nullreturn it; - if
getSectionPaint(Comparable)isnullbutautoPopulateistrue, attempt to fetch a new paint from the drawing supplier (Plot.getDrawingSupplier()); - if all else fails, return
getDefaultSectionPaint().
- Parameters:
key- the section key.autoPopulate- a flag that controls whether the drawing supplier is used to auto-populate the section paint settings.- Returns:
- The paint.
- if
-
getSectionKey
Returns a key for the specified section. The preferred way of doing this now is to link the attributes directly to the section key (there are new methods for this, starting from version 1.0.3).- Parameters:
section- the section index.- Returns:
- The key.
-
getSectionPaint
Returns the paint associated with the specified key, ornullif there is no paint associated with the key.- Parameters:
key- the key (nullnot permitted).- Returns:
- The paint associated with the specified key, or
null. - Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
setSectionPaint
Sets the paint associated with the specified key, and sends aPlotChangeEventto all registered listeners.- Parameters:
key- the key (nullnot permitted).paint- the paint.- Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
clearSectionPaints
Clears the section paint settings for this plot and, if requested, sends aPlotChangeEventto all registered listeners. Be aware that if theautoPopulateSectionPaintflag is set, the section paints may be repopulated using the same colours as before.- Parameters:
notify- notify listeners?- See Also:
-
autoPopulateSectionPaint
-
getDefaultSectionPaint
Returns the default section paint. This is used when no other paint is defined, which is rare. The default value isColor.GRAY.- Returns:
- The paint (never
null). - See Also:
-
setDefaultSectionPaint
Sets the default section paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getAutoPopulateSectionPaint
Returns the flag that controls whether or not the section paint is auto-populated by thelookupSectionPaint(Comparable)method.- Returns:
- A boolean.
-
setAutoPopulateSectionPaint
Sets the flag that controls whether or not the section paint is auto-populated by thelookupSectionPaint(Comparable)method, and sends aPlotChangeEventto all registered listeners.- Parameters:
auto- auto-populate?
-
getSectionOutlinesVisible
Returns the flag that controls whether or not the outline is drawn for each pie section.- Returns:
- The flag that controls whether or not the outline is drawn for each pie section.
- See Also:
-
setSectionOutlinesVisible
Sets the flag that controls whether or not the outline is drawn for each pie section, and sends aPlotChangeEventto all registered listeners.- Parameters:
visible- the flag.- See Also:
-
lookupSectionOutlinePaint
Returns the outline paint for the specified section. This is equivalent tolookupSectionPaint(section, getAutoPopulateSectionOutlinePaint()).- Parameters:
key- the section key.- Returns:
- The paint for the specified section.
- See Also:
-
lookupSectionOutlinePaint
Returns the outline paint for the specified section. The lookup involves these steps:- if
getSectionOutlinePaint(Comparable)is non-nullreturn it; - if
getSectionOutlinePaint(Comparable)isnullbutautoPopulateistrue, attempt to fetch a new outline paint from the drawing supplier (Plot.getDrawingSupplier()); - if all else fails, return
getDefaultSectionOutlinePaint().
- Parameters:
key- the section key.autoPopulate- a flag that controls whether the drawing supplier is used to auto-populate the section outline paint settings.- Returns:
- The paint.
- if
-
getSectionOutlinePaint
Returns the outline paint associated with the specified key, ornullif there is no paint associated with the key.- Parameters:
key- the key (nullnot permitted).- Returns:
- The paint associated with the specified key, or
null. - Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
setSectionOutlinePaint
Sets the outline paint associated with the specified key, and sends aPlotChangeEventto all registered listeners.- Parameters:
key- the key (nullnot permitted).paint- the paint.- Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
clearSectionOutlinePaints
Clears the section outline paint settings for this plot and, if requested, sends aPlotChangeEventto all registered listeners. Be aware that if theautoPopulateSectionPaintflag is set, the section paints may be repopulated using the same colours as before.- Parameters:
notify- notify listeners?- See Also:
-
autoPopulateSectionOutlinePaint
-
getDefaultSectionOutlinePaint
Returns the default section paint. This is used when no other paint is available.- Returns:
- The paint (never
null). - See Also:
-
setDefaultSectionOutlinePaint
Sets the default section paint.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getAutoPopulateSectionOutlinePaint
Returns the flag that controls whether or not the section outline paint is auto-populated by thelookupSectionOutlinePaint(Comparable)method.- Returns:
- A boolean.
-
setAutoPopulateSectionOutlinePaint
Sets the flag that controls whether or not the section outline paint is auto-populated by thelookupSectionOutlinePaint(Comparable)method, and sends aPlotChangeEventto all registered listeners.- Parameters:
auto- auto-populate?
-
lookupSectionOutlineStroke
Returns the outline stroke for the specified section. This is equivalent tolookupSectionOutlineStroke(section, getAutoPopulateSectionOutlineStroke()).- Parameters:
key- the section key.- Returns:
- The stroke for the specified section.
- See Also:
-
lookupSectionOutlineStroke
Returns the outline stroke for the specified section. The lookup involves these steps:- if
getSectionOutlineStroke(Comparable)is non-nullreturn it; - if
getSectionOutlineStroke(Comparable)isnullbutautoPopulateistrue, attempt to fetch a new outline stroke from the drawing supplier (Plot.getDrawingSupplier()); - if all else fails, return
getDefaultSectionOutlineStroke().
- Parameters:
key- the section key.autoPopulate- a flag that controls whether the drawing supplier is used to auto-populate the section outline stroke settings.- Returns:
- The stroke.
- if
-
getSectionOutlineStroke
Returns the outline stroke associated with the specified key, ornullif there is no stroke associated with the key.- Parameters:
key- the key (nullnot permitted).- Returns:
- The stroke associated with the specified key, or
null. - Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
setSectionOutlineStroke
Sets the outline stroke associated with the specified key, and sends aPlotChangeEventto all registered listeners.- Parameters:
key- the key (nullnot permitted).stroke- the stroke.- Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
clearSectionOutlineStrokes
Clears the section outline stroke settings for this plot and, if requested, sends aPlotChangeEventto all registered listeners. Be aware that if theautoPopulateSectionPaintflag is set, the section paints may be repopulated using the same colours as before.- Parameters:
notify- notify listeners?- See Also:
-
autoPopulateSectionOutlineStroke
-
getDefaultSectionOutlineStroke
Returns the default section stroke. This is used when no other stroke is available.- Returns:
- The stroke (never
null). - See Also:
-
setDefaultSectionOutlineStroke
Sets the default section stroke.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
-
getAutoPopulateSectionOutlineStroke
Returns the flag that controls whether or not the section outline stroke is auto-populated by thelookupSectionOutlinePaint(Comparable)method.- Returns:
- A boolean.
-
setAutoPopulateSectionOutlineStroke
Sets the flag that controls whether or not the section outline stroke is auto-populated by thelookupSectionOutlineStroke(Comparable)method, and sends aPlotChangeEventto all registered listeners.- Parameters:
auto- auto-populate?
-
getShadowPaint
Returns the shadow paint.- Returns:
- The paint (possibly
null). - See Also:
-
setShadowPaint
Sets the shadow paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullpermitted).- See Also:
-
getShadowXOffset
Returns the x-offset for the shadow effect.- Returns:
- The offset (in Java2D units).
- See Also:
-
setShadowXOffset
Sets the x-offset for the shadow effect and sends aPlotChangeEventto all registered listeners.- Parameters:
offset- the offset (in Java2D units).- See Also:
-
getShadowYOffset
Returns the y-offset for the shadow effect.- Returns:
- The offset (in Java2D units).
- See Also:
-
setShadowYOffset
Sets the y-offset for the shadow effect and sends aPlotChangeEventto all registered listeners.- Parameters:
offset- the offset (in Java2D units).- See Also:
-
getExplodePercent
Returns the amount that the section with the specified key should be exploded.- Parameters:
key- the key (nullnot permitted).- Returns:
- The amount that the section with the specified key should be exploded.
- Throws:
IllegalArgumentException- ifkeyisnull.- See Also:
-
setExplodePercent
Sets the amount that a pie section should be exploded and sends aPlotChangeEventto all registered listeners.- Parameters:
key- the section key (nullnot permitted).percent- the explode percentage (0.30 = 30 percent).- See Also:
-
getMaximumExplodePercent
Returns the maximum explode percent.- Returns:
- The percent.
-
getLabelGenerator
Returns the section label generator.- Returns:
- The generator (possibly
null). - See Also:
-
setLabelGenerator
Sets the section label generator and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getLabelGap
Returns the gap between the edge of the pie and the labels, expressed as a percentage of the plot width.- Returns:
- The gap (a percentage, where 0.05 = five percent).
- See Also:
-
setLabelGap
Sets the gap between the edge of the pie and the labels (expressed as a percentage of the plot width) and sends aPlotChangeEventto all registered listeners.- Parameters:
gap- the gap (a percentage, where 0.05 = five percent).- See Also:
-
getMaximumLabelWidth
Returns the maximum label width as a percentage of the plot width.- Returns:
- The width (a percentage, where 0.20 = 20 percent).
- See Also:
-
setMaximumLabelWidth
Sets the maximum label width as a percentage of the plot width and sends aPlotChangeEventto all registered listeners.- Parameters:
width- the width (a percentage, where 0.20 = 20 percent).- See Also:
-
getLabelLinksVisible
Returns the flag that controls whether or not label linking lines are visible.- Returns:
- A boolean.
- See Also:
-
setLabelLinksVisible
Sets the flag that controls whether or not label linking lines are visible and sends aPlotChangeEventto all registered listeners. Please take care when hiding the linking lines - depending on the data values, the labels can be displayed some distance away from the corresponding pie section.- Parameters:
visible- the flag.- See Also:
-
getLabelLinkStyle
Returns the label link style.- Returns:
- The label link style (never
null). - See Also:
-
setLabelLinkStyle
Sets the label link style and sends aPlotChangeEventto all registered listeners.- Parameters:
style- the new style (nullnot permitted).- See Also:
-
getLabelLinkMargin
Returns the margin (expressed as a percentage of the width or height) between the edge of the pie and the link point.- Returns:
- The link margin (as a percentage, where 0.05 is five percent).
- See Also:
-
setLabelLinkMargin
Sets the link margin and sends aPlotChangeEventto all registered listeners.- Parameters:
margin- the margin.- See Also:
-
getLabelLinkPaint
Returns the paint used for the lines that connect pie sections to their corresponding labels.- Returns:
- The paint (never
null). - See Also:
-
setLabelLinkPaint
Sets the paint used for the lines that connect pie sections to their corresponding labels, and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getLabelLinkStroke
Returns the stroke used for the label linking lines.- Returns:
- The stroke.
- See Also:
-
setLabelLinkStroke
Sets the link stroke and sends aPlotChangeEventto all registered listeners.- Parameters:
stroke- the stroke.- See Also:
-
getLabelLinkDepth
Returns the distance that the end of the label link is embedded into the plot, expressed as a percentage of the plot's radius.
This method is overridden in theRingPlotclass to resolve bug 2121818.- Returns:
0.10.
-
getLabelFont
Returns the section label font.- Returns:
- The font (never
null). - See Also:
-
setLabelFont
Sets the section label font and sends aPlotChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
-
getLabelPaint
Returns the section label paint.- Returns:
- The paint (never
null). - See Also:
-
setLabelPaint
Sets the section label paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getLabelBackgroundPaint
Returns the section label background paint.- Returns:
- The paint (possibly
null). - See Also:
-
setLabelBackgroundPaint
Sets the section label background paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullpermitted).- See Also:
-
getLabelOutlinePaint
Returns the section label outline paint.- Returns:
- The paint (possibly
null). - See Also:
-
setLabelOutlinePaint
Sets the section label outline paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullpermitted).- See Also:
-
getLabelOutlineStroke
Returns the section label outline stroke.- Returns:
- The stroke (possibly
null). - See Also:
-
setLabelOutlineStroke
Sets the section label outline stroke and sends aPlotChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullpermitted).- See Also:
-
getLabelShadowPaint
Returns the section label shadow paint.- Returns:
- The paint (possibly
null). - See Also:
-
setLabelShadowPaint
Sets the section label shadow paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullpermitted).- See Also:
-
getLabelPadding
Returns the label padding.- Returns:
- The label padding (never
null). - See Also:
-
setLabelPadding
Sets the padding between each label and its outline and sends aPlotChangeEventto all registered listeners.- Parameters:
padding- the padding (nullnot permitted).- See Also:
-
getSimpleLabels
Returns the flag that controls whether simple or extended labels are displayed on the plot.- Returns:
- A boolean.
-
setSimpleLabels
Sets the flag that controls whether simple or extended labels are displayed on the plot, and sends aPlotChangeEventto all registered listeners.- Parameters:
simple- the new flag value.
-
getSimpleLabelOffset
Returns the offset used for the simple labels, if they are displayed.- Returns:
- The offset (never
null). - See Also:
-
setSimpleLabelOffset
Sets the offset for the simple labels and sends aPlotChangeEventto all registered listeners.- Parameters:
offset- the offset (nullnot permitted).- See Also:
-
getLabelDistributor
Returns the object responsible for the vertical layout of the pie section labels.- Returns:
- The label distributor (never
null).
-
setLabelDistributor
Sets the label distributor and sends aPlotChangeEventto all registered listeners.- Parameters:
distributor- the distributor (nullnot permitted).
-
getToolTipGenerator
Returns the tool tip generator, an object that is responsible for generating the text items used for tool tips by the plot. If the generator isnull, no tool tips will be created.- Returns:
- The generator (possibly
null). - See Also:
-
setToolTipGenerator
Sets the tool tip generator and sends aPlotChangeEventto all registered listeners. Set the generator tonullif you don't want any tool tips.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getURLGenerator
Returns the URL generator.- Returns:
- The generator (possibly
null). - See Also:
-
setURLGenerator
Sets the URL generator and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getMinimumArcAngleToDraw
Returns the minimum arc angle that will be drawn. Pie sections for an angle smaller than this are not drawn, to avoid a JDK bug.- Returns:
- The minimum angle.
- See Also:
-
setMinimumArcAngleToDraw
Sets the minimum arc angle that will be drawn. Pie sections for an angle smaller than this are not drawn, to avoid a JDK bug. See this link for details:
http://www.jfree.org/phpBB2/viewtopic.php?t=2707
...and this bug report in the Java Bug Parade:
http://developer.java.sun.com/developer/bugParade/bugs/4836495.html- Parameters:
angle- the minimum angle.- See Also:
-
getLegendItemShape
Returns the shape used for legend items.- Returns:
- The shape (never
null). - See Also:
-
setLegendItemShape
Sets the shape used for legend items and sends aPlotChangeEventto all registered listeners.- Parameters:
shape- the shape (nullnot permitted).- See Also:
-
getLegendLabelGenerator
Returns the legend label generator.- Returns:
- The legend label generator (never
null). - See Also:
-
setLegendLabelGenerator
Sets the legend label generator and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullnot permitted).- See Also:
-
getLegendLabelToolTipGenerator
Returns the legend label tool tip generator.- Returns:
- The legend label tool tip generator (possibly
null). - See Also:
-
setLegendLabelToolTipGenerator
Sets the legend label tool tip generator and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getLegendLabelURLGenerator
Returns the legend label URL generator.- Returns:
- The legend label URL generator (possibly
null). - See Also:
-
setLegendLabelURLGenerator
Sets the legend label URL generator and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getShadowGenerator
Returns the shadow generator for the plot, if any.- Returns:
- The shadow generator (possibly
null).
-
setShadowGenerator
Sets the shadow generator for the plot and sends aPlotChangeEventto all registered listeners. Note that this is a bitmap drop-shadow generation facility and is separate from the vector based show option that is controlled via thesetShadowPaint(java.awt.Paint)method.- Parameters:
generator- the generator (nullpermitted).
-
handleMouseWheelRotation
Handles a mouse wheel rotation (this method is intended for use by theMouseWheelHandlerclass).- Parameters:
rotateClicks- the number of rotate clicks on the the mouse wheel.
-
initialise
public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea, PiePlot<?> plot, Integer index, PlotRenderingInfo info) Initialises the drawing procedure. This method will be called before the first item is rendered, giving the plot an opportunity to initialise any state information it wants to maintain.- Parameters:
g2- the graphics device.plotArea- the plot area (nullnot permitted).plot- the plot.index- the secondary index (nullfor primary renderer).info- collects chart rendering information for return to caller.- Returns:
- A state object (maintains state information relevant to one chart drawing).
-
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). -
drawPie
Draws the pie.- Parameters:
g2- the graphics device.plotArea- the plot area.info- chart rendering info.
-
drawItem
protected void drawItem(Graphics2D g2, int section, Rectangle2D dataArea, PiePlotState state, int currentPass) Draws a single data item.- Parameters:
g2- the graphics device (nullnot permitted).section- the section index.dataArea- the data plot area.state- state information for one chart.currentPass- the current pass index.
-
drawSimpleLabels
protected void drawSimpleLabels(Graphics2D g2, List<K> keys, double totalValue, Rectangle2D plotArea, Rectangle2D pieArea, PiePlotState state) Draws the pie section labels in the simple form.- Parameters:
g2- the graphics device.keys- the section keys.totalValue- the total value for all sections in the pie.plotArea- the plot area.pieArea- the area containing the pie.state- the plot state.
-
drawLabels
protected void drawLabels(Graphics2D g2, List<K> keys, double totalValue, Rectangle2D plotArea, Rectangle2D linkArea, PiePlotState state) Draws the labels for the pie sections.- Parameters:
g2- the graphics device.keys- the keys.totalValue- the total value.plotArea- the plot area.linkArea- the link area.state- the state.
-
drawLeftLabels
protected void drawLeftLabels(KeyedValues<K> leftKeys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) Draws the left labels.- Parameters:
leftKeys- a collection of keys and angles (to the middle of the section, in degrees) for the sections on the left side of the plot.g2- the graphics device.plotArea- the plot area.linkArea- the link area.maxLabelWidth- the maximum label width.state- the state.
-
drawRightLabels
protected void drawRightLabels(KeyedValues<K> keys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) Draws the right labels.- Parameters:
keys- the keys.g2- the graphics device.plotArea- the plot area.linkArea- the link area.maxLabelWidth- the maximum label width.state- the state.
-
getLegendItems
Returns a collection of legend items for the pie chart.- Specified by:
getLegendItemsin interfaceLegendItemSource- Overrides:
getLegendItemsin classPlot- Returns:
- The legend items (never
null).
-
getPlotType
Returns a short string describing the type of plot.- Specified by:
getPlotTypein classPlot- Returns:
- The plot type.
-
getArcBounds
protected Rectangle2D getArcBounds(Rectangle2D unexploded, Rectangle2D exploded, double angle, double extent, double explodePercent) Returns a rectangle that can be used to create a pie section (taking into account the amount by which the pie section is 'exploded').- Parameters:
unexploded- the area inside which the unexploded pie sections are drawn.exploded- the area inside which the exploded pie sections are drawn.angle- the start angle.extent- the extent of the arc.explodePercent- the amount by which the pie section is exploded.- Returns:
- A rectangle that can be used to create a pie section.
-
drawLeftLabel
Draws a section label on the left side of the pie chart.- Parameters:
g2- the graphics device.state- the state.record- the label record.
-
drawRightLabel
Draws a section label on the right side of the pie chart.- Parameters:
g2- the graphics device.state- the state.record- the label record.
-
getArcCenter
Returns the center for the specified section. Checks to see if the section is exploded and recalculates the new center if so.- Parameters:
state- PiePlotStatekey- section key.- Returns:
- The center for the specified section.
-
lookupSectionPaint
Returns the paint for the specified section. This is equivalent tolookupSectionPaint(section). Checks to see if the user set thePaintto be of typeRadialGradientPaintand if so it adjusts the center and radius to match the Pie.- Parameters:
key- the section key.state- PiePlotState.- Returns:
- The paint for the specified section.
-
equals
Tests this plot for equality with an arbitrary object. Note that the plot's dataset is NOT included in the test for equality. -
hashCode
Generates a hashcode. Note that, as with the equals method, the dataset is NOT included in the hashcode. -
clone
Returns a clone of the plot.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classPlot- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if some component of the plot does not support cloning.
-