Package org.jfree.chart.plot
Class Marker
- java.lang.Object
-
- org.jfree.chart.plot.Marker
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
CategoryMarker
,IntervalMarker
,ValueMarker
public abstract class Marker extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
The base class for markers that can be added to plots to highlight a value or range of values.
An event notification mechanism was added to this class in JFreeChart version 1.0.3.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private float
alpha
The alpha transparency.private java.lang.String
label
The label.private RectangleAnchor
labelAnchor
The label position.private java.awt.Color
labelBackgroundColor
The label background color.private java.awt.Font
labelFont
The label font.private RectangleInsets
labelOffset
The label offset from the marker rectangle.private LengthAdjustmentType
labelOffsetType
The offset type for the domain or range axis (nevernull
).private java.awt.Paint
labelPaint
The label paint.private TextAnchor
labelTextAnchor
The text anchor for the label.private javax.swing.event.EventListenerList
listenerList
Storage for registered change listeners.private java.awt.Paint
outlinePaint
The outline paint.private java.awt.Stroke
outlineStroke
The outline stroke.private java.awt.Paint
paint
The paint (null is not allowed).private static long
serialVersionUID
For serialization.private java.awt.Stroke
stroke
The stroke (null is not allowed).
-
Constructor Summary
Constructors Modifier Constructor Description protected
Marker()
Creates a new marker with default attributes.protected
Marker(java.awt.Paint paint)
Constructs a new marker.protected
Marker(java.awt.Paint paint, java.awt.Stroke stroke, java.awt.Paint outlinePaint, java.awt.Stroke outlineStroke, float alpha)
Constructs a new marker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(MarkerChangeListener listener)
Registers an object for notification of changes to the marker.boolean
canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals.java.lang.Object
clone()
Creates a clone of the marker.boolean
equals(java.lang.Object obj)
Tests the marker for equality with an arbitrary object.float
getAlpha()
Returns the alpha transparency.java.lang.String
getLabel()
Returns the label (ifnull
no label is displayed).RectangleAnchor
getLabelAnchor()
Returns the label anchor.java.awt.Color
getLabelBackgroundColor()
Returns the label background color.java.awt.Font
getLabelFont()
Returns the label font.RectangleInsets
getLabelOffset()
Returns the label offset.LengthAdjustmentType
getLabelOffsetType()
Returns the label offset type.java.awt.Paint
getLabelPaint()
Returns the label paint.TextAnchor
getLabelTextAnchor()
Returns the label text anchor.java.util.EventListener[]
getListeners(java.lang.Class listenerType)
Returns an array containing all the listeners of the specified type.java.awt.Paint
getOutlinePaint()
Returns the outline paint.java.awt.Stroke
getOutlineStroke()
Returns the outline stroke.java.awt.Paint
getPaint()
Returns the paint.java.awt.Stroke
getStroke()
Returns the stroke.int
hashCode()
void
notifyListeners(MarkerChangeEvent event)
Notifies all registered listeners that the marker has been modified.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
removeChangeListener(MarkerChangeListener listener)
Unregisters an object for notification of changes to the marker.void
setAlpha(float alpha)
Sets the alpha transparency that should be used when drawing the marker, and sends aMarkerChangeEvent
to all registered listeners.void
setLabel(java.lang.String label)
Sets the label (ifnull
no label is displayed) and sends aMarkerChangeEvent
to all registered listeners.void
setLabelAnchor(RectangleAnchor anchor)
Sets the label anchor and sends aMarkerChangeEvent
to all registered listeners.void
setLabelBackgroundColor(java.awt.Color color)
Sets the label background color.void
setLabelFont(java.awt.Font font)
Sets the label font and sends aMarkerChangeEvent
to all registered listeners.void
setLabelOffset(RectangleInsets offset)
Sets the label offset and sends aMarkerChangeEvent
to all registered listeners.void
setLabelOffsetType(LengthAdjustmentType adj)
Sets the label offset type and sends aMarkerChangeEvent
to all registered listeners.void
setLabelPaint(java.awt.Paint paint)
Sets the label paint and sends aMarkerChangeEvent
to all registered listeners.void
setLabelTextAnchor(TextAnchor anchor)
Sets the label text anchor and sends aMarkerChangeEvent
to all registered listeners.void
setOutlinePaint(java.awt.Paint paint)
Sets the outline paint and sends aMarkerChangeEvent
to all registered listeners.void
setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke and sends aMarkerChangeEvent
to all registered listeners.void
setPaint(java.awt.Paint paint)
Sets the paint and sends aMarkerChangeEvent
to all registered listeners.void
setStroke(java.awt.Stroke stroke)
Sets the stroke and sends aMarkerChangeEvent
to all registered listeners.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
paint
private transient java.awt.Paint paint
The paint (null is not allowed).
-
stroke
private transient java.awt.Stroke stroke
The stroke (null is not allowed).
-
outlinePaint
private transient java.awt.Paint outlinePaint
The outline paint.
-
outlineStroke
private transient java.awt.Stroke outlineStroke
The outline stroke.
-
alpha
private float alpha
The alpha transparency.
-
label
private java.lang.String label
The label.
-
labelFont
private java.awt.Font labelFont
The label font.
-
labelPaint
private transient java.awt.Paint labelPaint
The label paint.
-
labelBackgroundColor
private java.awt.Color labelBackgroundColor
The label background color.
-
labelAnchor
private RectangleAnchor labelAnchor
The label position.
-
labelTextAnchor
private TextAnchor labelTextAnchor
The text anchor for the label.
-
labelOffset
private RectangleInsets labelOffset
The label offset from the marker rectangle.
-
labelOffsetType
private LengthAdjustmentType labelOffsetType
The offset type for the domain or range axis (nevernull
).
-
listenerList
private transient javax.swing.event.EventListenerList listenerList
Storage for registered change listeners.
-
-
Constructor Detail
-
Marker
protected Marker()
Creates a new marker with default attributes.
-
Marker
protected Marker(java.awt.Paint paint)
Constructs a new marker.- Parameters:
paint
- the paint (null
not permitted).
-
Marker
protected Marker(java.awt.Paint paint, java.awt.Stroke stroke, java.awt.Paint outlinePaint, java.awt.Stroke outlineStroke, float alpha)
Constructs a new marker.- Parameters:
paint
- the paint (null
not permitted).stroke
- the stroke (null
not permitted).outlinePaint
- the outline paint (null
permitted).outlineStroke
- the outline stroke (null
permitted).alpha
- the alpha transparency (must be in the range 0.0f to 1.0f).- Throws:
java.lang.IllegalArgumentException
- ifpaint
orstroke
isnull
, oralpha
is not in the specified range.
-
-
Method Detail
-
getPaint
public java.awt.Paint getPaint()
Returns the paint.- Returns:
- The paint (never
null
). - See Also:
setPaint(Paint)
-
setPaint
public void setPaint(java.awt.Paint paint)
Sets the paint and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getPaint()
-
getStroke
public java.awt.Stroke getStroke()
Returns the stroke.- Returns:
- The stroke (never
null
). - See Also:
setStroke(Stroke)
-
setStroke
public void setStroke(java.awt.Stroke stroke)
Sets the stroke and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
getStroke()
-
getOutlinePaint
public java.awt.Paint getOutlinePaint()
Returns the outline paint.- Returns:
- The outline paint (possibly
null
). - See Also:
setOutlinePaint(Paint)
-
setOutlinePaint
public void setOutlinePaint(java.awt.Paint paint)
Sets the outline paint and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
permitted).- See Also:
getOutlinePaint()
-
getOutlineStroke
public java.awt.Stroke getOutlineStroke()
Returns the outline stroke.- Returns:
- The outline stroke (possibly
null
). - See Also:
setOutlineStroke(Stroke)
-
setOutlineStroke
public void setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
permitted).- See Also:
getOutlineStroke()
-
getAlpha
public float getAlpha()
Returns the alpha transparency.- Returns:
- The alpha transparency.
- See Also:
setAlpha(float)
-
setAlpha
public void setAlpha(float alpha)
Sets the alpha transparency that should be used when drawing the marker, and sends aMarkerChangeEvent
to all registered listeners. The alpha transparency is a value in the range 0.0f (completely transparent) to 1.0f (completely opaque).- Parameters:
alpha
- the alpha transparency (must be in the range 0.0f to 1.0f).- Throws:
java.lang.IllegalArgumentException
- ifalpha
is not in the specified range.- See Also:
getAlpha()
-
getLabel
public java.lang.String getLabel()
Returns the label (ifnull
no label is displayed).- Returns:
- The label (possibly
null
). - See Also:
setLabel(String)
-
setLabel
public void setLabel(java.lang.String label)
Sets the label (ifnull
no label is displayed) and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
label
- the label (null
permitted).- See Also:
getLabel()
-
getLabelFont
public java.awt.Font getLabelFont()
Returns the label font.- Returns:
- The label font (never
null
). - See Also:
setLabelFont(Font)
-
setLabelFont
public void setLabelFont(java.awt.Font font)
Sets the label font and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
font
- the font (null
not permitted).- See Also:
getLabelFont()
-
getLabelPaint
public java.awt.Paint getLabelPaint()
Returns the label paint.- Returns:
- The label paint (never
null
). - See Also:
setLabelPaint(Paint)
-
setLabelPaint
public void setLabelPaint(java.awt.Paint paint)
Sets the label paint and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getLabelPaint()
-
getLabelBackgroundColor
public java.awt.Color getLabelBackgroundColor()
Returns the label background color. The default value isColor(100, 100, 100, 100)
..- Returns:
- The label background color (never
null
).
-
setLabelBackgroundColor
public void setLabelBackgroundColor(java.awt.Color color)
Sets the label background color.- Parameters:
color
- the color (null
not permitted).
-
getLabelAnchor
public RectangleAnchor getLabelAnchor()
Returns the label anchor. This defines the position of the label anchor, relative to the bounds of the marker.- Returns:
- The label anchor (never
null
). - See Also:
setLabelAnchor(RectangleAnchor)
-
setLabelAnchor
public void setLabelAnchor(RectangleAnchor anchor)
Sets the label anchor and sends aMarkerChangeEvent
to all registered listeners. The anchor defines the position of the label anchor, relative to the bounds of the marker.- Parameters:
anchor
- the anchor (null
not permitted).- See Also:
getLabelAnchor()
-
getLabelOffset
public RectangleInsets getLabelOffset()
Returns the label offset.- Returns:
- The label offset (never
null
). - See Also:
setLabelOffset(RectangleInsets)
-
setLabelOffset
public void setLabelOffset(RectangleInsets offset)
Sets the label offset and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
offset
- the label offset (null
not permitted).- See Also:
getLabelOffset()
-
getLabelOffsetType
public LengthAdjustmentType getLabelOffsetType()
Returns the label offset type.- Returns:
- The type (never
null
). - See Also:
setLabelOffsetType(LengthAdjustmentType)
-
setLabelOffsetType
public void setLabelOffsetType(LengthAdjustmentType adj)
Sets the label offset type and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
adj
- the type (null
not permitted).- See Also:
getLabelOffsetType()
-
getLabelTextAnchor
public TextAnchor getLabelTextAnchor()
Returns the label text anchor.- Returns:
- The label text anchor (never
null
). - See Also:
setLabelTextAnchor(TextAnchor)
-
setLabelTextAnchor
public void setLabelTextAnchor(TextAnchor anchor)
Sets the label text anchor and sends aMarkerChangeEvent
to all registered listeners.- Parameters:
anchor
- the label text anchor (null
not permitted).- See Also:
getLabelTextAnchor()
-
addChangeListener
public void addChangeListener(MarkerChangeListener listener)
Registers an object for notification of changes to the marker.- Parameters:
listener
- the object to be registered.- See Also:
removeChangeListener(MarkerChangeListener)
-
removeChangeListener
public void removeChangeListener(MarkerChangeListener listener)
Unregisters an object for notification of changes to the marker.- Parameters:
listener
- the object to be unregistered.- See Also:
addChangeListener(MarkerChangeListener)
-
notifyListeners
public void notifyListeners(MarkerChangeEvent event)
Notifies all registered listeners that the marker has been modified.- Parameters:
event
- information about the change event.
-
getListeners
public java.util.EventListener[] getListeners(java.lang.Class listenerType)
Returns an array containing all the listeners of the specified type.- Parameters:
listenerType
- the listener type.- Returns:
- The array of listeners.
-
equals
public boolean equals(java.lang.Object obj)
Tests the marker for equality with an arbitrary object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
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.- Parameters:
other
- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Creates a clone of the marker.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- never.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides 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.ClassNotFoundException
Provides 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.
-
-