Package org.jfree.chart.plot.dial
Class DialValueIndicator
- java.lang.Object
-
- org.jfree.chart.plot.dial.AbstractDialLayer
-
- org.jfree.chart.plot.dial.DialValueIndicator
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,DialLayer
,PublicCloneable
public class DialValueIndicator extends AbstractDialLayer implements DialLayer, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A value indicator for aDialPlot
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private double
angle
The angle that defines the anchor point.private java.awt.Paint
backgroundPaint
The background paint.private int
datasetIndex
The dataset index.private java.awt.Font
font
The font.private java.text.NumberFormat
formatter
The formatter.private RectangleAnchor
frameAnchor
The frame anchor.private RectangleInsets
insets
The insets.private java.lang.Number
maxTemplateValue
A data value that will be formatted to determine the maximum size of the indicator bounds.private java.awt.Paint
outlinePaint
The outline paint.private java.awt.Stroke
outlineStroke
The outline stroke.private java.awt.Paint
paint
The paint.private double
radius
The radius that defines the anchor point.(package private) static long
serialVersionUID
For serialization.private java.lang.Number
templateValue
The template value.private TextAnchor
textAnchor
The text anchor for displaying the value.private RectangleAnchor
valueAnchor
The value anchor.
-
Constructor Summary
Constructors Constructor Description DialValueIndicator()
Creates a new instance ofDialValueIndicator
.DialValueIndicator(int datasetIndex)
Creates a new instance ofDialValueIndicator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a clone of this instance.void
draw(java.awt.Graphics2D g2, DialPlot plot, java.awt.geom.Rectangle2D frame, java.awt.geom.Rectangle2D view)
Draws the background to the specified graphics device.boolean
equals(java.lang.Object obj)
Tests this instance for equality with an arbitrary object.private double
fixToRange(double x, double minX, double maxX)
A utility method that adjusts a value, if necessary, to be within a specified range.double
getAngle()
Returns the angle for the anchor point.java.awt.Paint
getBackgroundPaint()
Returns the background paint.int
getDatasetIndex()
Returns the index of the dataset from which this indicator fetches its current value.java.awt.Font
getFont()
Returns the font.RectangleAnchor
getFrameAnchor()
Returns the frame anchor.RectangleInsets
getInsets()
Returns the insets.java.lang.Number
getMaxTemplateValue()
Returns the template value for the maximum size of the indicator bounds.java.text.NumberFormat
getNumberFormat()
Returns the formatter used to format the value.java.awt.Paint
getOutlinePaint()
Returns the outline paint.java.awt.Stroke
getOutlineStroke()
Returns the outline stroke.java.awt.Paint
getPaint()
Returns the paint.double
getRadius()
Returns the radius.java.lang.Number
getTemplateValue()
Returns the template value.TextAnchor
getTextAnchor()
Returns the text anchor.RectangleAnchor
getValueAnchor()
Returns the value anchor.int
hashCode()
Returns a hash code for this instance.boolean
isClippedToWindow()
Returnstrue
to indicate that this layer should be clipped within the dial window.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setAngle(double angle)
Sets the angle for the anchor point and sends aDialLayerChangeEvent
to all registered listeners.void
setBackgroundPaint(java.awt.Paint paint)
Sets the background paint and sends aDialLayerChangeEvent
to all registered listeners.void
setDatasetIndex(int index)
Sets the dataset index and sends aDialLayerChangeEvent
to all registered listeners.void
setFont(java.awt.Font font)
Sets the font and sends aDialLayerChangeEvent
to all registered listeners.void
setFrameAnchor(RectangleAnchor anchor)
Sets the frame anchor and sends aDialLayerChangeEvent
to all registered listeners.void
setInsets(RectangleInsets insets)
Sets the insets and sends aDialLayerChangeEvent
to all registered listeners.void
setMaxTemplateValue(java.lang.Number value)
Sets the template value for the maximum size of the indicator bounds and sends aDialLayerChangeEvent
to all registered listeners.void
setNumberFormat(java.text.NumberFormat formatter)
Sets the formatter used to format the value and sends aDialLayerChangeEvent
to all registered listeners.void
setOutlinePaint(java.awt.Paint paint)
Sets the outline paint and sends aDialLayerChangeEvent
to all registered listeners.void
setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke and sends aDialLayerChangeEvent
to all registered listeners.void
setPaint(java.awt.Paint paint)
Sets the paint and sends aDialLayerChangeEvent
to all registered listeners.void
setRadius(double radius)
Sets the radius and sends aDialLayerChangeEvent
to all registered listeners.void
setTemplateValue(java.lang.Number value)
Sets the template value and sends aDialLayerChangeEvent
to all registered listeners.void
setTextAnchor(TextAnchor anchor)
Sets the text anchor and sends aDialLayerChangeEvent
to all registered listeners.void
setValueAnchor(RectangleAnchor anchor)
Sets the value anchor and sends aDialLayerChangeEvent
to all registered listeners.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
Methods inherited from class org.jfree.chart.plot.dial.AbstractDialLayer
addChangeListener, hasListener, isVisible, notifyListeners, removeChangeListener, setVisible
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.chart.plot.dial.DialLayer
addChangeListener, hasListener, isVisible, removeChangeListener
-
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
datasetIndex
private int datasetIndex
The dataset index.
-
angle
private double angle
The angle that defines the anchor point.
-
radius
private double radius
The radius that defines the anchor point.
-
frameAnchor
private RectangleAnchor frameAnchor
The frame anchor.
-
templateValue
private java.lang.Number templateValue
The template value.
-
maxTemplateValue
private java.lang.Number maxTemplateValue
A data value that will be formatted to determine the maximum size of the indicator bounds. If this is null, the indicator bounds can grow as large as necessary to contain the actual data value.
-
formatter
private java.text.NumberFormat formatter
The formatter.
-
font
private java.awt.Font font
The font.
-
paint
private transient java.awt.Paint paint
The paint.
-
backgroundPaint
private transient java.awt.Paint backgroundPaint
The background paint.
-
outlineStroke
private transient java.awt.Stroke outlineStroke
The outline stroke.
-
outlinePaint
private transient java.awt.Paint outlinePaint
The outline paint.
-
insets
private RectangleInsets insets
The insets.
-
valueAnchor
private RectangleAnchor valueAnchor
The value anchor.
-
textAnchor
private TextAnchor textAnchor
The text anchor for displaying the value.
-
-
Method Detail
-
getDatasetIndex
public int getDatasetIndex()
Returns the index of the dataset from which this indicator fetches its current value.- Returns:
- The dataset index.
- See Also:
setDatasetIndex(int)
-
setDatasetIndex
public void setDatasetIndex(int index)
Sets the dataset index and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
index
- the index.- See Also:
getDatasetIndex()
-
getAngle
public double getAngle()
Returns the angle for the anchor point. The angle is specified in degrees using the same orientation as Java'sArc2D
class.- Returns:
- The angle (in degrees).
- See Also:
setAngle(double)
-
setAngle
public void setAngle(double angle)
Sets the angle for the anchor point and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
angle
- the angle (in degrees).- See Also:
getAngle()
-
getRadius
public double getRadius()
Returns the radius.- Returns:
- The radius.
- See Also:
setRadius(double)
-
setRadius
public void setRadius(double radius)
Sets the radius and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
radius
- the radius.- See Also:
getRadius()
-
getFrameAnchor
public RectangleAnchor getFrameAnchor()
Returns the frame anchor.- Returns:
- The frame anchor.
- See Also:
setFrameAnchor(RectangleAnchor)
-
setFrameAnchor
public void setFrameAnchor(RectangleAnchor anchor)
Sets the frame anchor and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor (null
not permitted).- See Also:
getFrameAnchor()
-
getTemplateValue
public java.lang.Number getTemplateValue()
Returns the template value.- Returns:
- The template value (never
null
). - See Also:
setTemplateValue(Number)
-
setTemplateValue
public void setTemplateValue(java.lang.Number value)
Sets the template value and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
value
- the value (null
not permitted).- See Also:
setTemplateValue(Number)
-
getMaxTemplateValue
public java.lang.Number getMaxTemplateValue()
Returns the template value for the maximum size of the indicator bounds.- Returns:
- The template value (possibly
null
). - See Also:
setMaxTemplateValue(java.lang.Number)
-
setMaxTemplateValue
public void setMaxTemplateValue(java.lang.Number value)
Sets the template value for the maximum size of the indicator bounds and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
value
- the value (null
permitted).- See Also:
getMaxTemplateValue()
-
getNumberFormat
public java.text.NumberFormat getNumberFormat()
Returns the formatter used to format the value.- Returns:
- The formatter (never
null
). - See Also:
setNumberFormat(NumberFormat)
-
setNumberFormat
public void setNumberFormat(java.text.NumberFormat formatter)
Sets the formatter used to format the value and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
formatter
- the formatter (null
not permitted).- See Also:
getNumberFormat()
-
getFont
public java.awt.Font getFont()
Returns the font.- Returns:
- The font (never
null
). - See Also:
getFont()
-
setFont
public void setFont(java.awt.Font font)
Sets the font and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
font
- the font (null
not permitted).
-
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 aDialLayerChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getPaint()
-
getBackgroundPaint
public java.awt.Paint getBackgroundPaint()
Returns the background paint.- Returns:
- The background paint.
- See Also:
setBackgroundPaint(Paint)
-
setBackgroundPaint
public void setBackgroundPaint(java.awt.Paint paint)
Sets the background paint and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getBackgroundPaint()
-
getOutlineStroke
public java.awt.Stroke getOutlineStroke()
Returns the outline stroke.- Returns:
- The outline stroke (never
null
). - See Also:
setOutlineStroke(Stroke)
-
setOutlineStroke
public void setOutlineStroke(java.awt.Stroke stroke)
Sets the outline stroke and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
getOutlineStroke()
-
getOutlinePaint
public java.awt.Paint getOutlinePaint()
Returns the outline paint.- Returns:
- The outline paint (never
null
). - See Also:
setOutlinePaint(Paint)
-
setOutlinePaint
public void setOutlinePaint(java.awt.Paint paint)
Sets the outline paint and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getOutlinePaint()
-
getInsets
public RectangleInsets getInsets()
Returns the insets.- Returns:
- The insets (never
null
). - See Also:
setInsets(RectangleInsets)
-
setInsets
public void setInsets(RectangleInsets insets)
Sets the insets and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
insets
- the insets (null
not permitted).- See Also:
getInsets()
-
getValueAnchor
public RectangleAnchor getValueAnchor()
Returns the value anchor.- Returns:
- The value anchor (never
null
). - See Also:
setValueAnchor(RectangleAnchor)
-
setValueAnchor
public void setValueAnchor(RectangleAnchor anchor)
Sets the value anchor and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor (null
not permitted).- See Also:
getValueAnchor()
-
getTextAnchor
public TextAnchor getTextAnchor()
Returns the text anchor.- Returns:
- The text anchor (never
null
). - See Also:
setTextAnchor(TextAnchor)
-
setTextAnchor
public void setTextAnchor(TextAnchor anchor)
Sets the text anchor and sends aDialLayerChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor (null
not permitted).- See Also:
getTextAnchor()
-
isClippedToWindow
public boolean isClippedToWindow()
Returnstrue
to indicate that this layer should be clipped within the dial window.- Specified by:
isClippedToWindow
in interfaceDialLayer
- Returns:
true
.
-
draw
public void draw(java.awt.Graphics2D g2, DialPlot plot, java.awt.geom.Rectangle2D frame, java.awt.geom.Rectangle2D view)
Draws the background to the specified graphics device. If the dial frame specifies a window, the clipping region will already have been set to this window before this method is called.
-
fixToRange
private double fixToRange(double x, double minX, double maxX)
A utility method that adjusts a value, if necessary, to be within a specified range.- Parameters:
x
- the value.minX
- the minimum value in the range.maxX
- the maximum value in the range.- Returns:
- The adjusted value.
-
equals
public boolean equals(java.lang.Object obj)
Tests this instance for equality with an arbitrary object.- Overrides:
equals
in classAbstractDialLayer
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCode
in classAbstractDialLayer
- Returns:
- The hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of this instance.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDialLayer
- Returns:
- The clone.
- Throws:
java.lang.CloneNotSupportedException
- if some attribute of this instance cannot be cloned.
-
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.
-
-