|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.jrefinery.chart.Plot
com.jrefinery.chart.PiePlot
public class PiePlot
A plot that displays data in the form of a pie chart, using data from any class that implements the PieDataset interface.
Notes: (1) negative values in the dataset are ignored; (2) vertical axis and horizontal axis are set to null; (3) there are utility methods for creating a PieDataset from a CategoryDataset;
Plot,
PieDataset| Field Summary | |
|---|---|
protected boolean |
circular
Flag determining whether to draw an ellipse or a perfect circle. |
static double |
DEFAULT_INTERIOR_GAP
The default interior gap percent (currently 20%). |
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. |
protected double[] |
explodePercentages
The percentage amount to explode each pie section. |
protected double |
interiorGapPercent
The amount of space left around the outside of the pie plot, expressed as a percentage. |
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 |
PERCENT_LABELS
Constant indicating percent labels on the pie sections. |
protected java.text.DecimalFormat |
percentFormatter
|
protected double |
radiusPercent
The radius as a percentage of the available drawing area. |
protected java.awt.Font |
sectionLabelFont
The font used to display the section labels. |
protected double |
sectionLabelGapPercent
The gap between the labels and the pie sections, as a percentage of the radius. |
protected java.awt.Paint |
sectionLabelPaint
The color used to draw the section labels. |
protected int |
sectionLabelType
Label type (NO_LABELS, NAME_LABELS, PERCENT_LABELS, NAME_AND_PERCENT_LABELS). |
protected com.jrefinery.chart.tooltips.PieToolTipGenerator |
toolTipGenerator
The tool tip generator. |
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. |
protected java.text.DecimalFormat |
valueFormatter
|
| Fields inherited from class com.jrefinery.chart.Plot |
|---|
backgroundAlpha, backgroundImage, backgroundPaint, dataset, DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, firstSeriesIndex, foregroundAlpha, insets, listeners, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, outlinePaint, outlineStroke, seriesOutlinePaint, seriesOutlineStroke, seriesPaint, seriesStroke, shapeFactory, ZERO |
| Fields inherited from interface com.jrefinery.chart.AxisConstants |
|---|
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_STROKE |
| Constructor Summary | |
|---|---|
PiePlot(PieDataset data)
Constructs a new pie plot, using default attributes as required. |
|
PiePlot(PieDataset data,
java.awt.Insets insets,
java.awt.Paint backgroundPaint,
java.awt.Image backgroundImage,
float backgroundAlpha,
java.awt.Stroke outlineStroke,
java.awt.Paint outlinePaint,
float foregroundAlpha,
double interiorGapPercent,
boolean circular,
double radiusPercent,
int sectionLabelType,
java.awt.Font sectionLabelFont,
java.awt.Paint sectionLabelPaint,
double sectionLabelGapPercent,
java.lang.String valueFormatString,
java.lang.String percentFormatString,
com.jrefinery.chart.tooltips.PieToolTipGenerator tooltipGenerator)
Constructs a pie plot. |
|
| 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. |
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.util.Collection |
getCategories()
Returns a collection of the categories in the dataset. |
double |
getExplodePercent(int section)
Returns the amount that a section should be 'exploded'. |
double |
getInteriorGapPercent()
Returns the interior gap, measures as a percentage of the available drawing space. |
java.util.List |
getLegendItemLabels()
Returns a list of labels for the legend. |
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 |
getRadiusPercent()
Returns the radius percentage. |
java.awt.Font |
getSectionLabelFont()
Returns the section label font. |
double |
getSectionLabelGapPercent()
Returns the section label gap, measures as a percentage of the radius. |
java.awt.Paint |
getSectionLabelPaint()
Returns the section label paint. |
int |
getSectionLabelType()
Returns the section label type. |
com.jrefinery.chart.tooltips.PieToolTipGenerator |
getToolTipGenerator()
Returns the tooltip generator (possibly null). |
boolean |
isCircular()
Returns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape. |
boolean |
isCompatibleHorizontalAxis(Axis axis)
Returns true if the axis is compatible with the pie plot, and false otherwise. |
boolean |
isCompatibleVerticalAxis(Axis axis)
Returns true if the axis is compatible with the pie plot, and false otherwise. |
void |
setCircular(boolean flag)
A flag indicating whether the pie chart is circular, or stretched into an elliptical shape. |
void |
setExplodePercent(int section,
double percent)
Sets the amount that a pie section should be exploded. |
void |
setInteriorGapPercent(double percent)
Sets the interior gap percent. |
void |
setPercentFormatString(java.lang.String format)
Sets the format string for the percent labels. |
void |
setRadiusPercent(double percent)
Sets the radius percentage. |
void |
setSectionLabelFont(java.awt.Font font)
Sets the section label font. |
void |
setSectionLabelGapPercent(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 |
setToolTipGenerator(com.jrefinery.chart.tooltips.PieToolTipGenerator generator)
Sets the tooltip generator. |
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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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 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 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
protected double interiorGapPercent
protected boolean circular
protected double radiusPercent
protected int sectionLabelType
protected java.awt.Font sectionLabelFont
protected java.awt.Paint sectionLabelPaint
protected double sectionLabelGapPercent
protected double[] explodePercentages
protected java.text.DecimalFormat valueFormatter
protected java.text.DecimalFormat percentFormatter
protected com.jrefinery.chart.tooltips.PieToolTipGenerator toolTipGenerator
| Constructor Detail |
|---|
public PiePlot(PieDataset data)
data - The data.
public PiePlot(PieDataset data,
java.awt.Insets insets,
java.awt.Paint backgroundPaint,
java.awt.Image backgroundImage,
float backgroundAlpha,
java.awt.Stroke outlineStroke,
java.awt.Paint outlinePaint,
float foregroundAlpha,
double interiorGapPercent,
boolean circular,
double radiusPercent,
int sectionLabelType,
java.awt.Font sectionLabelFont,
java.awt.Paint sectionLabelPaint,
double sectionLabelGapPercent,
java.lang.String valueFormatString,
java.lang.String percentFormatString,
com.jrefinery.chart.tooltips.PieToolTipGenerator tooltipGenerator)
data - The data.insets - Amount of blank space around the plot area.backgroundPaint - An optional color for the plot's background.backgroundImage - An optional image for the plot's background.backgroundAlpha - Alpha-transparency for the plot's background.outlineStroke - The Stroke used to draw an outline around the plot.outlinePaint - The color used to draw an outline around the plot.foregroundAlpha - The alpha-transparency for the plot.interiorGapPercent - The interior gap (space for labels) as a percentage of the
available space.circular - Flag indicating whether the pie chart is circular or elliptical.radiusPercent - The radius of the pie chart, as a percentage of the available space
(after accounting for interior gap).sectionLabelFont - The font for the section labels.sectionLabelPaint - The color for the section labels.sectionLabelGapPercent - The space between the pie sections and the labels.| Method Detail |
|---|
public java.util.List getLegendItemLabels()
getLegendItemLabels in class Plotpublic double getInteriorGapPercent()
public void setInteriorGapPercent(double percent)
public boolean isCircular()
public void setCircular(boolean flag)
flag - The new value.public double getRadiusPercent()
public void setRadiusPercent(double percent)
percent - The new value.public int getSectionLabelType()
public void setSectionLabelType(int type)
Valid types are defined by the following constants: NO_LABELS, NAME_LABELS, PERCENT_LABELS, NAME_AND_PERCENT_LABELS.
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 getSectionLabelGapPercent()
public void setSectionLabelGapPercent(double percent)
public void setValueFormatString(java.lang.String format)
public void setPercentFormatString(java.lang.String format)
public double getExplodePercent(int section)
section - The section number.
public void setExplodePercent(int section,
double percent)
public PieDataset getPieDataset()
Provided for convenience.
public java.util.Collection getCategories()
public com.jrefinery.chart.tooltips.PieToolTipGenerator getToolTipGenerator()
public void setToolTipGenerator(com.jrefinery.chart.tooltips.PieToolTipGenerator generator)
generator - The new tooltip generator (null permitted).
public void draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info)
draw in class Plotg2 - 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)
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.section - The section (zero-based index).startAngle - The starting angle.extent - The extent of the arc.public java.lang.String getPlotType()
getPlotType in class Plotpublic boolean isCompatibleHorizontalAxis(Axis axis)
axis - The axis.public boolean isCompatibleVerticalAxis(Axis axis)
axis - The axis.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 Plotpercent - 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.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||