public class StandardPieLabelGenerator extends java.lang.Object implements PieLabelGenerator, java.io.Serializable
PieLabelGenerator interface. The
implementation uses a Formatter instance to generate
the labels. Three values are passed to the formatter: (1) the key for
the current pie section, (2) the data value for the section (as a
Double, possibly null) and (3) the calculated
percentage value (as a Double, Double.NaN if the
value is null).
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_TEMPLATE
The default template string (used in the default constructor, it is
equivalent to
PERCENT_TEMPLATE). |
static java.lang.String |
KEY_ONLY_TEMPLATE
A template string that will show the section key only.
|
static java.lang.String |
PERCENT_TEMPLATE
A template string that will show the section key followed by the
percentage in brackets (with zero decimal places).
|
static java.lang.String |
PERCENT_TEMPLATE_2DP
A template string that will show the section key followed by the
percentage in brackets (with two decimal places precision).
|
static java.lang.String |
VALUE_TEMPLATE
A template string that will show the section key followed by the
value in brackets (with zero decimal places precision).
|
static java.lang.String |
VALUE_TEMPLATE_2DP
A template string that will show the section key followed by the
value in brackets (with two decimal places precision).
|
| Constructor and Description |
|---|
StandardPieLabelGenerator()
The default constructor, uses
DEFAULT_TEMPLATE for the
template string. |
StandardPieLabelGenerator(java.lang.String template)
Creates a new instance with the specified template string (which will
be passed to a
java.util.Formatter instance when generating
labels). |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Tests this label generator for equality with an arbitrary object.
|
java.lang.String |
generateLabel(PieDataset3D dataset,
java.lang.Comparable<?> key)
Generates the label for one section in a pie chart.
|
int |
hashCode() |
public static final java.lang.String KEY_ONLY_TEMPLATE
public static final java.lang.String PERCENT_TEMPLATE
public static final java.lang.String PERCENT_TEMPLATE_2DP
public static final java.lang.String VALUE_TEMPLATE
public static final java.lang.String VALUE_TEMPLATE_2DP
public static final java.lang.String DEFAULT_TEMPLATE
PERCENT_TEMPLATE).public StandardPieLabelGenerator()
DEFAULT_TEMPLATE for the
template string.public StandardPieLabelGenerator(java.lang.String template)
java.util.Formatter instance when generating
labels). See the class description for an explanation of the values
that are available for use in the template string.template - the template (null not permitted).public java.lang.String generateLabel(PieDataset3D dataset, java.lang.Comparable<?> key)
generateLabel in interface PieLabelGeneratordataset - the dataset (null not permitted).key - the key (null not permitted).null for this implementation).public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object (null permitted).public int hashCode()
hashCode in class java.lang.Object