org.jfree.chart.annotations

Class CategoryPointerAnnotation

public class CategoryPointerAnnotation extends CategoryTextAnnotation implements Cloneable, PublicCloneable, Serializable

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

The arrow length (and its offset from the (category, value) location) is controlled by the tip radius and the base radius attributes. Imagine two circles around the (category, value) 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.

Since: 1.0.3

Field Summary
static doubleDEFAULT_ARROW_LENGTH
The default arrow length (in Java2D units).
static doubleDEFAULT_ARROW_WIDTH
The default arrow width (in Java2D units).
static doubleDEFAULT_BASE_RADIUS
The default base radius (in Java2D units).
static doubleDEFAULT_LABEL_OFFSET
The default label offset (in Java2D units).
static doubleDEFAULT_TIP_RADIUS
The default tip radius (in Java2D units).
Constructor Summary
CategoryPointerAnnotation(String label, Comparable key, double value, double angle)
Creates a new label and arrow annotation.
Method Summary
Objectclone()
Returns a clone of the annotation.
voiddraw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)
Draws the annotation.
booleanequals(Object obj)
Tests this annotation for equality with an arbitrary object.
doublegetAngle()
Returns the angle of the arrow.
doublegetArrowLength()
Returns the arrow length.
PaintgetArrowPaint()
Returns the paint used for the arrow.
StrokegetArrowStroke()
Returns the stroke used to draw the arrow line.
doublegetArrowWidth()
Returns the arrow width.
doublegetBaseRadius()
Returns the base radius.
doublegetLabelOffset()
Returns the label offset.
doublegetTipRadius()
Returns the tip radius.
inthashCode()
Returns a hash code for this instance.
voidsetAngle(double angle)
Sets the angle of the arrow.
voidsetArrowLength(double length)
Sets the arrow length.
voidsetArrowPaint(Paint paint)
Sets the paint used for the arrow.
voidsetArrowStroke(Stroke stroke)
Sets the stroke used to draw the arrow line.
voidsetArrowWidth(double width)
Sets the arrow width.
voidsetBaseRadius(double radius)
Sets the base radius.
voidsetLabelOffset(double offset)
Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units).
voidsetTipRadius(double radius)
Sets the tip radius.

Field Detail

DEFAULT_ARROW_LENGTH

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

DEFAULT_ARROW_WIDTH

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

DEFAULT_BASE_RADIUS

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

DEFAULT_LABEL_OFFSET

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

DEFAULT_TIP_RADIUS

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

Constructor Detail

CategoryPointerAnnotation

public CategoryPointerAnnotation(String label, Comparable key, double value, double angle)
Creates a new label and arrow annotation.

Parameters: label the label (null permitted). key the category key. value the y-value (measured against the chart's range axis). angle the angle of the arrow's line (in radians).

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, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)
Draws the annotation.

Parameters: g2 the graphics device. plot the plot. dataArea the data area. domainAxis the domain axis. rangeAxis the range axis.

equals

public boolean equals(Object obj)
Tests this annotation for equality with an arbitrary object.

Parameters: obj the object (null permitted).

Returns: true or false.

getAngle

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

Returns: The angle (in radians).

See Also: CategoryPointerAnnotation

getArrowLength

public double getArrowLength()
Returns the arrow length.

Returns: The arrow length.

See Also: CategoryPointerAnnotation

getArrowPaint

public Paint getArrowPaint()
Returns the paint used for the arrow.

Returns: The arrow paint (never null).

See Also: setArrowPaint

getArrowStroke

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

Returns: The arrow stroke (never null).

See Also: setArrowStroke

getArrowWidth

public double getArrowWidth()
Returns the arrow width.

Returns: The arrow width (in Java2D units).

See Also: CategoryPointerAnnotation

getBaseRadius

public double getBaseRadius()
Returns the base radius.

Returns: The base radius (in Java2D units).

See Also: CategoryPointerAnnotation

getLabelOffset

public double getLabelOffset()
Returns the label offset.

Returns: The label offset (in Java2D units).

See Also: CategoryPointerAnnotation

getTipRadius

public double getTipRadius()
Returns the tip radius.

Returns: The tip radius (in Java2D units).

See Also: CategoryPointerAnnotation

hashCode

public int hashCode()
Returns a hash code for this instance.

Returns: A hash code.

setAngle

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

Parameters: angle the angle (in radians).

See Also: getAngle

setArrowLength

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

Parameters: length the length.

See Also: getArrowLength

setArrowPaint

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

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

See Also: getArrowPaint

setArrowStroke

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

Parameters: stroke the stroke (null not permitted).

See Also: getArrowStroke

setArrowWidth

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

Parameters: width the width (in Java2D units).

See Also: getArrowWidth

setBaseRadius

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

Parameters: radius the radius (in Java2D units).

See Also: getBaseRadius

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

See Also: getLabelOffset

setTipRadius

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

Parameters: radius the radius (in Java2D units).

See Also: getTipRadius

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