Package org.jfree.chart.labels
Class AbstractCategoryItemLabelGenerator
- java.lang.Object
-
- org.jfree.chart.labels.AbstractCategoryItemLabelGenerator
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,PublicCloneable
- Direct Known Subclasses:
StandardCategoryItemLabelGenerator
,StandardCategoryToolTipGenerator
public abstract class AbstractCategoryItemLabelGenerator extends java.lang.Object implements PublicCloneable, java.lang.Cloneable, java.io.Serializable
A base class that can be used to create a label or tooltip generator that can be assigned to aCategoryItemRenderer
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.text.DateFormat
dateFormat
A date formatter used to preformat the value before it is passed to the MessageFormat object.private java.lang.String
labelFormat
The label format string used by aMessageFormat
object to combine the standard items: {0} = series name, {1} = category, {2} = value, {3} = value as a percentage of the column total.private java.lang.String
nullValueString
The string used to represent a null value.private java.text.NumberFormat
numberFormat
A number formatter used to preformat the value before it is passed to the MessageFormat object.private java.text.NumberFormat
percentFormat
A number formatter used to preformat the percentage value before it is passed to the MessageFormat object.private static long
serialVersionUID
For serialization.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCategoryItemLabelGenerator(java.lang.String labelFormat, java.text.DateFormat formatter)
Creates a label generator with the specified date formatter.protected
AbstractCategoryItemLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat formatter)
Creates a label generator with the specified number formatter.protected
AbstractCategoryItemLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat formatter, java.text.NumberFormat percentFormatter)
Creates a label generator with the specified number formatter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canEqual(java.lang.Object other)
java.lang.Object
clone()
Returns an independent copy of the generator.protected java.lang.Object[]
createItemArray(CategoryDataset dataset, int row, int column)
Creates the array of items that can be passed to theMessageFormat
class for creating labels.boolean
equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.java.lang.String
generateColumnLabel(CategoryDataset dataset, int column)
Generates a label for the specified row.protected java.lang.String
generateLabelString(CategoryDataset dataset, int row, int column)
Generates a for the specified item.java.lang.String
generateRowLabel(CategoryDataset dataset, int row)
Generates a label for the specified row.java.text.DateFormat
getDateFormat()
Returns the date formatter.java.lang.String
getLabelFormat()
Returns the label format string.java.text.NumberFormat
getNumberFormat()
Returns the number 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 used by aMessageFormat
object to combine the standard items: {0} = series name, {1} = category, {2} = value, {3} = value as a percentage of the column total.
-
nullValueString
private final java.lang.String nullValueString
The string used to represent a null value.
-
numberFormat
private java.text.NumberFormat numberFormat
A number formatter used to preformat the value before it is passed to the MessageFormat object.
-
dateFormat
private java.text.DateFormat dateFormat
A date formatter used to preformat the value before it is passed to the MessageFormat object.
-
percentFormat
private final java.text.NumberFormat percentFormat
A number formatter used to preformat the percentage value before it is passed to the MessageFormat object.
-
-
Constructor Detail
-
AbstractCategoryItemLabelGenerator
protected AbstractCategoryItemLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat formatter)
Creates a label generator with the specified number formatter.- Parameters:
labelFormat
- the label format string (null
not permitted).formatter
- the number formatter (null
not permitted).
-
AbstractCategoryItemLabelGenerator
protected AbstractCategoryItemLabelGenerator(java.lang.String labelFormat, java.text.NumberFormat formatter, java.text.NumberFormat percentFormatter)
Creates a label generator with the specified number formatter.- Parameters:
labelFormat
- the label format string (null
not permitted).formatter
- the number formatter (null
not permitted).percentFormatter
- the percent formatter (null
not permitted).
-
AbstractCategoryItemLabelGenerator
protected AbstractCategoryItemLabelGenerator(java.lang.String labelFormat, java.text.DateFormat formatter)
Creates a label generator with the specified date formatter.- Parameters:
labelFormat
- the label format string (null
not permitted).formatter
- the date formatter (null
not permitted).
-
-
Method Detail
-
generateRowLabel
public java.lang.String generateRowLabel(CategoryDataset dataset, int row)
Generates a label for the specified row.- Parameters:
dataset
- the dataset (null
not permitted).row
- the row index (zero-based).- Returns:
- The label.
-
generateColumnLabel
public java.lang.String generateColumnLabel(CategoryDataset dataset, int column)
Generates a label for the specified row.- Parameters:
dataset
- the dataset (null
not permitted).column
- the column index (zero-based).- Returns:
- The label.
-
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 number formatter (possibly
null
).
-
getDateFormat
public java.text.DateFormat getDateFormat()
Returns the date formatter.- Returns:
- The date formatter (possibly
null
).
-
generateLabelString
protected java.lang.String generateLabelString(CategoryDataset dataset, int row, int column)
Generates a for the specified item.- Parameters:
dataset
- the dataset (null
not permitted).row
- the row index (zero-based).column
- the column index (zero-based).- Returns:
- The label (possibly
null
).
-
createItemArray
protected java.lang.Object[] createItemArray(CategoryDataset dataset, int row, int column)
Creates the array of items that can be passed to theMessageFormat
class for creating labels.- Parameters:
dataset
- the dataset (null
not permitted).row
- the row index (zero-based).column
- the column index (zero-based).- Returns:
- The items (never
null
).
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the other object (null
permitted).- Returns:
- A boolean.
-
canEqual
public boolean canEqual(java.lang.Object other)
-
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.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classjava.lang.Object
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- should not happen.
-
-