org.jfree.chart.annotations

Class XYTextAnnotation

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.
Field Summary
static FontDEFAULT_FONT
The default font.
static PaintDEFAULT_PAINT
The default paint.
static TextAnchorDEFAULT_ROTATION_ANCHOR
The default rotation anchor.
static doubleDEFAULT_ROTATION_ANGLE
The default rotation angle.
static TextAnchorDEFAULT_TEXT_ANCHOR
The default text anchor.
Constructor Summary
XYTextAnnotation(String text, double x, double y)
Creates a new annotation to be displayed at the given coordinates.
Method Summary
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.
voidsetFont(Font font)
Sets the font for the annotation.
voidsetOutlinePaint(Paint paint)
Sets the outline paint for the annotation.
voidsetOutlineStroke(Stroke stroke)
Sets the outline stroke for the annotation.
voidsetOutlineVisible(boolean visible)
Sets the flag that controls whether or not the outline is drawn.
voidsetPaint(Paint paint)
Sets the paint for the annotation.
voidsetRotationAnchor(TextAnchor anchor)
Sets the rotation anchor point.
voidsetRotationAngle(double angle)
Sets the rotation angle.
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).
voidsetX(double x)
Sets the x coordinate for the text anchor point (measured against the domain axis).
voidsetY(double y)
Sets the y coordinate for the text anchor point (measured against the range axis).

Field Detail

DEFAULT_FONT

public static final Font DEFAULT_FONT
The default font.

DEFAULT_PAINT

public static final Paint DEFAULT_PAINT
The default paint.

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.

DEFAULT_TEXT_ANCHOR

public static final TextAnchor DEFAULT_TEXT_ANCHOR
The default text anchor.

Constructor Detail

XYTextAnnotation

public XYTextAnnotation(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). y the y-coordinate (in data space).

Method Detail

clone

public Object clone()
Returns a clone of the annotation.

Returns: A clone.

Throws: CloneNotSupportedException if the annotation can't be cloned.

draw

public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info)
Draws the annotation.

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(Object obj)
Tests this annotation for equality with an arbitrary object.

Parameters: obj the object (null permitted).

Returns: A boolean.

getBackgroundPaint

public Paint getBackgroundPaint()
Returns the background paint for the annotation.

Returns: The background paint (possibly null).

Since: 1.0.13

See Also:

getFont

public Font getFont()
Returns the font for the annotation.

Returns: The font (never null).

See Also: setFont

getOutlinePaint

public Paint getOutlinePaint()
Returns the outline paint for the annotation.

Returns: The outline paint (never null).

Since: 1.0.13

See Also:

getOutlineStroke

public Stroke getOutlineStroke()
Returns the outline stroke for the annotation.

Returns: The outline stroke (never null).

Since: 1.0.13

See Also:

getPaint

public Paint getPaint()
Returns the paint for the annotation.

Returns: The paint (never null).

See Also: setPaint

getRotationAnchor

public TextAnchor getRotationAnchor()
Returns the rotation anchor.

Returns: The rotation anchor point (never null).

See Also: setRotationAnchor

getRotationAngle

public double getRotationAngle()
Returns the rotation angle.

Returns: The rotation angle.

See Also: XYTextAnnotation

getText

public String getText()
Returns the text for the annotation.

Returns: The text (never null).

See Also: setText

getTextAnchor

public TextAnchor getTextAnchor()
Returns the text anchor.

Returns: The text anchor (never null).

See Also: setTextAnchor

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: XYTextAnnotation

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: XYTextAnnotation

hashCode

public int hashCode()
Returns a hash code for the object.

Returns: A hash code.

isOutlineVisible

public boolean isOutlineVisible()
Returns the flag that controls whether or not the outline is drawn.

Returns: A boolean.

Since: 1.0.13

setBackgroundPaint

public void setBackgroundPaint(Paint paint)
Sets the background paint for the annotation.

Parameters: paint the paint (null permitted).

Since: 1.0.13

See Also:

setFont

public void setFont(Font font)
Sets the font for the annotation.

Parameters: font the font (null not permitted).

See Also: getFont

setOutlinePaint

public void setOutlinePaint(Paint paint)
Sets the outline paint for the annotation.

Parameters: paint the paint (null not permitted).

Since: 1.0.13

See Also:

setOutlineStroke

public void setOutlineStroke(Stroke stroke)
Sets the outline stroke for the annotation.

Parameters: stroke the stroke (null not permitted).

Since: 1.0.13

See Also:

setOutlineVisible

public void setOutlineVisible(boolean visible)
Sets the flag that controls whether or not the outline is drawn.

Parameters: visible the new flag value.

Since: 1.0.13

setPaint

public void setPaint(Paint paint)
Sets the paint for the annotation.

Parameters: paint the paint (null not permitted).

See Also: getPaint

setRotationAnchor

public void setRotationAnchor(TextAnchor anchor)
Sets the rotation anchor point.

Parameters: anchor the anchor (null not permitted).

See Also: getRotationAnchor

setRotationAngle

public void setRotationAngle(double angle)
Sets the rotation angle. The angle is measured clockwise in radians.

Parameters: angle the angle (in radians).

See Also: getRotationAngle

setText

public void setText(String text)
Sets the text for the annotation.

Parameters: text the text (null not permitted).

See Also: getText

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).

Parameters: anchor the anchor point (null not permitted).

See Also: getTextAnchor

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 (in data space).

See Also: getX

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.

See Also: getY

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.