Package org.jfree.chart.annotations
Class XYPointerAnnotation
java.lang.Object
org.jfree.chart.annotations.TextAnnotation
org.jfree.chart.annotations.XYTextAnnotation
org.jfree.chart.annotations.XYPointerAnnotation
- All Implemented Interfaces:
Serializable,Cloneable,XYAnnotation
public class XYPointerAnnotation extends XYTextAnnotation implements XYAnnotation, Cloneable, 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
Fields Modifier and Type Field Description static doubleDEFAULT_ARROW_LENGTHThe default arrow length (in Java2D units).static doubleDEFAULT_ARROW_WIDTHThe default arrow width (in Java2D units).static doubleDEFAULT_BASE_RADIUSThe default base radius (in Java2D units).static doubleDEFAULT_LABEL_OFFSETThe default label offset (in Java2D units).static doubleDEFAULT_TIP_RADIUSThe default tip radius (in Java2D units).Fields inherited from class org.jfree.chart.annotations.TextAnnotation
DEFAULT_FONT, DEFAULT_PAINT, DEFAULT_ROTATION_ANCHOR, DEFAULT_ROTATION_ANGLE, DEFAULT_TEXT_ANCHOR -
Constructor Summary
Constructors Constructor Description XYPointerAnnotation(String label, double x, double y, double angle)Creates a new label and arrow annotation. -
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)Draws the annotation.booleanequals(Object object)Tests this annotation for equality with an object.doublegetAngle()Returns the angle of the arrow.doublegetArrowLength()Returns the arrow length.PaintgetArrowPaint()Sets the paint used for the arrow.StrokegetArrowStroke()Returns the stroke used to draw the arrow line.doublegetArrowWidth()Returns the arrow width.doublegetBaseRadius()Sets the base radius.doublegetLabelOffset()Sets the label offset.doublegetTipRadius()Returns the tip radius.voidsetAngle(double angle)Sets the angle.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.Methods inherited from class org.jfree.chart.annotations.XYTextAnnotation
getX, getY, setX, setYMethods inherited from class org.jfree.chart.annotations.TextAnnotation
getFont, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, setFont, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor
-
Field Details
-
DEFAULT_TIP_RADIUS
public static final double DEFAULT_TIP_RADIUSThe default tip radius (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_BASE_RADIUS
public static final double DEFAULT_BASE_RADIUSThe default base radius (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_LABEL_OFFSET
public static final double DEFAULT_LABEL_OFFSETThe default label offset (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_ARROW_LENGTH
public static final double DEFAULT_ARROW_LENGTHThe default arrow length (in Java2D units).- See Also:
- Constant Field Values
-
DEFAULT_ARROW_WIDTH
public static final double DEFAULT_ARROW_WIDTHThe default arrow width (in Java2D units).- See Also:
- Constant Field Values
-
-
Constructor Details
-
XYPointerAnnotation
Creates a new label and arrow annotation.- Parameters:
label- the label.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 Details
-
getAngle
public double getAngle()Returns the angle of the arrow.- Returns:
- The angle.
-
setAngle
public void setAngle(double angle)Sets the angle.- Parameters:
angle- the angle.
-
getTipRadius
public double getTipRadius()Returns the tip radius.- Returns:
- The tip radius.
-
setTipRadius
public void setTipRadius(double radius)Sets the tip radius.- Parameters:
radius- the radius.
-
getBaseRadius
public double getBaseRadius()Sets the base radius.- Returns:
- The base radius.
-
setBaseRadius
public void setBaseRadius(double radius)Sets the base radius.- Parameters:
radius- The radius.
-
getLabelOffset
public double getLabelOffset()Sets the label offset.- Returns:
- The label offset.
-
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.
-
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.
-
setArrowWidth
public void setArrowWidth(double width)Sets the arrow width.- Parameters:
width- the width.
-
getArrowStroke
Returns the stroke used to draw the arrow line.- Returns:
- The arrow stroke.
-
setArrowStroke
Sets the stroke used to draw the arrow line.- Parameters:
stroke- the stroke.
-
getArrowPaint
Sets the paint used for the arrow.- Returns:
- The arrow paint.
-
setArrowPaint
Sets the paint used for the arrow.- Parameters:
paint- the arrow paint.
-
draw
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis)Draws the annotation.- Specified by:
drawin interfaceXYAnnotation- Overrides:
drawin classXYTextAnnotation- Parameters:
g2- the graphics device.plot- the plot.dataArea- the data area.domainAxis- the domain axis.rangeAxis- the range axis.
-
equals
Tests this annotation for equality with an object.- Overrides:
equalsin classTextAnnotation- Parameters:
object- the object to test against.- Returns:
trueorfalse.
-
clone
Returns a clone of the annotation.- Overrides:
clonein classXYTextAnnotation- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if the annotation can't be cloned.
-