org.jfree.chart.annotations
Class XYPointerAnnotation

java.lang.Object
  extended byorg.jfree.chart.annotations.AbstractXYAnnotation
      extended byorg.jfree.chart.annotations.XYTextAnnotation
          extended byorg.jfree.chart.annotations.XYPointerAnnotation
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, XYAnnotation

public class XYPointerAnnotation
extends XYTextAnnotation
implements java.lang.Cloneable, java.io.Serializable

An arrow and label that can be placed on an XYPlot. The arrow is drawn at a user-definable angle so that it points towards the (x, y) location for the annotation.

The arrow length (and its offset from the (x, y) location) is controlled by the tip radius and the base radius attributes. Imagine two circles around the (x, y) coordinate: the inner circle defined by the tip radius, and the outer circle defined by the base radius. Now, draw the arrow starting at some point on the outer circle (the point is determined by the angle), with the arrow tip being drawn at a corresponding point on the inner circle.

See the MarkerDemo1.java source file in the JFreeChart distribution for an example.

See Also:
Serialized Form

Field Summary
static double DEFAULT_ARROW_LENGTH
          The default arrow length (in Java2D units).
static double DEFAULT_ARROW_WIDTH
          The default arrow width (in Java2D units).
static double DEFAULT_BASE_RADIUS
          The default base radius (in Java2D units).
static double DEFAULT_LABEL_OFFSET
          The default label offset (in Java2D units).
static double DEFAULT_TIP_RADIUS
          The default tip radius (in Java2D units).
 
Fields inherited from class org.jfree.chart.annotations.XYTextAnnotation
DEFAULT_FONT, DEFAULT_PAINT, DEFAULT_ROTATION_ANCHOR, DEFAULT_ROTATION_ANGLE, DEFAULT_TEXT_ANCHOR
 
Constructor Summary
XYPointerAnnotation(java.lang.String label, double x, double y, double angle)
          Creates a new label and arrow annotation.
 
Method Summary
 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 object)
          Tests this annotation for equality with an object.
 double getAngle()
          Returns the angle of the arrow.
 double getArrowLength()
          Returns the arrow length.
 java.awt.Paint getArrowPaint()
          Sets the paint used for the arrow.
 java.awt.Stroke getArrowStroke()
          Returns the stroke used to draw the arrow line.
 double getArrowWidth()
          Returns the arrow width.
 double getBaseRadius()
          Sets the base radius.
 double getLabelOffset()
          Sets the label offset.
 double getTipRadius()
          Returns the tip radius.
 void setAngle(double angle)
          Sets the angle of the arrow.
 void setArrowLength(double length)
          Sets the arrow length.
 void setArrowPaint(java.awt.Paint paint)
          Sets the paint used for the arrow.
 void setArrowStroke(java.awt.Stroke stroke)
          Sets the stroke used to draw the arrow line.
 void setArrowWidth(double width)
          Sets the arrow width.
 void setBaseRadius(double radius)
          Sets the base radius.
 void setLabelOffset(double offset)
          Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units).
 void setTipRadius(double radius)
          Sets the tip radius.
 
Methods inherited from class org.jfree.chart.annotations.XYTextAnnotation
getFont, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, getX, getY, hashCode, setFont, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor, setX, setY
 
Methods inherited from class org.jfree.chart.annotations.AbstractXYAnnotation
addEntity, getToolTipText, getURL, setToolTipText, setURL
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIP_RADIUS

public static final double DEFAULT_TIP_RADIUS
The default tip radius (in Java2D units).

See Also:
Constant Field Values

DEFAULT_BASE_RADIUS

public static final double DEFAULT_BASE_RADIUS
The default base radius (in Java2D units).

See Also:
Constant Field Values

DEFAULT_LABEL_OFFSET

public static final double DEFAULT_LABEL_OFFSET
The default label offset (in Java2D units).

See Also:
Constant Field Values

DEFAULT_ARROW_LENGTH

public static final double DEFAULT_ARROW_LENGTH
The default arrow length (in Java2D units).

See Also:
Constant Field Values

DEFAULT_ARROW_WIDTH

public static final double DEFAULT_ARROW_WIDTH
The default arrow width (in Java2D units).

See Also:
Constant Field Values
Constructor Detail

XYPointerAnnotation

public XYPointerAnnotation(java.lang.String label,
                           double x,
                           double y,
                           double angle)
Creates a new label and arrow annotation.

Parameters:
label - the label (null permitted).
x - the x-coordinate (measured against the chart's domain axis).
y - the y-coordinate (measured against the chart's range axis).
angle - the angle of the arrow's line (in radians).
Method Detail

getAngle

public double getAngle()
Returns the angle of the arrow.

Returns:
The angle (in radians).

setAngle

public void setAngle(double angle)
Sets the angle of the arrow.

Parameters:
angle - the angle (in radians).

getTipRadius

public double getTipRadius()
Returns the tip radius.

Returns:
The tip radius (in Java2D units).

setTipRadius

public void setTipRadius(double radius)
Sets the tip radius.

Parameters:
radius - the radius (in Java2D units).

getBaseRadius

public double getBaseRadius()
Sets the base radius.

Returns:
The base radius (in Java2D units).

setBaseRadius

public void setBaseRadius(double radius)
Sets the base radius.

Parameters:
radius - the radius (in Java2D units).

getLabelOffset

public double getLabelOffset()
Sets the label offset.

Returns:
The label offset (in Java2D units).

setLabelOffset

public void setLabelOffset(double offset)
Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units).

Parameters:
offset - the offset (in Java2D units).

getArrowLength

public double getArrowLength()
Returns the arrow length.

Returns:
The arrow length.

setArrowLength

public void setArrowLength(double length)
Sets the arrow length.

Parameters:
length - the length.

getArrowWidth

public double getArrowWidth()
Returns the arrow width.

Returns:
The arrow width (in Java2D units).

setArrowWidth

public void setArrowWidth(double width)
Sets the arrow width.

Parameters:
width - the width (in Java2D units).

getArrowStroke

public java.awt.Stroke getArrowStroke()
Returns the stroke used to draw the arrow line.

Returns:
The arrow stroke (never null).

setArrowStroke

public void setArrowStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the arrow line.

Parameters:
stroke - the stroke (null not permitted).

getArrowPaint

public java.awt.Paint getArrowPaint()
Sets the paint used for the arrow.

Returns:
The arrow paint (never null).

setArrowPaint

public void setArrowPaint(java.awt.Paint paint)
Sets the paint used for the arrow.

Parameters:
paint - the arrow paint (null not permitted).

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 interface XYAnnotation
Overrides:
draw in class XYTextAnnotation
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 - the plot rendering info.

equals

public boolean equals(java.lang.Object object)
Tests this annotation for equality with an object.

Overrides:
equals in class XYTextAnnotation
Parameters:
object - the object to test against.
Returns:
true or false.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the annotation.

Overrides:
clone in class XYTextAnnotation
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - if the annotation can't be cloned.