Package org.jfree.chart.annotations
Class CategoryPointerAnnotation
- 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:
java.io.Serializable,java.lang.Cloneable,Annotation,CategoryAnnotation,PublicCloneable
public class CategoryPointerAnnotation extends CategoryTextAnnotation implements java.lang.Cloneable, PublicCloneable, java.io.Serializable
An arrow and label that can be placed on aCategoryPlot. 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private doubleangleThe angle of the arrow's line (in radians).private doublearrowLengthThe length of the arrow head (in Java2D units).private java.awt.PaintarrowPaintThe arrow paint.private java.awt.StrokearrowStrokeThe arrow stroke.private doublearrowWidthThe arrow width (in Java2D units, per side).private doublebaseRadiusThe radius from the (x, y) point to the start of the arrow line (in Java2D units).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).private doublelabelOffsetThe radius from the base point to the anchor point for the label.private static longserialVersionUIDFor serialization.private doubletipRadiusThe radius from the (x, y) point to the tip of the arrow (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 CategoryPointerAnnotation(java.lang.String label, java.lang.Comparable key, double value, double angle)Creates a new label and arrow annotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.java.lang.Objectclone()Returns a clone of the annotation.voiddraw(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)Draws the annotation.booleanequals(java.lang.Object obj)Tests this annotation for equality with an arbitrary object.doublegetAngle()Returns the angle of the arrow.doublegetArrowLength()Returns the arrow length.java.awt.PaintgetArrowPaint()Returns the paint used for the arrow.java.awt.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.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetAngle(double angle)Sets the angle of the arrow and sends anAnnotationChangeEventto all registered listeners.voidsetArrowLength(double length)Sets the arrow length and sends anAnnotationChangeEventto all registered listeners.voidsetArrowPaint(java.awt.Paint paint)Sets the paint used for the arrow and sends anAnnotationChangeEventto all registered listeners.voidsetArrowStroke(java.awt.Stroke stroke)Sets the stroke used to draw the arrow line and sends anAnnotationChangeEventto all registered listeners.voidsetArrowWidth(double width)Sets the arrow width and sends anAnnotationChangeEventto all registered listeners.voidsetBaseRadius(double radius)Sets the base radius and sends anAnnotationChangeEventto all registered listeners.voidsetLabelOffset(double offset)Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEventto all registered listeners.voidsetTipRadius(double radius)Sets the tip radius and sends anAnnotationChangeEventto all registered listeners.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.-
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 Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
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
-
angle
private double angle
The angle of the arrow's line (in radians).
-
tipRadius
private double tipRadius
The radius from the (x, y) point to the tip of the arrow (in Java2D units).
-
baseRadius
private double baseRadius
The radius from the (x, y) point to the start of the arrow line (in Java2D units).
-
arrowLength
private double arrowLength
The length of the arrow head (in Java2D units).
-
arrowWidth
private double arrowWidth
The arrow width (in Java2D units, per side).
-
arrowStroke
private transient java.awt.Stroke arrowStroke
The arrow stroke.
-
arrowPaint
private transient java.awt.Paint arrowPaint
The arrow paint.
-
labelOffset
private double labelOffset
The radius from the base point to the anchor point for the label.
-
-
Constructor Detail
-
CategoryPointerAnnotation
public CategoryPointerAnnotation(java.lang.String label, java.lang.Comparable key, double value, double angle)Creates a new label and arrow annotation.- Parameters:
label- the label (nullpermitted).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
-
getAngle
public double getAngle()
Returns the angle of the arrow.- Returns:
- The angle (in radians).
- See Also:
setAngle(double)
-
setAngle
public void setAngle(double angle)
Sets the angle of the arrow and sends anAnnotationChangeEventto all registered listeners.- Parameters:
angle- the angle (in radians).- See Also:
getAngle()
-
getTipRadius
public double getTipRadius()
Returns the tip radius.- Returns:
- The tip radius (in Java2D units).
- See Also:
setTipRadius(double)
-
setTipRadius
public void setTipRadius(double radius)
Sets the tip radius and sends anAnnotationChangeEventto all registered listeners.- Parameters:
radius- the radius (in Java2D units).- See Also:
getTipRadius()
-
getBaseRadius
public double getBaseRadius()
Returns the base radius.- Returns:
- The base radius (in Java2D units).
- See Also:
setBaseRadius(double)
-
setBaseRadius
public void setBaseRadius(double radius)
Sets the base radius and sends anAnnotationChangeEventto all registered listeners.- Parameters:
radius- the radius (in Java2D units).- See Also:
getBaseRadius()
-
getLabelOffset
public double getLabelOffset()
Returns the label offset.- Returns:
- The label offset (in Java2D units).
- See Also:
setLabelOffset(double)
-
setLabelOffset
public void setLabelOffset(double offset)
Sets the label offset (from the arrow base, continuing in a straight line, in Java2D units) and sends anAnnotationChangeEventto all registered listeners.- Parameters:
offset- the offset (in Java2D units).- See Also:
getLabelOffset()
-
getArrowLength
public double getArrowLength()
Returns the arrow length.- Returns:
- The arrow length.
- See Also:
setArrowLength(double)
-
setArrowLength
public void setArrowLength(double length)
Sets the arrow length and sends anAnnotationChangeEventto all registered listeners.- Parameters:
length- the length.- See Also:
getArrowLength()
-
getArrowWidth
public double getArrowWidth()
Returns the arrow width.- Returns:
- The arrow width (in Java2D units).
- See Also:
setArrowWidth(double)
-
setArrowWidth
public void setArrowWidth(double width)
Sets the arrow width and sends anAnnotationChangeEventto all registered listeners.- Parameters:
width- the width (in Java2D units).- See Also:
getArrowWidth()
-
getArrowStroke
public java.awt.Stroke getArrowStroke()
Returns the stroke used to draw the arrow line.- Returns:
- The arrow stroke (never
null). - See Also:
setArrowStroke(Stroke)
-
setArrowStroke
public void setArrowStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the arrow line and sends anAnnotationChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getArrowStroke()
-
getArrowPaint
public java.awt.Paint getArrowPaint()
Returns the paint used for the arrow.- Returns:
- The arrow paint (never
null). - See Also:
setArrowPaint(Paint)
-
setArrowPaint
public void setArrowPaint(java.awt.Paint paint)
Sets the paint used for the arrow and sends anAnnotationChangeEventto all registered listeners.- Parameters:
paint- the arrow paint (nullnot permitted).- See Also:
getArrowPaint()
-
draw
public void draw(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis)Draws the annotation.- Specified by:
drawin interfaceCategoryAnnotation- Overrides:
drawin classCategoryTextAnnotation- Parameters:
g2- the graphics device.plot- the plot.dataArea- the data area.domainAxis- the domain axis.rangeAxis- the range axis.
-
equals
public boolean equals(java.lang.Object obj)
Tests this annotation for equality with an arbitrary object.- Overrides:
equalsin classCategoryTextAnnotation- Parameters:
obj- the object (nullpermitted).- Returns:
trueorfalse.
-
canEqual
public boolean canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqualin classCategoryTextAnnotation- Parameters:
other- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCodein classCategoryTextAnnotation- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the annotation.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classCategoryTextAnnotation- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- if the annotation can't be cloned.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides serialization support.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionProvides serialization support.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O error.java.lang.ClassNotFoundException- if there is a classpath problem.
-
-