|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jfree.chart.plot.Plot | +--org.jfree.chart.plot.PiePlot
A plot that displays data in the form of a pie chart, using data from any class that implements
the PieDataset
interface.
Special notes:
PieDataset
from a
CategoryDataset
Plot
,
PieDataset
,
Serialized FormField Summary | |
static int |
ANTICLOCKWISE
A constant representing the anti-clockwise direction. |
static int |
CLOCKWISE
A constant indicating the clockwise direction. |
static int |
DEFAULT_DIRECTION
The default direction for the pie chart. |
static double |
DEFAULT_INTERIOR_GAP
The default interior gap. |
static double |
DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW
The default minimum arc angle to draw. |
static java.text.NumberFormat |
DEFAULT_PERCENT_FORMATTER
The default percent label formatter. |
static double |
DEFAULT_RADIUS
The default radius percent (currently 100%). |
static java.awt.Font |
DEFAULT_SECTION_LABEL_FONT
The default section label font. |
static double |
DEFAULT_SECTION_LABEL_GAP
The default section label gap (currently 10%). |
static java.awt.Paint |
DEFAULT_SECTION_LABEL_PAINT
The default section label paint. |
static int |
DEFAULT_SECTION_LABEL_TYPE
The default section label type. |
static java.awt.Font |
DEFAULT_SERIES_LABEL_FONT
The default series label font. |
static java.awt.Paint |
DEFAULT_SERIES_LABEL_PAINT
The default series label paint. |
static boolean |
DEFAULT_SHOW_SERIES_LABELS
The default for the show series labels flag |
static double |
DEFAULT_START_ANGLE
The default starting angle for the pie chart. |
static java.text.NumberFormat |
DEFAULT_VALUE_FORMATTER
The default value label formatter. |
static double |
MAX_INTERIOR_GAP
The maximum interior gap (currently 40%). |
static double |
MAX_RADIUS
The maximum radius (currently 100%). |
static double |
MAX_SECTION_LABEL_GAP
The maximum interior gap (currently 30%). |
static int |
NAME_AND_PERCENT_LABELS
Constant indicating percent labels on the pie sections. |
static int |
NAME_AND_VALUE_LABELS
Constant indicating percent labels on the pie sections. |
static int |
NAME_LABELS
Constant indicating name labels on the pie sections. |
static int |
NO_LABELS
Constant indicating no labels on the pie sections. |
static int |
PER_COLUMN
A useful constant for multiple pie charts. |
static int |
PER_ROW
A useful constant for multiple pie charts. |
static int |
PERCENT_LABELS
Constant indicating percent labels on the pie sections. |
static int |
VALUE_AND_PERCENT_LABELS
Constant indicating percent labels on the pie sections. |
static int |
VALUE_LABELS
Constant indicating value labels on the pie sections. |
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 | |
PiePlot(CategoryDataset data,
int type)
Creates a new plot that will draw multiple pie charts, one for each row or column (as requested) in the dataset. |
|
PiePlot(PieDataset data)
Creates a pie chart. |
Method Summary | |
protected java.awt.geom.Point2D |
calculateLabelLocation(java.awt.geom.Rectangle2D labelBounds,
double ascent,
java.awt.geom.Rectangle2D unexploded,
java.awt.geom.Rectangle2D exploded,
double startAngle,
double extent,
double explodePercent)
Returns the location for a label, taking into account whether or not the pie section is exploded. |
void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer). |
protected void |
drawLabel(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D pieArea,
java.awt.geom.Rectangle2D explodedPieArea,
PieDataset data,
double value,
int section,
double startAngle,
double extent)
Draws the label for one pie section. |
boolean |
equals(java.lang.Object obj)
Tests this plot for equality with another object. |
protected java.awt.geom.Rectangle2D |
getArcBounds(java.awt.geom.Rectangle2D unexploded,
java.awt.geom.Rectangle2D exploded,
double startAngle,
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'). |
java.awt.Paint |
getDefaultOutlinePaint()
Returns the default outline paint. |
java.awt.Stroke |
getDefaultOutlineStroke()
Returns the default outline stroke. |
java.awt.Paint |
getDefaultPaint()
Returns the default paint. |
int |
getDirection()
Returns the direction in which the pie sections are drawn (clockwise or anti-clockwise). |
double |
getExplodePercent(int section)
Returns the amount that a section should be 'exploded'. |
double |
getInteriorGap()
Returns the interior gap, measured as a percentage of the available drawing space. |
java.util.Collection |
getKeys()
Returns a collection of the categories in the dataset. |
LegendItemCollection |
getLegendItems()
Returns a collection of legend items for the pie chart. |
double |
getMinimumArcAngleToDraw()
Returns the minimum arc angle that will be drawn. |
java.awt.Paint |
getOutlinePaint(int section)
Returns the paint used to outline a section of the pie plot. |
java.awt.Stroke |
getOutlineStroke(int section)
Returns the stroke used to outline a section of the pie plot. |
java.awt.Paint |
getPaint(int section)
Returns the paint used to fill a section of the pie plot. |
PieDataset |
getPieDataset()
Returns the dataset for the plot, cast as a PieDataset . |
java.lang.String |
getPlotType()
Returns a short string describing the type of plot. |
double |
getRadius()
Returns the radius (a percentage of the available space). |
java.awt.Font |
getSectionLabelFont()
Returns the section label font. |
double |
getSectionLabelGap()
Returns the section label gap, measured as a percentage of the radius. |
java.awt.Paint |
getSectionLabelPaint()
Returns the section label paint. |
int |
getSectionLabelType()
Returns the section label type. |
java.awt.Font |
getSeriesLabelFont()
Returns the series label font. |
java.awt.Paint |
getSeriesLabelPaint()
Returns the series label paint. |
boolean |
getShowSeriesLabels()
Returns the show series labels flag. |
double |
getStartAngle()
Returns the start angle for the first pie section. |
PieToolTipGenerator |
getToolTipGenerator()
Returns the tooltip generator (possibly null). |
PieURLGenerator |
getURLGenerator()
Returns the URL generator (possibly null). |
boolean |
isCircular()
Returns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape. |
boolean |
isOutlinePaintTableActive()
Returns true if the lookup table for outline paint objects is being used, and
false otherwise. |
boolean |
isOutlineStrokeTableActive()
Returns true if the lookup table for outline stroke objects is being used, and
false otherwise. |
boolean |
isPaintTableActive()
Returns true if the lookup table for paint objects is being used, and
false otherwise. |
void |
setCircular(boolean flag)
A flag indicating whether the pie chart is circular, or stretched into an elliptical shape. |
protected void |
setCircularAttribute(boolean circular)
Sets the circular attribute, with no side effects. |
void |
setDefaultOutlinePaint(java.awt.Paint paint)
Sets the default outline paint. |
void |
setDefaultOutlineStroke(java.awt.Stroke stroke)
Sets the default outline stroke. |
void |
setDefaultPaint(java.awt.Paint paint)
Sets the default paint. |
void |
setDirection(int direction)
Sets the direction (use the constants CLOCKWISE or ANTICLOCKWISE). |
void |
setExplodePercent(int section,
double percent)
Sets the amount that a pie section should be exploded. |
void |
setInteriorGap(double percent)
Sets the interior gap. |
void |
setMinimumArcAngleToDraw(double angle)
Sets the minimum arc angle that will be drawn. |
void |
setOutlinePaint(int section,
java.awt.Paint paint)
Sets the paint used to outline a section of the pie. |
void |
setOutlinePaintTableActive(boolean active)
Sets a flag that controls whether or not the paint table is active. |
void |
setOutlineStroke(int section,
java.awt.Stroke stroke)
Sets the stroke used to outline a section of the pie. |
void |
setOutlineStrokeTableActive(boolean active)
Sets a flag that controls whether or not the outline stroke table is active. |
void |
setPaint(int section,
java.awt.Paint paint)
Sets the paint used to fill a section of the pie. |
void |
setPaintTableActive(boolean active)
Sets a flag that controls whether or not the paint table is active. |
void |
setPercentFormat(java.text.NumberFormat format)
Sets the format for the value labels. |
void |
setPercentFormatString(java.lang.String format)
Sets the format string for the percent labels. |
void |
setRadius(double percent)
Sets the radius. |
void |
setSectionLabelFont(java.awt.Font font)
Sets the section label font. |
void |
setSectionLabelGap(double percent)
Sets the section label gap percent. |
void |
setSectionLabelPaint(java.awt.Paint paint)
Sets the section label paint. |
void |
setSectionLabelType(int type)
Sets the section label type. |
void |
setSeriesLabelFont(java.awt.Font font)
Sets the series label font. |
void |
setSeriesLabelPaint(java.awt.Paint paint)
Sets the series label paint. |
void |
setShowSeriesLabels(boolean flag)
Sets the show series labels flag. |
void |
setStartAngle(double angle)
Sets the starting angle. |
void |
setToolTipGenerator(PieToolTipGenerator generator)
Sets the tool tip generator. |
void |
setURLGenerator(PieURLGenerator generator)
Sets the URL generator. |
void |
setValueFormat(java.text.NumberFormat format)
Sets the format for the value labels. |
void |
setValueFormatString(java.lang.String format)
Sets the format string for the value labels. |
void |
zoom(double percent)
A zoom method that does nothing. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int CLOCKWISE
public static final int ANTICLOCKWISE
public static final int NO_LABELS
public static final int NAME_LABELS
public static final int VALUE_LABELS
public static final int PERCENT_LABELS
public static final int NAME_AND_VALUE_LABELS
public static final int NAME_AND_PERCENT_LABELS
public static final int VALUE_AND_PERCENT_LABELS
public static final int PER_ROW
public static final int PER_COLUMN
public static final double DEFAULT_INTERIOR_GAP
public static final double MAX_INTERIOR_GAP
public static final double DEFAULT_RADIUS
public static final double MAX_RADIUS
public static final double DEFAULT_START_ANGLE
public static final int DEFAULT_DIRECTION
public static final int DEFAULT_SECTION_LABEL_TYPE
public static final java.awt.Font DEFAULT_SECTION_LABEL_FONT
public static final java.awt.Paint DEFAULT_SECTION_LABEL_PAINT
public static final double DEFAULT_SECTION_LABEL_GAP
public static final double MAX_SECTION_LABEL_GAP
public static final java.text.NumberFormat DEFAULT_VALUE_FORMATTER
public static final java.text.NumberFormat DEFAULT_PERCENT_FORMATTER
public static final java.awt.Font DEFAULT_SERIES_LABEL_FONT
public static final java.awt.Paint DEFAULT_SERIES_LABEL_PAINT
public static final boolean DEFAULT_SHOW_SERIES_LABELS
public static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW
Constructor Detail |
public PiePlot(PieDataset data)
data
- the data.public PiePlot(CategoryDataset data, int type)
data
- the data.type
- controls how pie data is extracted (PER_ROW or PER_COLUMN).Method Detail |
public double getStartAngle()
This is measured in degrees starting from 3 o'clock and measuring anti-clockwise.
public void setStartAngle(double angle)
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.
angle
- the angle (in degrees).public int getDirection()
public void setDirection(int direction)
direction
- the new direction.public double getInteriorGap()
public void setInteriorGap(double percent)
percent
- The gap.public boolean isCircular()
public void setCircular(boolean flag)
flag
- the new value.protected void setCircularAttribute(boolean circular)
circular
- the new value of the flag.public double getRadius()
public void setRadius(double percent)
percent
- the new value.public double getExplodePercent(int section)
section
- the section number.
public void setExplodePercent(int section, double percent)
section
- the section index.percent
- the amount to explode the section as a percentage.public int getSectionLabelType()
public void setSectionLabelType(int type)
Valid types are defined by the following constants: NO_LABELS, NAME_LABELS, VALUE_LABELS, PERCENT_LABELS, NAME_AND_VALUE_LABELS, NAME_AND_PERCENT_LABELS, VALUE_AND_PERCENT_LABELS.
type
- the type.public java.awt.Font getSectionLabelFont()
public void setSectionLabelFont(java.awt.Font font)
Notifies registered listeners that the plot has been changed.
font
- the new section label font.public java.awt.Paint getSectionLabelPaint()
public void setSectionLabelPaint(java.awt.Paint paint)
Notifies registered listeners that the plot has been changed.
paint
- the new section label paint.public double getSectionLabelGap()
public void setSectionLabelGap(double percent)
percent
- the gap.public void setValueFormatString(java.lang.String format)
format
- The format.public void setValueFormat(java.text.NumberFormat format)
format
- the format.public void setPercentFormatString(java.lang.String format)
format
- the format.public void setPercentFormat(java.text.NumberFormat format)
format
- the format.public PieDataset getPieDataset()
PieDataset
.
Provided for convenience.
PieDataset
.public boolean getShowSeriesLabels()
public void setShowSeriesLabels(boolean flag)
Notifies registered listeners that the plot has been changed.
flag
- the new show series labels flag.public java.awt.Font getSeriesLabelFont()
public void setSeriesLabelFont(java.awt.Font font)
Notifies registered listeners that the plot has been changed.
font
- the new series label font.public java.awt.Paint getSeriesLabelPaint()
public void setSeriesLabelPaint(java.awt.Paint paint)
Notifies registered listeners that the plot has been changed.
paint
- the new series label paint.
public java.util.Collection getKeys()
public boolean isPaintTableActive()
true
if the lookup table for paint objects is being used, and
false
otherwise.
true
or false.public void setPaintTableActive(boolean active)
Except in very special circumstances, you will probably want to leave this flag at
the default value of true
.
active
- the new value of the flag.public java.awt.Paint getPaint(int section)
section
- the section index (zero-based).
public void setPaint(int section, java.awt.Paint paint)
section
- the section index (zero-based).paint
- the paint.public java.awt.Paint getDefaultPaint()
public void setDefaultPaint(java.awt.Paint paint)
paint
- the paint.public boolean isOutlinePaintTableActive()
true
if the lookup table for outline paint objects is being used, and
false
otherwise.
true
or false.public void setOutlinePaintTableActive(boolean active)
Except in very special circumstances, you will probably want to leave this flag at
the default value of true
.
active
- the new value of the flag.public java.awt.Paint getOutlinePaint(int section)
section
- the section index (zero-based).
public void setOutlinePaint(int section, java.awt.Paint paint)
section
- the section index (zero-based).paint
- the paint.public java.awt.Paint getDefaultOutlinePaint()
public void setDefaultOutlinePaint(java.awt.Paint paint)
paint
- the paint.public boolean isOutlineStrokeTableActive()
true
if the lookup table for outline stroke objects is being used, and
false
otherwise.
true
or false.public void setOutlineStrokeTableActive(boolean active)
active
- the new value of the flag.public java.awt.Stroke getOutlineStroke(int section)
section
- the section index (zero-based).
public void setOutlineStroke(int section, java.awt.Stroke stroke)
section
- the section index (zero-based).stroke
- the stroke.public java.awt.Stroke getDefaultOutlineStroke()
public void setDefaultOutlineStroke(java.awt.Stroke stroke)
stroke
- the stroke.public double getMinimumArcAngleToDraw()
public void setMinimumArcAngleToDraw(double angle)
angle
- the minimum angle.public LegendItemCollection getLegendItems()
getLegendItems
in class Plot
public PieToolTipGenerator getToolTipGenerator()
public void setToolTipGenerator(PieToolTipGenerator generator)
If you set the generator to null, no tool tips will be generated for the pie chart.
generator
- the new tooltip generator (null permitted).public PieURLGenerator getURLGenerator()
public void setURLGenerator(PieURLGenerator generator)
generator
- the new URL generator (null permitted).public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, ChartRenderingInfo info)
draw
in class Plot
g2
- the graphics device.plotArea
- the area within which the plot should be drawn.info
- collects info about the drawing.protected void drawLabel(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D pieArea, java.awt.geom.Rectangle2D explodedPieArea, PieDataset data, double value, int section, double startAngle, double extent)
You can control the label type using the setSectionLabelType()
method.
g2
- the graphics device.pieArea
- the area for the unexploded pie sections.explodedPieArea
- the area for the exploded pie section.data
- the data for the plot.value
- the value of the label.section
- the section (zero-based index).startAngle
- the starting angle.extent
- the extent of the arc.public java.lang.String getPlotType()
getPlotType
in class Plot
public void zoom(double percent)
Plots are required to support the zoom operation. In the case of a pie chart, it doesn't make sense to zoom in or out, so the method is empty.
zoom
in class Plot
percent
- the zoom percentage.protected java.awt.geom.Rectangle2D getArcBounds(java.awt.geom.Rectangle2D unexploded, java.awt.geom.Rectangle2D exploded, double startAngle, double extent, double explodePercent)
unexploded
- the area inside which the unexploded pie sections are drawn.exploded
- the area inside which the exploded pie sections are drawn.startAngle
- the start angle.extent
- the extent of the arc.explodePercent
- the amount by which the pie section is exploded.
protected java.awt.geom.Point2D calculateLabelLocation(java.awt.geom.Rectangle2D labelBounds, double ascent, java.awt.geom.Rectangle2D unexploded, java.awt.geom.Rectangle2D exploded, double startAngle, double extent, double explodePercent)
labelBounds
- the label bounds.ascent
- the ascent.unexploded
- the area within which the unexploded pie sections are drawn.exploded
- the area within which the exploded pie sections are drawn.startAngle
- the start angle for the pie section.extent
- the extent of the arc.explodePercent
- the amount by which the pie section is exploded.
public boolean equals(java.lang.Object obj)
equals
in class Plot
obj
- the other object.
true
or false
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |