Package org.jfree.chart.annotations
Class XYTextAnnotation
java.lang.Object
org.jfree.chart.annotations.TextAnnotation
org.jfree.chart.annotations.XYTextAnnotation
- All Implemented Interfaces:
Serializable
,Cloneable
,XYAnnotation
- Direct Known Subclasses:
XYPointerAnnotation
public class XYTextAnnotation extends TextAnnotation implements XYAnnotation, Cloneable, Serializable
A text annotation that can be placed at a particular (x, y) location on an
XYPlot
.- See Also:
- Serialized Form
-
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
Constructors Constructor Description XYTextAnnotation(String text, double x, double y)
Creates a new annotation to be displayed at the given coordinates. -
Method Summary
Modifier and Type Method Description Object
clone()
Returns a clone of the annotation.void
draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis)
Draws the annotation.double
getX()
Returns the x coordinate for the text anchor point (measured against the domain axis).double
getY()
Returns the y coordinate for the text anchor point (measured against the range axis).void
setX(double x)
Sets the x coordinate for the text anchor point (measured against the domain axis).void
setY(double y)
Sets the y coordinate for the text anchor point (measured against the range axis).Methods inherited from class org.jfree.chart.annotations.TextAnnotation
equals, getFont, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, setFont, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor
-
Constructor Details
-
XYTextAnnotation
Creates a new annotation to be displayed at the given coordinates. The coordinates are specified in data space (they will be converted to Java2D space for display).- Parameters:
text
- the text.x
- the x-coordinate.y
- the y-coordinate.
-
-
Method Details
-
getX
public double getX()Returns the x coordinate for the text anchor point (measured against the domain axis).- Returns:
- The x coordinate.
-
setX
public void setX(double x)Sets the x coordinate for the text anchor point (measured against the domain axis).- Parameters:
x
- the x coordinate.
-
getY
public double getY()Returns the y coordinate for the text anchor point (measured against the range axis).- Returns:
- The y coordinate.
-
setY
public void setY(double y)Sets the y coordinate for the text anchor point (measured against the range axis).- Parameters:
y
- the y coordinate.
-
draw
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis)Draws the annotation.- Specified by:
draw
in interfaceXYAnnotation
- Parameters:
g2
- the graphics device.plot
- the plot.dataArea
- the data area.domainAxis
- the domain axis.rangeAxis
- the range axis.
-
clone
Returns a clone of the annotation.- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if the annotation can't be cloned.
-