- java.lang.Object
-
- org.jfree.chart.labels.AbstractPieItemLabelGenerator
-
- org.jfree.chart.labels.StandardPieSectionLabelGenerator
-
- All Implemented Interfaces:
Serializable,Cloneable,PublicCloneable,PieSectionLabelGenerator
public class StandardPieSectionLabelGenerator extends AbstractPieItemLabelGenerator implements PieSectionLabelGenerator, Cloneable, PublicCloneable, Serializable
A standard item label generator for plots that use data from aPieDataset.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 asapple = 120 (5%).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_SECTION_LABEL_FORMATThe default section label format.
-
Constructor Summary
Constructors Constructor Description StandardPieSectionLabelGenerator()Creates a new section label generator usingDEFAULT_SECTION_LABEL_FORMATas the label format string, and platform default number and percentage formatters.StandardPieSectionLabelGenerator(String labelFormat)Creates a new section label generator using the specified label format string, and platform default number and percentage formatters.StandardPieSectionLabelGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat)Creates an item label generator using the specified number formatters.StandardPieSectionLabelGenerator(String labelFormat, Locale locale)Creates a new instance for the specified locale.StandardPieSectionLabelGenerator(Locale locale)Creates a new instance for the specified locale.
-
Method Summary
All Methods Instance Methods Concrete Methods 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.AttributedStringgenerateAttributedSectionLabel(PieDataset dataset, Comparable key)Generates an attributed label for the specified series, ornullif no attributed label is available (in which case, the string returned bygenerateSectionLabel(PieDataset, Comparable)will provide the fallback).StringgenerateSectionLabel(PieDataset dataset, Comparable key)Generates a label for a pie section.AttributedStringgetAttributedLabel(int section)Returns the attributed label for a section, ornullif none is defined.inthashCode()Returns a hash code for this instance.voidsetAttributedLabel(int section, AttributedString label)Sets the attributed label for a section.-
Methods inherited from class org.jfree.chart.labels.AbstractPieItemLabelGenerator
createItemArray, getLabelFormat, getNumberFormat, getPercentFormat
-
-
-
-
Field Detail
-
DEFAULT_SECTION_LABEL_FORMAT
public static final String DEFAULT_SECTION_LABEL_FORMAT
The default section label format.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator()
Creates a new section label generator usingDEFAULT_SECTION_LABEL_FORMATas the label format string, and platform default number and percentage formatters.
-
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator(Locale locale)
Creates a new instance for the specified locale.- Parameters:
locale- the local (nullnot permitted).
-
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator(String labelFormat)
Creates a new section label generator using the specified label format string, and platform default number and percentage formatters.- Parameters:
labelFormat- the label format (nullnot permitted).
-
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator(String labelFormat, Locale locale)
Creates a new instance for the specified locale.- Parameters:
labelFormat- the label format (nullnot permitted).locale- the local (nullnot permitted).
-
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator(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 Detail
-
getAttributedLabel
public AttributedString getAttributedLabel(int section)
Returns the attributed label for a section, ornullif none is defined.- Parameters:
section- the section index.- Returns:
- The attributed label.
-
setAttributedLabel
public void setAttributedLabel(int section, AttributedString label)
Sets the attributed label for a section.- Parameters:
section- the section index.label- the label (nullpermitted).
-
generateSectionLabel
public String generateSectionLabel(PieDataset dataset, Comparable key)
Generates a label for a pie section.- Specified by:
generateSectionLabelin interfacePieSectionLabelGenerator- Overrides:
generateSectionLabelin classAbstractPieItemLabelGenerator- Parameters:
dataset- the dataset (nullnot permitted).key- the section key (nullnot permitted).- Returns:
- The label (possibly
null).
-
generateAttributedSectionLabel
public AttributedString generateAttributedSectionLabel(PieDataset dataset, Comparable key)
Generates an attributed label for the specified series, ornullif no attributed label is available (in which case, the string returned bygenerateSectionLabel(PieDataset, Comparable)will provide the fallback). Only certain attributes are recognised by the code that ultimately displays the labels:TextAttribute.FONT: will set the font;TextAttribute.POSTURE: a value ofTextAttribute.POSTURE_OBLIQUEwill addFont.ITALICto the current font;TextAttribute.WEIGHT: a value ofTextAttribute.WEIGHT_BOLDwill addFont.BOLDto the current font;TextAttribute.FOREGROUND: this will set thePaintfor the currentTextAttribute.SUPERSCRIPT: the valuesTextAttribute.SUPERSCRIPT_SUBandTextAttribute.SUPERSCRIPT_SUPERare recognised.
- Specified by:
generateAttributedSectionLabelin interfacePieSectionLabelGenerator- Parameters:
dataset- the dataset (nullnot permitted).key- the key.- Returns:
- An attributed label (possibly
null).
-
equals
public boolean equals(Object obj)
Tests the generator for equality with an arbitrary object.- Overrides:
equalsin classAbstractPieItemLabelGenerator- Parameters:
obj- the object to test against (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Description copied from class:AbstractPieItemLabelGeneratorReturns a hash code for this instance.- Overrides:
hashCodein classAbstractPieItemLabelGenerator- Returns:
- A hash code.
-
clone
public Object clone() throws CloneNotSupportedException
Returns an independent copy of the generator.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractPieItemLabelGenerator- Returns:
- A clone.
- Throws:
CloneNotSupportedException- should not happen.
-
-