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:
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:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static FontDEFAULT_FONTThe default font.static PaintDEFAULT_PAINTThe default paint.static TextAnchorDEFAULT_ROTATION_ANCHORThe default rotation anchor.static doubleDEFAULT_ROTATION_ANGLEThe default rotation angle.static TextAnchorDEFAULT_TEXT_ANCHORThe 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 Objectclone()Returns a clone of the annotation.voiddraw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info)Draws the annotation.booleanequals(Object obj)Tests this annotation for equality with an arbitrary object.PaintgetBackgroundPaint()Returns the background paint for the annotation.FontgetFont()Returns the font for the annotation.PaintgetOutlinePaint()Returns the outline paint for the annotation.StrokegetOutlineStroke()Returns the outline stroke for the annotation.PaintgetPaint()Returns the paint for the annotation.TextAnchorgetRotationAnchor()Returns the rotation anchor.doublegetRotationAngle()Returns the rotation angle.StringgetText()Returns the text for the annotation.TextAnchorgetTextAnchor()Returns the text anchor.doublegetX()Returns the x coordinate for the text anchor point (measured against the domain axis).doublegetY()Returns the y coordinate for the text anchor point (measured against the range axis).inthashCode()Returns a hash code for the object.booleanisOutlineVisible()Returns the flag that controls whether or not the outline is drawn.voidsetBackgroundPaint(Paint paint)Sets the background paint for the annotation and sends anAnnotationChangeEventto all registered listeners.voidsetFont(Font font)Sets the font for the annotation and sends anAnnotationChangeEventto all registered listeners.voidsetOutlinePaint(Paint paint)Sets the outline paint for the annotation and sends anAnnotationChangeEventto all registered listeners.voidsetOutlineStroke(Stroke stroke)Sets the outline stroke for the annotation and sends anAnnotationChangeEventto all registered listeners.voidsetOutlineVisible(boolean visible)Sets the flag that controls whether or not the outline is drawn and sends anAnnotationChangeEventto all registered listeners.voidsetPaint(Paint paint)Sets the paint for the annotation and sends anAnnotationChangeEventto all registered listeners.voidsetRotationAnchor(TextAnchor anchor)Sets the rotation anchor point and sends anAnnotationChangeEventto all registered listeners.voidsetRotationAngle(double angle)Sets the rotation angle and sends anAnnotationChangeEventto all registered listeners.voidsetText(String text)Sets the text for the annotation.voidsetTextAnchor(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 anAnnotationChangeEventto all registered listeners.voidsetX(double x)Sets the x coordinate for the text anchor point (measured against the domain axis) and sends anAnnotationChangeEventto all registered listeners.voidsetY(double y)Sets the y coordinate for the text anchor point (measured against the range axis) and sends anAnnotationChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.annotations.AbstractXYAnnotation
addEntity, getToolTipText, getURL, setToolTipText, setURLMethods inherited from class org.jfree.chart.annotations.AbstractAnnotation
addChangeListener, fireAnnotationChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotifyMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods 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
The default rotation angle.- See Also:
- Constant Field Values
-
-
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 (nullnot 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(String)
-
setText
Sets the text for the annotation.- Parameters:
text- the text (nullnot permitted).- See Also:
getText()
-
getFont
Returns the font for the annotation.- Returns:
- The font (never
null). - See Also:
setFont(Font)
-
setFont
Sets the font for the annotation and sends anAnnotationChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
getFont()
-
getPaint
Returns the paint for the annotation.- Returns:
- The paint (never
null). - See Also:
setPaint(Paint)
-
setPaint
Sets the paint for the annotation and sends anAnnotationChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getPaint()
-
getTextAnchor
Returns the text anchor.- Returns:
- The text anchor (never
null). - See Also:
setTextAnchor(TextAnchor)
-
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 anAnnotationChangeEventto all registered listeners.- Parameters:
anchor- the anchor point (nullnot permitted).- See Also:
getTextAnchor()
-
getRotationAnchor
Returns the rotation anchor.- Returns:
- The rotation anchor point (never
null). - See Also:
setRotationAnchor(TextAnchor)
-
setRotationAnchor
Sets the rotation anchor point and sends anAnnotationChangeEventto all registered listeners.- Parameters:
anchor- the anchor (nullnot permitted).- See Also:
getRotationAnchor()
-
getRotationAngle
Returns the rotation angle.- Returns:
- The rotation angle.
- See Also:
setRotationAngle(double)
-
setRotationAngle
Sets the rotation angle and sends anAnnotationChangeEventto all registered listeners. The angle is measured clockwise in radians.- Parameters:
angle- the angle (in radians).- See Also:
getRotationAngle()
-
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
Sets the x coordinate for the text anchor point (measured against the domain axis) and sends anAnnotationChangeEventto all registered listeners.- Parameters:
x- the x coordinate (in data space).- See Also:
getX()
-
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
Sets the y coordinate for the text anchor point (measured against the range axis) and sends anAnnotationChangeEventto all registered listeners.- Parameters:
y- the y coordinate.- See Also:
getY()
-
getBackgroundPaint
Returns the background paint for the annotation.- Returns:
- The background paint (possibly
null). - See Also:
setBackgroundPaint(Paint)
-
setBackgroundPaint
Sets the background paint for the annotation and sends anAnnotationChangeEventto all registered listeners.- Parameters:
paint- the paint (nullpermitted).- See Also:
getBackgroundPaint()
-
getOutlinePaint
Returns the outline paint for the annotation.- Returns:
- The outline paint (never
null). - See Also:
setOutlinePaint(Paint)
-
setOutlinePaint
Sets the outline paint for the annotation and sends anAnnotationChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getOutlinePaint()
-
getOutlineStroke
Returns the outline stroke for the annotation.- Returns:
- The outline stroke (never
null). - See Also:
setOutlineStroke(Stroke)
-
setOutlineStroke
Sets the outline stroke for the annotation and sends anAnnotationChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getOutlineStroke()
-
isOutlineVisible
Returns the flag that controls whether or not the outline is drawn.- Returns:
- A boolean.
-
setOutlineVisible
Sets the flag that controls whether or not the outline is drawn and sends anAnnotationChangeEventto 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:
drawin interfaceXYAnnotation- Specified by:
drawin 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:
equalsin classAbstractXYAnnotation- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
hashCode
Returns a hash code for the object.- Overrides:
hashCodein classAbstractXYAnnotation- Returns:
- A hash code.
-
clone
Returns a clone of the annotation.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractAnnotation- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if the annotation can't be cloned.
-