org.jfree.chart.labels

Class StandardPieSectionLabelGenerator

public class StandardPieSectionLabelGenerator extends AbstractPieItemLabelGenerator implements 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%).

Field Summary
static StringDEFAULT_SECTION_LABEL_FORMAT
The default section label format.
Constructor Summary
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(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.
Method Summary
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, or null if no attributed label is available (in which case, the string returned by StandardPieSectionLabelGenerator 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, or null if none is defined.
voidsetAttributedLabel(int section, AttributedString label)
Sets the attributed label for a section.

Field Detail

DEFAULT_SECTION_LABEL_FORMAT

public static final String DEFAULT_SECTION_LABEL_FORMAT
The default section label format.

Constructor Detail

StandardPieSectionLabelGenerator

public 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

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 (null not 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 (null not permitted). numberFormat the format object for the values (null not permitted). percentFormat the format object for the percentages (null not permitted).

Method Detail

clone

public Object clone()
Returns an independent copy of the generator.

Returns: A clone.

Throws: CloneNotSupportedException should not happen.

equals

public boolean equals(Object obj)
Tests the generator for equality with an arbitrary object.

Parameters: obj the object to test against (null permitted).

Returns: A boolean.

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 StandardPieSectionLabelGenerator will provide the fallback). Only certain attributes are recognised by the code that ultimately displays the labels:

Parameters: dataset the dataset (null not permitted). key the key.

Returns: An attributed label (possibly null).

generateSectionLabel

public String generateSectionLabel(PieDataset dataset, Comparable key)
Generates a label for a pie section.

Parameters: dataset the dataset (null not permitted). key the section key (null not permitted).

Returns: The label (possibly null).

getAttributedLabel

public AttributedString getAttributedLabel(int section)
Returns the attributed label for a section, or null if 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 (null permitted).