org.jfree.chart.labels
Class StandardPieSectionLabelGenerator
- Cloneable, PieSectionLabelGenerator, 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%)
.
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator(String labelFormat)
Creates a new section label generator using the specified label format
string, and platform default number and percentage formatters.
labelFormat
- the label format (null
not permitted).
StandardPieSectionLabelGenerator
public StandardPieSectionLabelGenerator(String labelFormat,
NumberFormat numberFormat,
NumberFormat percentFormat)
Creates an item label generator using the specified number formatters.
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).
generateAttributedSectionLabel
public AttributedString generateAttributedSectionLabel(PieDataset dataset,
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). 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.
- An attributed label (possibly
null
).
getAttributedLabel
public AttributedString getAttributedLabel(int section)
Returns the attributed label for a section, or null
if none
is defined.
section
- the section index.
setAttributedLabel
public void setAttributedLabel(int section,
AttributedString label)
Sets the attributed label for a section.
section
- the section index.label
- the label (null
permitted).