Package org.jfree.chart.labels
Class AbstractPieItemLabelGenerator
- java.lang.Object
-
- org.jfree.chart.labels.AbstractPieItemLabelGenerator
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
StandardPieSectionLabelGenerator
,StandardPieToolTipGenerator
public class AbstractPieItemLabelGenerator extends java.lang.Object implements java.io.Serializable
A base class used for generating pie chart item labels.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
labelFormat
The label format string.private java.text.NumberFormat
numberFormat
A number formatter for the value.private java.text.NumberFormat
percentFormat
A number formatter for the percentage.private static long
serialVersionUID
For serialization.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPieItemLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat numberFormat, java.text.NumberFormat percentFormat)
Creates an item label generator using the specified number formatters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns an independent copy of the generator.protected java.lang.Object[]
createItemArray(PieDataset dataset, java.lang.Comparable key)
Creates the array of items that can be passed to theMessageFormat
class for creating labels.boolean
equals(java.lang.Object obj)
Tests the generator for equality with an arbitrary object.protected java.lang.String
generateSectionLabel(PieDataset dataset, java.lang.Comparable key)
Generates a label for a pie section.java.lang.String
getLabelFormat()
Returns the label format string.java.text.NumberFormat
getNumberFormat()
Returns the number formatter.java.text.NumberFormat
getPercentFormat()
Returns the percent formatter.int
hashCode()
Returns a hash code for this instance.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
labelFormat
private final java.lang.String labelFormat
The label format string.
-
numberFormat
private java.text.NumberFormat numberFormat
A number formatter for the value.
-
percentFormat
private java.text.NumberFormat percentFormat
A number formatter for the percentage.
-
-
Constructor Detail
-
AbstractPieItemLabelGenerator
protected AbstractPieItemLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat numberFormat, java.text.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
-
getLabelFormat
public java.lang.String getLabelFormat()
Returns the label format string.- Returns:
- The label format string (never
null
).
-
getNumberFormat
public java.text.NumberFormat getNumberFormat()
Returns the number formatter.- Returns:
- The formatter (never
null
).
-
getPercentFormat
public java.text.NumberFormat getPercentFormat()
Returns the percent formatter.- Returns:
- The formatter (never
null
).
-
createItemArray
protected java.lang.Object[] createItemArray(PieDataset dataset, java.lang.Comparable key)
Creates the array of items that can be passed to theMessageFormat
class for creating labels. The returned array contains four values:- result[0] = the section key converted to a
String
; - result[1] = the formatted data value;
- result[2] = the formatted percentage (of the total);
- result[3] = the formatted total value.
- Parameters:
dataset
- the dataset (null
not permitted).key
- the key (null
not permitted).- Returns:
- The items (never
null
).
- result[0] = the section key converted to a
-
generateSectionLabel
protected java.lang.String generateSectionLabel(PieDataset dataset, java.lang.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
).
-
equals
public boolean equals(java.lang.Object obj)
Tests the generator for equality with an arbitrary object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to test against (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns an independent copy of the generator.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- should not happen.
-
-