Package org.jfree.chart.labels
Class StandardPieItemLabelGenerator
java.lang.Object
org.jfree.chart.labels.StandardPieItemLabelGenerator
- All Implemented Interfaces:
Serializable,Cloneable,PieSectionLabelGenerator,PieToolTipGenerator
public class StandardPieItemLabelGenerator extends Object implements PieToolTipGenerator, PieSectionLabelGenerator, Cloneable, Serializable
A standard item label generator for plots that use data from a
PieDataset.
For the label format, use {0} where the pie section key should be inserted,
{1} for the absolute section value and {2} for the percent amount of the pie
section, e.g. "{0} = {1} ({2})" will display as
apple = 120 (5%).
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_SECTION_LABEL_FORMATThe default section label format.static StringDEFAULT_TOOLTIP_FORMATThe default tooltip format. -
Constructor Summary
Constructors Constructor Description StandardPieItemLabelGenerator()Creates an item label generator using default number formatters.StandardPieItemLabelGenerator(String labelFormat)Creates an item label generator.StandardPieItemLabelGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat)Creates an item label generator using the specified number formatters. -
Method Summary
Modifier and Type Method Description Objectclone()Returns an independent copy of the generator.booleanequals(Object obj)Tests the generator for equality with an arbitrary object.StringgenerateSectionLabel(PieDataset dataset, Comparable key)Generates a label for a pie section.StringgenerateToolTip(PieDataset dataset, Comparable key)Generates a tool tip text item for one section in a pie chart.NumberFormatgetNumberFormat()Returns the number formatter.NumberFormatgetPercentFormat()Returns the percent formatter.
-
Field Details
-
DEFAULT_TOOLTIP_FORMAT
The default tooltip format.- See Also:
- Constant Field Values
-
DEFAULT_SECTION_LABEL_FORMAT
The default section label format.- See Also:
- Constant Field Values
-
-
Constructor Details
-
StandardPieItemLabelGenerator
public StandardPieItemLabelGenerator()Creates an item label generator using default number formatters. -
StandardPieItemLabelGenerator
Creates an item label generator.- Parameters:
labelFormat- the label format.
-
StandardPieItemLabelGenerator
public StandardPieItemLabelGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat)Creates an item label generator using the specified number formatters.- Parameters:
labelFormat- the label format string (nullnot permitted).numberFormat- the format object for the values (nullnot permitted).percentFormat- the format object for the percentages (nullnot permitted).
-
-
Method Details
-
getNumberFormat
Returns the number formatter.- Returns:
- The formatter (never
null).
-
getPercentFormat
Returns the percent formatter.- Returns:
- The formatter (never
null).
-
generateSectionLabel
Generates a label for a pie section.- Specified by:
generateSectionLabelin interfacePieSectionLabelGenerator- Parameters:
dataset- the dataset (nullnot permitted).key- the section key (nullnot permitted).- Returns:
- The label (possibly
null).
-
generateToolTip
Generates a tool tip text item for one section in a pie chart.- Specified by:
generateToolTipin interfacePieToolTipGenerator- Parameters:
dataset- the dataset (nullnot permitted).key- the section key (nullnot permitted).- Returns:
- The tool tip text (possibly
null).
-
equals
Tests the generator for equality with an arbitrary object. -
clone
Returns an independent copy of the generator.- Returns:
- A clone.
- Throws:
CloneNotSupportedException- should not happen.
-