Package org.jfree.chart.annotations
Class TextAnnotation
- java.lang.Object
-
- org.jfree.chart.annotations.AbstractAnnotation
-
- org.jfree.chart.annotations.TextAnnotation
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Annotation
- Direct Known Subclasses:
CategoryTextAnnotation
public class TextAnnotation extends AbstractAnnotation implements java.io.Serializable
A base class for text annotations. This class records the content but not the location of the annotation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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
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.
-
Constructor Summary
Constructors Modifier Constructor Description protected
TextAnnotation(java.lang.String text)
Creates a text annotation with default settings.
-
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.boolean
equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.java.awt.Font
getFont()
Returns the font 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 in radians.java.lang.String
getText()
Returns the text for the annotation.TextAnchor
getTextAnchor()
Returns the text anchor.int
hashCode()
Returns a hash code for this instance.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setFont(java.awt.Font font)
Sets the font for the annotation 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 and sends anAnnotationChangeEvent
to all registered listeners.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.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
Methods inherited from class org.jfree.chart.annotations.AbstractAnnotation
addChangeListener, clone, fireAnnotationChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify
-
-
-
-
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.
-
textAnchor
private TextAnchor textAnchor
The text anchor.
-
rotationAnchor
private TextAnchor rotationAnchor
The rotation anchor.
-
rotationAngle
private double rotationAngle
The rotation angle.
-
-
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 and sends anAnnotationChangeEvent
to all registered listeners.- 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.
- 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 in radians.- 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()
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.- Overrides:
equals
in classAbstractAnnotation
- 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 classAbstractAnnotation
- 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 classAbstractAnnotation
- Returns:
- A hash code.
-
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.
-
-