java.lang.Object
org.jfree.chart.annotations.AbstractAnnotation
org.jfree.chart.annotations.AbstractXYAnnotation
org.jfree.chart.annotations.XYTextAnnotation
- All Implemented Interfaces:
Serializable
,Cloneable
,Annotation
,XYAnnotation
,PublicCloneable
- Direct Known Subclasses:
XYPointerAnnotation
public class XYTextAnnotation
extends AbstractXYAnnotation
implements Cloneable, PublicCloneable, Serializable
A text annotation that can be placed at a particular (x, y) location on an
XYPlot
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Font
The default font.static final Paint
The default paint.static final TextAnchor
The default rotation anchor.static final double
The default rotation angle.static final TextAnchor
The default text anchor. -
Constructor Summary
ConstructorDescriptionXYTextAnnotation
(String text, double x, double y) Creates a new annotation to be displayed at the given coordinates. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of the annotation.void
draw
(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) Draws the annotation.boolean
Tests this annotation for equality with an arbitrary object.Returns the background paint for the annotation.getFont()
Returns the font for the annotation.Returns the outline paint for the annotation.Returns the outline stroke for the annotation.getPaint()
Returns the paint for the annotation.Returns the rotation anchor.double
Returns the rotation angle.getText()
Returns the text for the annotation.Returns the text anchor.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).int
hashCode()
Returns a hash code for the object.boolean
Returns the flag that controls whether or not the outline is drawn.void
setBackgroundPaint
(Paint paint) Sets the background paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
Sets the font for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setOutlinePaint
(Paint paint) Sets the outline paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setOutlineStroke
(Stroke stroke) Sets the outline stroke for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setOutlineVisible
(boolean visible) Sets the flag that controls whether or not the outline is drawn and sends anAnnotationChangeEvent
to all registered listeners.void
Sets the paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setRotationAnchor
(TextAnchor anchor) Sets the rotation anchor point and sends anAnnotationChangeEvent
to all registered listeners.void
setRotationAngle
(double angle) Sets the rotation angle and sends anAnnotationChangeEvent
to all registered listeners.void
Sets the text for the annotation.void
setTextAnchor
(TextAnchor anchor) Sets the text anchor (the point on the text bounding rectangle that is aligned to the (x, y) coordinate of the annotation) and sends anAnnotationChangeEvent
to all registered listeners.void
setX
(double x) Sets the x coordinate for the text anchor point (measured against the domain axis) and sends anAnnotationChangeEvent
to all registered listeners.void
setY
(double y) Sets the y coordinate for the text anchor point (measured against the range axis) and sends anAnnotationChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.annotations.AbstractXYAnnotation
addEntity, getToolTipText, getURL, setToolTipText, setURL
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 Details
-
DEFAULT_FONT
The default font. -
DEFAULT_PAINT
The default paint. -
DEFAULT_TEXT_ANCHOR
The default text anchor. -
DEFAULT_ROTATION_ANCHOR
The default rotation anchor. -
DEFAULT_ROTATION_ANGLE
public static final double DEFAULT_ROTATION_ANGLEThe default rotation angle.- See Also:
-
-
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 (null
not permitted).x
- the x-coordinate (in data space).y
- the y-coordinate (in data space).
-
-
Method Details
-
getText
Returns the text for the annotation.- Returns:
- The text (never
null
). - See Also:
-
setText
Sets the text for the annotation.- Parameters:
text
- the text (null
not permitted).- See Also:
-
getFont
Returns the font for the annotation.- Returns:
- The font (never
null
). - See Also:
-
setFont
Sets the font for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
font
- the font (null
not permitted).- See Also:
-
getPaint
Returns the paint for the annotation.- Returns:
- The paint (never
null
). - See Also:
-
setPaint
Sets the paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
-
getTextAnchor
Returns the text anchor.- Returns:
- The text anchor (never
null
). - See Also:
-
setTextAnchor
Sets the text anchor (the point on the text bounding rectangle that is aligned to the (x, y) coordinate of the annotation) and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor point (null
not permitted).- See Also:
-
getRotationAnchor
Returns the rotation anchor.- Returns:
- The rotation anchor point (never
null
). - See Also:
-
setRotationAnchor
Sets the rotation anchor point and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor (null
not permitted).- See Also:
-
getRotationAngle
public double getRotationAngle()Returns the rotation angle.- Returns:
- The rotation angle.
- See Also:
-
setRotationAngle
public void setRotationAngle(double angle) Sets the rotation angle and sends anAnnotationChangeEvent
to all registered listeners. The angle is measured clockwise in radians.- Parameters:
angle
- the angle (in radians).- See Also:
-
getX
public double getX()Returns the x coordinate for the text anchor point (measured against the domain axis).- Returns:
- The x coordinate (in data space).
- See Also:
-
setX
public void setX(double x) Sets the x coordinate for the text anchor point (measured against the domain axis) and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
x
- the x coordinate (in data space).- See Also:
-
getY
public double getY()Returns the y coordinate for the text anchor point (measured against the range axis).- Returns:
- The y coordinate (in data space).
- See Also:
-
setY
public void setY(double y) Sets the y coordinate for the text anchor point (measured against the range axis) and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
y
- the y coordinate.- See Also:
-
getBackgroundPaint
Returns the background paint for the annotation.- Returns:
- The background paint (possibly
null
). - See Also:
-
setBackgroundPaint
Sets the background paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
permitted).- See Also:
-
getOutlinePaint
Returns the outline paint for the annotation.- Returns:
- The outline paint (never
null
). - See Also:
-
setOutlinePaint
Sets the outline paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
-
getOutlineStroke
Returns the outline stroke for the annotation.- Returns:
- The outline stroke (never
null
). - See Also:
-
setOutlineStroke
Sets the outline stroke for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
-
isOutlineVisible
public boolean isOutlineVisible()Returns the flag that controls whether or not the outline is drawn.- Returns:
- A boolean.
-
setOutlineVisible
public void setOutlineVisible(boolean visible) Sets the flag that controls whether or not the outline is drawn and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.
-
draw
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) Draws the annotation.- Specified by:
draw
in interfaceXYAnnotation
- Specified by:
draw
in classAbstractXYAnnotation
- Parameters:
g2
- the graphics device.plot
- the plot.dataArea
- the data area.domainAxis
- the domain axis.rangeAxis
- the range axis.rendererIndex
- the renderer index.info
- an optional info object that will be populated with entity information.
-
equals
Tests this annotation for equality with an arbitrary object.- Overrides:
equals
in classAbstractXYAnnotation
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()Returns a hash code for the object.- Overrides:
hashCode
in classAbstractXYAnnotation
- Returns:
- A hash code.
-
clone
Returns a clone of the annotation.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractAnnotation
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if the annotation can't be cloned.
-