java.lang.Object
org.jfree.chart.annotations.AbstractAnnotation
org.jfree.chart.annotations.TextAnnotation
org.jfree.chart.annotations.CategoryTextAnnotation
org.jfree.chart.annotations.CategoryPointerAnnotation
- All Implemented Interfaces:
Serializable
,Cloneable
,Annotation
,CategoryAnnotation
,PublicCloneable
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.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The default arrow length (in Java2D units).static final double
The default arrow width (in Java2D units).static final double
The default base radius (in Java2D units).static final double
The default label offset (in Java2D units).static final double
The 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
ConstructorDescriptionCategoryPointerAnnotation
(String label, Comparable key, double value, double angle) Creates a new label and arrow annotation. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of the annotation.void
draw
(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) Draws the annotation.boolean
Tests this annotation for equality with an arbitrary object.double
getAngle()
Returns the angle of the arrow.double
Returns the arrow length.Returns the paint used for the arrow.Returns the stroke used to draw the arrow line.double
Returns the arrow width.double
Returns the base radius.double
Returns the label offset.double
Returns the tip radius.int
hashCode()
Returns a hash code for this instance.void
setAngle
(double angle) Sets the angle of the arrow and sends anAnnotationChangeEvent
to all registered listeners.void
setArrowLength
(double length) Sets the arrow length and sends anAnnotationChangeEvent
to all registered listeners.void
setArrowPaint
(Paint paint) Sets the paint used for the arrow and sends anAnnotationChangeEvent
to all registered listeners.void
setArrowStroke
(Stroke stroke) Sets the stroke used to draw the arrow line and sends anAnnotationChangeEvent
to all registered listeners.void
setArrowWidth
(double width) Sets the arrow width and sends anAnnotationChangeEvent
to all registered listeners.void
setBaseRadius
(double radius) Sets the base radius and sends anAnnotationChangeEvent
to all registered listeners.void
setLabelOffset
(double offset) Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEvent
to all registered listeners.void
setTipRadius
(double radius) Sets the tip radius and sends anAnnotationChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.annotations.CategoryTextAnnotation
getCategory, getCategoryAnchor, getValue, setCategory, setCategoryAnchor, setValue
Methods inherited from class org.jfree.chart.annotations.TextAnnotation
getFont, getPaint, getRotationAnchor, getRotationAngle, getText, getTextAnchor, setFont, setPaint, setRotationAnchor, setRotationAngle, setText, setTextAnchor
Methods inherited from class org.jfree.chart.annotations.AbstractAnnotation
addChangeListener, fireAnnotationChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.chart.annotations.Annotation
addChangeListener, removeChangeListener
-
Field Details
-
DEFAULT_TIP_RADIUS
public static final double DEFAULT_TIP_RADIUSThe default tip radius (in Java2D units).- See Also:
-
DEFAULT_BASE_RADIUS
public static final double DEFAULT_BASE_RADIUSThe default base radius (in Java2D units).- See Also:
-
DEFAULT_LABEL_OFFSET
public static final double DEFAULT_LABEL_OFFSETThe default label offset (in Java2D units).- See Also:
-
DEFAULT_ARROW_LENGTH
public static final double DEFAULT_ARROW_LENGTHThe default arrow length (in Java2D units).- See Also:
-
DEFAULT_ARROW_WIDTH
public static final double DEFAULT_ARROW_WIDTHThe default arrow width (in Java2D units).- See Also:
-
-
Constructor Details
-
CategoryPointerAnnotation
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 Details
-
getAngle
public double getAngle()Returns the angle of the arrow.- Returns:
- The angle (in radians).
- See Also:
-
setAngle
public void setAngle(double angle) Sets the angle of the arrow and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
angle
- the angle (in radians).- See Also:
-
getTipRadius
public double getTipRadius()Returns the tip radius.- Returns:
- The tip radius (in Java2D units).
- See Also:
-
setTipRadius
public void setTipRadius(double radius) Sets the tip radius and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
radius
- the radius (in Java2D units).- See Also:
-
getBaseRadius
public double getBaseRadius()Returns the base radius.- Returns:
- The base radius (in Java2D units).
- See Also:
-
setBaseRadius
public void setBaseRadius(double radius) Sets the base radius and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
radius
- the radius (in Java2D units).- See Also:
-
getLabelOffset
public double getLabelOffset()Returns the label offset.- Returns:
- The label offset (in Java2D units).
- See Also:
-
setLabelOffset
public void setLabelOffset(double offset) Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
offset
- the offset (in Java2D units).- See Also:
-
getArrowLength
public double getArrowLength()Returns the arrow length.- Returns:
- The arrow length.
- See Also:
-
setArrowLength
public void setArrowLength(double length) Sets the arrow length and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
length
- the length.- See Also:
-
getArrowWidth
public double getArrowWidth()Returns the arrow width.- Returns:
- The arrow width (in Java2D units).
- See Also:
-
setArrowWidth
public void setArrowWidth(double width) Sets the arrow width and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
width
- the width (in Java2D units).- See Also:
-
getArrowStroke
Returns the stroke used to draw the arrow line.- Returns:
- The arrow stroke (never
null
). - See Also:
-
setArrowStroke
Sets the stroke used to draw the arrow line and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
-
getArrowPaint
Returns the paint used for the arrow.- Returns:
- The arrow paint (never
null
). - See Also:
-
setArrowPaint
Sets the paint used for the arrow and sends anAnnotationChangeEvent
to all registered listeners.- Parameters:
paint
- the arrow paint (null
not permitted).- See Also:
-
draw
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) Draws the annotation.- Specified by:
draw
in interfaceCategoryAnnotation
- Overrides:
draw
in classCategoryTextAnnotation
- 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 arbitrary object.- Overrides:
equals
in classCategoryTextAnnotation
- Parameters:
obj
- the object (null
permitted).- Returns:
true
orfalse
.
-
hashCode
public int hashCode()Returns a hash code for this instance.- Overrides:
hashCode
in classCategoryTextAnnotation
- Returns:
- A hash code.
-
clone
Returns a clone of the annotation.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classCategoryTextAnnotation
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if the annotation can't be cloned.
-