Package org.jfree.chart.annotations
Class XYTextAnnotation
- java.lang.Object
-
- org.jfree.chart.annotations.AbstractAnnotation
-
- org.jfree.chart.annotations.AbstractXYAnnotation
-
- org.jfree.chart.annotations.XYTextAnnotation
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Annotation
,XYAnnotation
,PublicCloneable
- Direct Known Subclasses:
XYNoteAnnotation
,XYPointerAnnotation
public class XYTextAnnotation extends AbstractXYAnnotation implements java.lang.Cloneable, PublicCloneable, java.io.Serializable
A text annotation that can be placed at a particular (x, y) location on anXYPlot
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Paint
backgroundPaint
The background paint (possibly null).static java.awt.Font
DEFAULT_FONT
The default font.static java.awt.Paint
DEFAULT_PAINT
The default paint.static TextAnchor
DEFAULT_ROTATION_ANCHOR
The default rotation anchor.static double
DEFAULT_ROTATION_ANGLE
The default rotation angle.static TextAnchor
DEFAULT_TEXT_ANCHOR
The default text anchor.private java.awt.Font
font
The font.private java.awt.Paint
outlinePaint
The outline paint (never null).private java.awt.Stroke
outlineStroke
The outline stroke (never null).private boolean
outlineVisible
The flag that controls the visibility of the outline.private java.awt.Paint
paint
The paint.private TextAnchor
rotationAnchor
The rotation anchor.private double
rotationAngle
The rotation angle.private static long
serialVersionUID
For serialization.private java.lang.String
text
The text.private TextAnchor
textAnchor
The text anchor (to be aligned with (x, y)).private double
x
The x-coordinate.private double
y
The y-coordinate.
-
Constructor Summary
Constructors Constructor Description XYTextAnnotation(java.lang.String text, double x, double y)
Creates a new annotation to be displayed at the given coordinates.
-
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, XYPlot plot, java.awt.geom.Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info)
Draws the annotation.boolean
equals(java.lang.Object obj)
Tests this annotation for equality with an arbitrary object.java.awt.Paint
getBackgroundPaint()
Returns the background paint for the annotation.java.awt.Font
getFont()
Returns the font for the annotation.java.awt.Paint
getOutlinePaint()
Returns the outline paint for the annotation.java.awt.Stroke
getOutlineStroke()
Returns the outline stroke for the annotation.java.awt.Paint
getPaint()
Returns the paint for the annotation.TextAnchor
getRotationAnchor()
Returns the rotation anchor.double
getRotationAngle()
Returns the rotation angle.java.lang.String
getText()
Returns the text for the annotation.TextAnchor
getTextAnchor()
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
isOutlineVisible()
Returns the flag that controls whether or not the outline is drawn.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setBackgroundPaint(java.awt.Paint paint)
Sets the background paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setFont(java.awt.Font font)
Sets the font for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setOutlinePaint(java.awt.Paint paint)
Sets the outline paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.void
setOutlineStroke(java.awt.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
setPaint(java.awt.Paint paint)
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
setText(java.lang.String text)
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.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
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 Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
DEFAULT_FONT
public static final java.awt.Font DEFAULT_FONT
The default font.
-
DEFAULT_PAINT
public static final java.awt.Paint DEFAULT_PAINT
The default paint.
-
DEFAULT_TEXT_ANCHOR
public static final TextAnchor DEFAULT_TEXT_ANCHOR
The default text anchor.
-
DEFAULT_ROTATION_ANCHOR
public static final TextAnchor DEFAULT_ROTATION_ANCHOR
The default rotation anchor.
-
DEFAULT_ROTATION_ANGLE
public static final double DEFAULT_ROTATION_ANGLE
The default rotation angle.- See Also:
- Constant Field Values
-
text
private java.lang.String text
The text.
-
font
private java.awt.Font font
The font.
-
paint
private transient java.awt.Paint paint
The paint.
-
x
private double x
The x-coordinate.
-
y
private double y
The y-coordinate.
-
textAnchor
private TextAnchor textAnchor
The text anchor (to be aligned with (x, y)).
-
rotationAnchor
private TextAnchor rotationAnchor
The rotation anchor.
-
rotationAngle
private double rotationAngle
The rotation angle.
-
backgroundPaint
private transient java.awt.Paint backgroundPaint
The background paint (possibly null).
-
outlineVisible
private boolean outlineVisible
The flag that controls the visibility of the outline.
-
outlinePaint
private transient java.awt.Paint outlinePaint
The outline paint (never null).
-
outlineStroke
private transient java.awt.Stroke outlineStroke
The outline stroke (never null).
-
-
Constructor Detail
-
XYTextAnnotation
public XYTextAnnotation(java.lang.String text, double x, double y)
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, must be finite).y
- the y-coordinate (in data space, must be finite).
-
-
Method Detail
-
getText
public java.lang.String getText()
Returns the text for the annotation.- Returns:
- The text (never
null
). - See Also:
setText(String)
-
setText
public void setText(java.lang.String text)
Sets the text for the annotation.- Parameters:
text
- the text (null
not permitted).- See Also:
getText()
-
getFont
public java.awt.Font getFont()
Returns the font for the annotation.- Returns:
- The font (never
null
). - See Also:
setFont(Font)
-
setFont
public void setFont(java.awt.Font font)
Sets the font for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
font
- the font (null
not permitted).- See Also:
getFont()
-
getPaint
public java.awt.Paint getPaint()
Returns the paint for the annotation.- Returns:
- The paint (never
null
). - See Also:
setPaint(Paint)
-
setPaint
public void setPaint(java.awt.Paint paint)
Sets the paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getPaint()
-
getTextAnchor
public TextAnchor getTextAnchor()
Returns the text anchor.- Returns:
- The text anchor (never
null
). - See Also:
setTextAnchor(TextAnchor)
-
setTextAnchor
public 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.- Parameters:
anchor
- the anchor point (null
not permitted).- See Also:
getTextAnchor()
-
getRotationAnchor
public TextAnchor getRotationAnchor()
Returns the rotation anchor.- Returns:
- The rotation anchor point (never
null
). - See Also:
setRotationAnchor(TextAnchor)
-
setRotationAnchor
public void setRotationAnchor(TextAnchor anchor)
Sets the rotation anchor point and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor (null
not permitted).- See Also:
getRotationAnchor()
-
getRotationAngle
public double getRotationAngle()
Returns the rotation angle.- Returns:
- The rotation angle.
- See Also:
setRotationAngle(double)
-
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:
getRotationAngle()
-
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(double)
-
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:
getX()
-
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(double)
-
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:
getY()
-
getBackgroundPaint
public java.awt.Paint getBackgroundPaint()
Returns the background paint for the annotation.- Returns:
- The background paint (possibly
null
). - See Also:
setBackgroundPaint(Paint)
-
setBackgroundPaint
public void setBackgroundPaint(java.awt.Paint paint)
Sets the background paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
permitted).- See Also:
getBackgroundPaint()
-
getOutlinePaint
public java.awt.Paint getOutlinePaint()
Returns the outline paint for the annotation.- Returns:
- The outline paint (never
null
). - See Also:
setOutlinePaint(Paint)
-
setOutlinePaint
public void setOutlinePaint(java.awt.Paint paint)
Sets the outline paint for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getOutlinePaint()
-
getOutlineStroke
public java.awt.Stroke getOutlineStroke()
Returns the outline stroke for the annotation.- Returns:
- The outline stroke (never
null
). - See Also:
setOutlineStroke(Stroke)
-
setOutlineStroke
public void setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke for the annotation and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
getOutlineStroke()
-
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(java.awt.Graphics2D g2, XYPlot plot, java.awt.geom.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
public boolean equals(java.lang.Object obj)
Tests this annotation for equality with an arbitrary object.- Overrides:
equals
in classAbstractXYAnnotation
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
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 classAbstractXYAnnotation
- Parameters:
other
- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()
Returns a hash code for the object.- Overrides:
hashCode
in classAbstractXYAnnotation
- 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
- if the annotation can't be cloned.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
java.io.IOException
- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.
-
-