org.jfree.chart.annotations

Class CategoryTextAnnotation

Implemented Interfaces:
CategoryAnnotation, Cloneable, Serializable
Known Direct Subclasses:
CategoryPointerAnnotation

public class CategoryTextAnnotation
extends TextAnnotation
implements CategoryAnnotation, Cloneable, Serializable

A text annotation that can be placed on a CategoryPlot.

Field Summary

Fields inherited from class org.jfree.chart.annotations.TextAnnotation

DEFAULT_FONT, DEFAULT_PAINT, DEFAULT_ROTATION_ANCHOR, DEFAULT_ROTATION_ANGLE, DEFAULT_TEXT_ANCHOR

Constructor Summary

CategoryTextAnnotation(String text, Comparable category, double value)
Creates a new annotation to be displayed at the given location.

Method Summary

Object
clone()
Returns a clone of the annotation.
void
draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)
Draws the annotation.
boolean
equals(Object obj)
Tests this object for equality with another.
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(Comparable category)
Sets the category that the annotation attaches to.
void
setCategoryAnchor(CategoryAnchor anchor)
Sets the category anchor point.
void
setValue(double value)
Sets the value.

Methods inherited from class org.jfree.chart.annotations.TextAnnotation

equals, getFont, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, hashCode, setFont, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor

Constructor Details

CategoryTextAnnotation

public CategoryTextAnnotation(String text,
                              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 Details

clone

public Object clone()
            throws CloneNotSupportedException
Returns a clone of the annotation.
Returns:
A clone.

draw

public void draw(Graphics2D g2,
                 CategoryPlot plot,
                 Rectangle2D dataArea,
                 CategoryAxis domainAxis,
                 ValueAxis rangeAxis)
Draws the annotation.
Specified by:
draw in interface CategoryAnnotation
Parameters:
g2 - the graphics device.
plot - the plot.
dataArea - the data area.
domainAxis - the domain axis.
rangeAxis - the range axis.

equals

public boolean equals(Object obj)
Tests this object for equality with another.
Overrides:
equals in interface TextAnnotation
Parameters:
obj - the object (null permitted).
Returns:
true or false.

getCategory

public Comparable getCategory()
Returns the category.
Returns:
The category (never null).

getCategoryAnchor

public CategoryAnchor getCategoryAnchor()
Returns the category anchor point.
Returns:
The category anchor point.

getValue

public double getValue()
Returns the value that the annotation attaches to.
Returns:
The value.

hashCode

public int hashCode()
Returns a hash code for this instance.
Overrides:
hashCode in interface TextAnnotation
Returns:
A hash code.

setCategory

public void setCategory(Comparable category)
Sets the category that the annotation attaches to.
Parameters:
category - the category (null not permitted).
See Also:
getCategory()

setCategoryAnchor

public void setCategoryAnchor(CategoryAnchor anchor)
Sets the category anchor point.
Parameters:
anchor - the anchor point (null not permitted).

setValue

public void setValue(double value)
Sets the value.
Parameters:
value - the value.
See Also:
getValue()