public class StandardPieSectionLabelGenerator extends AbstractPieItemLabelGenerator implements PieSectionLabelGenerator, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable
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%)
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_SECTION_LABEL_FORMAT
The default section label format.
|
Constructor and Description |
---|
StandardPieSectionLabelGenerator()
Creates a new section label generator using
DEFAULT_SECTION_LABEL_FORMAT as the label format string, and
platform default number and percentage formatters. |
StandardPieSectionLabelGenerator(java.util.Locale locale)
Creates a new instance for the specified locale.
|
StandardPieSectionLabelGenerator(java.lang.String labelFormat)
Creates a new section label generator using the specified label format
string, and platform default number and percentage formatters.
|
StandardPieSectionLabelGenerator(java.lang.String labelFormat,
java.util.Locale locale)
Creates a new instance for the specified locale.
|
StandardPieSectionLabelGenerator(java.lang.String labelFormat,
java.text.NumberFormat numberFormat,
java.text.NumberFormat percentFormat)
Creates an item label generator using the specified number formatters.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns an independent copy of the generator.
|
boolean |
equals(java.lang.Object obj)
Tests the generator for equality with an arbitrary object.
|
java.text.AttributedString |
generateAttributedSectionLabel(PieDataset dataset,
java.lang.Comparable key)
Generates an attributed label for the specified series, or
null if no attributed label is available (in which case,
the string returned by
generateSectionLabel(PieDataset, Comparable) will
provide the fallback). |
java.lang.String |
generateSectionLabel(PieDataset dataset,
java.lang.Comparable key)
Generates a label for a pie section.
|
java.text.AttributedString |
getAttributedLabel(int section)
Returns the attributed label for a section, or
null if none
is defined. |
void |
setAttributedLabel(int section,
java.text.AttributedString label)
Sets the attributed label for a section.
|
createItemArray, getLabelFormat, getNumberFormat, getPercentFormat, hashCode
public static final java.lang.String DEFAULT_SECTION_LABEL_FORMAT
public StandardPieSectionLabelGenerator()
DEFAULT_SECTION_LABEL_FORMAT
as the label format string, and
platform default number and percentage formatters.public StandardPieSectionLabelGenerator(java.util.Locale locale)
locale
- the local (null
not permitted).public StandardPieSectionLabelGenerator(java.lang.String labelFormat)
labelFormat
- the label format (null
not permitted).public StandardPieSectionLabelGenerator(java.lang.String labelFormat, java.util.Locale locale)
labelFormat
- the label format (null
not permitted).locale
- the local (null
not permitted).public StandardPieSectionLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat numberFormat, java.text.NumberFormat percentFormat)
labelFormat
- the label format string (null
not
permitted).numberFormat
- the format object for the values (null
not permitted).percentFormat
- the format object for the percentages
(null
not permitted).public java.text.AttributedString getAttributedLabel(int section)
null
if none
is defined.section
- the section index.public void setAttributedLabel(int section, java.text.AttributedString label)
section
- the section index.label
- the label (null
permitted).public java.lang.String generateSectionLabel(PieDataset dataset, java.lang.Comparable key)
generateSectionLabel
in interface PieSectionLabelGenerator
generateSectionLabel
in class AbstractPieItemLabelGenerator
dataset
- the dataset (null
not permitted).key
- the section key (null
not permitted).null
).public java.text.AttributedString generateAttributedSectionLabel(PieDataset dataset, java.lang.Comparable key)
null
if no attributed label is available (in which case,
the string returned by
generateSectionLabel(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 of
TextAttribute.POSTURE_OBLIQUE
will add Font.ITALIC
to
the current font;TextAttribute.WEIGHT
: a value of
TextAttribute.WEIGHT_BOLD
will add Font.BOLD
to the
current font;TextAttribute.FOREGROUND
: this will set the Paint
for the currentTextAttribute.SUPERSCRIPT
: the values
TextAttribute.SUPERSCRIPT_SUB
and
TextAttribute.SUPERSCRIPT_SUPER
are recognised.generateAttributedSectionLabel
in interface PieSectionLabelGenerator
dataset
- the dataset (null
not permitted).key
- the key.null
).public boolean equals(java.lang.Object obj)
equals
in class AbstractPieItemLabelGenerator
obj
- the object to test against (null
permitted).public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface org.jfree.util.PublicCloneable
clone
in class AbstractPieItemLabelGenerator
java.lang.CloneNotSupportedException
- should not happen.