Package org.jfree.chart.plot
Class MultiplePiePlot
- java.lang.Object
-
- org.jfree.chart.plot.Plot
-
- org.jfree.chart.plot.MultiplePiePlot
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,AnnotationChangeListener
,AxisChangeListener
,MarkerChangeListener
,LegendItemSource
,PublicCloneable
,DatasetChangeListener
public class MultiplePiePlot extends Plot implements java.lang.Cloneable, java.io.Serializable
A plot that displays multiple pie plots using data from aCategoryDataset
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Comparable
aggregatedItemsKey
The key for the aggregated items.private java.awt.Paint
aggregatedItemsPaint
The paint for the aggregated items.private TableOrder
dataExtractOrder
The data extract order (by row or by column).private CategoryDataset
dataset
The dataset.private java.awt.Shape
legendItemShape
The legend item shape (never null).private double
limit
The pie section limit percentage.private JFreeChart
pieChart
The chart object that draws the individual pie charts.private java.util.Map
sectionPaints
The colors to use for each section.private static long
serialVersionUID
For serialization.-
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 MultiplePiePlot()
Creates a new plot with no data.MultiplePiePlot(CategoryDataset dataset)
Creates a new plot.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a clone of the plot.void
draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).boolean
equals(java.lang.Object obj)
Tests this plot for equality with an arbitrary object.java.lang.Comparable
getAggregatedItemsKey()
Returns the key for aggregated items in the pie plots, if there are any.java.awt.Paint
getAggregatedItemsPaint()
Returns the paint used to draw the pie section representing the aggregated items.TableOrder
getDataExtractOrder()
Returns the data extract order (by row or by column).CategoryDataset
getDataset()
Returns the dataset used by the plot.LegendItemCollection
getLegendItems()
Returns a collection of legend items for the pie chart.java.awt.Shape
getLegendItemShape()
Returns the shape used for legend items.double
getLimit()
Returns the limit (as a percentage) below which small pie sections are aggregated.JFreeChart
getPieChart()
Returns the pie chart that is used to draw the individual pie plots.java.lang.String
getPlotType()
Returns a short string describing the type of plot.private void
prefetchSectionPaints()
For each key in the dataset, check thesectionPaints
cache to see if a paint is associated with that key and, if not, fetch one from the drawing supplier.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setAggregatedItemsKey(java.lang.Comparable key)
Sets the key for aggregated items in the pie plots.void
setAggregatedItemsPaint(java.awt.Paint paint)
Sets the paint used to draw the pie section representing the aggregated items and sends aPlotChangeEvent
to all registered listeners.void
setDataExtractOrder(TableOrder order)
Sets the data extract order (by row or by column) and sends aPlotChangeEvent
to all registered listeners.void
setDataset(CategoryDataset dataset)
Sets the dataset used by the plot and sends aPlotChangeEvent
to all registered listeners.void
setLegendItemShape(java.awt.Shape shape)
Sets the shape used for legend items and sends aPlotChangeEvent
to all registered listeners.void
setLimit(double limit)
Sets the limit below which pie sections are aggregated.void
setPieChart(JFreeChart pieChart)
Sets the chart that is used to draw the individual pie plots.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
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, hashCode, 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
-
pieChart
private JFreeChart pieChart
The chart object that draws the individual pie charts.
-
dataset
private CategoryDataset dataset
The dataset.
-
dataExtractOrder
private TableOrder dataExtractOrder
The data extract order (by row or by column).
-
limit
private double limit
The pie section limit percentage.
-
aggregatedItemsKey
private java.lang.Comparable aggregatedItemsKey
The key for the aggregated items.
-
aggregatedItemsPaint
private transient java.awt.Paint aggregatedItemsPaint
The paint for the aggregated items.
-
sectionPaints
private transient java.util.Map sectionPaints
The colors to use for each section.
-
legendItemShape
private transient java.awt.Shape legendItemShape
The legend item shape (never null).
-
-
Constructor Detail
-
MultiplePiePlot
public MultiplePiePlot()
Creates a new plot with no data.
-
MultiplePiePlot
public MultiplePiePlot(CategoryDataset dataset)
Creates a new plot.- Parameters:
dataset
- the dataset (null
permitted).
-
-
Method Detail
-
getDataset
public CategoryDataset getDataset()
Returns the dataset used by the plot.- Returns:
- The dataset (possibly
null
).
-
setDataset
public void setDataset(CategoryDataset dataset)
Sets the dataset used by the plot and sends aPlotChangeEvent
to all registered listeners.- Parameters:
dataset
- the dataset (null
permitted).
-
getPieChart
public JFreeChart getPieChart()
Returns the pie chart that is used to draw the individual pie plots. Note that there are some attributes on this chart instance that will be ignored at rendering time (for example, legend item settings).- Returns:
- The pie chart (never
null
). - See Also:
setPieChart(JFreeChart)
-
setPieChart
public void setPieChart(JFreeChart pieChart)
Sets the chart that is used to draw the individual pie plots. The chart's plot must be an instance ofPiePlot
.- Parameters:
pieChart
- the pie chart (null
not permitted).- See Also:
getPieChart()
-
getDataExtractOrder
public TableOrder getDataExtractOrder()
Returns the data extract order (by row or by column).- Returns:
- The data extract order (never
null
).
-
setDataExtractOrder
public void setDataExtractOrder(TableOrder order)
Sets the data extract order (by row or by column) and sends aPlotChangeEvent
to all registered listeners.- Parameters:
order
- the order (null
not permitted).
-
getLimit
public double getLimit()
Returns the limit (as a percentage) below which small pie sections are aggregated.- Returns:
- The limit percentage.
-
setLimit
public void setLimit(double limit)
Sets the limit below which pie sections are aggregated. Set this to 0.0 if you don't want any aggregation to occur.- Parameters:
limit
- the limit percent.
-
getAggregatedItemsKey
public java.lang.Comparable getAggregatedItemsKey()
Returns the key for aggregated items in the pie plots, if there are any. The default value is "Other".- Returns:
- The aggregated items key.
-
setAggregatedItemsKey
public void setAggregatedItemsKey(java.lang.Comparable key)
Sets the key for aggregated items in the pie plots. You must ensure that this doesn't clash with any keys in the dataset.- Parameters:
key
- the key (null
not permitted).
-
getAggregatedItemsPaint
public java.awt.Paint getAggregatedItemsPaint()
Returns the paint used to draw the pie section representing the aggregated items. The default value is {code Color.LIGHT_GRAY}.- Returns:
- The paint.
-
setAggregatedItemsPaint
public void setAggregatedItemsPaint(java.awt.Paint paint)
Sets the paint used to draw the pie section representing the aggregated items and sends aPlotChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).
-
getPlotType
public java.lang.String getPlotType()
Returns a short string describing the type of plot.- Specified by:
getPlotType
in classPlot
- Returns:
- The plot type.
-
getLegendItemShape
public java.awt.Shape getLegendItemShape()
Returns the shape used for legend items.- Returns:
- The shape (never
null
). - See Also:
setLegendItemShape(Shape)
-
setLegendItemShape
public void setLegendItemShape(java.awt.Shape shape)
Sets the shape used for legend items and sends aPlotChangeEvent
to all registered listeners.- Parameters:
shape
- the shape (null
not permitted).- See Also:
getLegendItemShape()
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).
-
prefetchSectionPaints
private void prefetchSectionPaints()
For each key in the dataset, check thesectionPaints
cache to see if a paint is associated with that key and, if not, fetch one from the drawing supplier. These colors are cached so that the legend and all the subplots use consistent colors.
-
getLegendItems
public LegendItemCollection getLegendItems()
Returns a collection of legend items for the pie chart.- Specified by:
getLegendItems
in interfaceLegendItemSource
- Overrides:
getLegendItems
in classPlot
- Returns:
- The legend items.
-
equals
public boolean equals(java.lang.Object obj)
Tests this plot for equality with an arbitrary object. Note that the plot's dataset is not considered in the equality test.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the plot.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classPlot
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if some component of the plot does not support cloning.
-
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.
-
-