Package org.jfree.chart.annotations
Class CategoryTextAnnotation
- java.lang.Object
-
- org.jfree.chart.annotations.AbstractAnnotation
-
- org.jfree.chart.annotations.TextAnnotation
-
- org.jfree.chart.annotations.CategoryTextAnnotation
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Annotation
,CategoryAnnotation
,PublicCloneable
- Direct Known Subclasses:
CategoryPointerAnnotation
public class CategoryTextAnnotation extends TextAnnotation implements CategoryAnnotation, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A text annotation that can be placed on aCategoryPlot
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Comparable
category
The category.private CategoryAnchor
categoryAnchor
The category anchor (START, MIDDLE, or END).private static long
serialVersionUID
For serialization.private double
value
The value.-
Fields inherited from class org.jfree.chart.annotations.TextAnnotation
DEFAULT_FONT, DEFAULT_PAINT, DEFAULT_ROTATION_ANCHOR, DEFAULT_ROTATION_ANGLE, DEFAULT_TEXT_ANCHOR
-
-
Constructor Summary
Constructors Constructor Description CategoryTextAnnotation(java.lang.String text, java.lang.Comparable category, double value)
Creates a new annotation to be displayed at the given location.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals.java.lang.Object
clone()
Returns a clone of the annotation.void
draw(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)
Draws the annotation.boolean
equals(java.lang.Object obj)
Tests this object for equality with another.java.lang.Comparable
getCategory()
Returns the category.CategoryAnchor
getCategoryAnchor()
Returns the category anchor point.double
getValue()
Returns the value that the annotation attaches to.int
hashCode()
Returns a hash code for this instance.void
setCategory(java.lang.Comparable category)
Sets the category that the annotation attaches to and sends anAnnotationChangeEvent
to all registered listeners.void
setCategoryAnchor(CategoryAnchor anchor)
Sets the category anchor point and sends anAnnotationChangeEvent
to all registered listeners.void
setValue(double value)
Sets the value and sends anAnnotationChangeEvent
to all registered listeners.-
Methods inherited from class org.jfree.chart.annotations.TextAnnotation
getFont, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, setFont, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor
-
Methods inherited from class org.jfree.chart.annotations.AbstractAnnotation
addChangeListener, fireAnnotationChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.chart.annotations.Annotation
addChangeListener, removeChangeListener
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
category
private java.lang.Comparable category
The category.
-
categoryAnchor
private CategoryAnchor categoryAnchor
The category anchor (START, MIDDLE, or END).
-
value
private double value
The value.
-
-
Constructor Detail
-
CategoryTextAnnotation
public CategoryTextAnnotation(java.lang.String text, java.lang.Comparable category, double value)
Creates a new annotation to be displayed at the given location.- Parameters:
text
- the text (null
not permitted).category
- the category (null
not permitted).value
- the value.
-
-
Method Detail
-
getCategory
public java.lang.Comparable getCategory()
Returns the category.- Returns:
- The category (never
null
). - See Also:
setCategory(Comparable)
-
setCategory
public void setCategory(java.lang.Comparable category)
Sets the category that the annotation attaches to and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
category
- the category (null
not permitted).- See Also:
getCategory()
-
getCategoryAnchor
public CategoryAnchor getCategoryAnchor()
Returns the category anchor point.- Returns:
- The category anchor point.
- See Also:
setCategoryAnchor(CategoryAnchor)
-
setCategoryAnchor
public void setCategoryAnchor(CategoryAnchor anchor)
Sets the category anchor point and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor point (null
not permitted).- See Also:
getCategoryAnchor()
-
getValue
public double getValue()
Returns the value that the annotation attaches to.- Returns:
- The value.
- See Also:
setValue(double)
-
setValue
public void setValue(double value)
Sets the value and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
value
- the value.- See Also:
getValue()
-
draw
public void draw(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)
Draws the annotation.- Specified by:
draw
in interfaceCategoryAnnotation
- Parameters:
g2
- the graphics device.plot
- the plot.dataArea
- the data area.domainAxis
- the domain axis.rangeAxis
- the range axis.
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with another.- Overrides:
equals
in classTextAnnotation
- Parameters:
obj
- the object (null
permitted).- Returns:
true
orfalse
.
-
canEqual
public boolean canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqual
in classTextAnnotation
- Parameters:
other
- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCode
in classTextAnnotation
- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the annotation.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractAnnotation
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- this class will not throw this exception, but subclasses (if any) might.
-
-