Package org.jfree.chart.plot.dial
Class StandardDialScale
- java.lang.Object
-
- org.jfree.chart.plot.dial.AbstractDialLayer
-
- org.jfree.chart.plot.dial.StandardDialScale
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,DialLayer,DialScale,PublicCloneable
public class StandardDialScale extends AbstractDialLayer implements DialScale, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A scale for aDialPlot.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private doubleextentThe extent of the scale display.private booleanfirstTickLabelVisibleA flag that controls whether or not the first tick label is displayed.private doublelowerBoundThe minimum data value for the scale.private doublemajorTickIncrementThe increment (in data units) between major tick marks.private doublemajorTickLengthThe factor that is subtracted from the tickRadius to determine the inner point of the major ticks.private java.awt.PaintmajorTickPaintThe paint to use for major tick marks.private java.awt.StrokemajorTickStrokeThe stroke to use for major tick marks.private intminorTickCountThe number of minor ticks between each major tick.private doubleminorTickLengthThe factor that is subtracted from the tickRadius to determine the inner point of the minor ticks.private java.awt.PaintminorTickPaintThe paint to use for minor tick marks.private java.awt.StrokeminorTickStrokeThe stroke to use for minor tick marks.(package private) static longserialVersionUIDFor serialization.private doublestartAngleThe start angle for the scale display, in degrees (using the same encoding as Arc2D).private java.awt.FonttickLabelFontThe tick label font.private java.text.NumberFormattickLabelFormatterThe number formatter for the tick labels.private doubletickLabelOffsetThe tick label offset.private java.awt.PainttickLabelPaintThe tick label paint.private booleantickLabelsVisibleA flag that controls whether or not the tick labels are displayed.private doubletickRadiusThe factor (in the range 0.0 to 1.0) that determines the outside limit of the tick marks.private doubleupperBoundThe maximum data value for the scale.
-
Constructor Summary
Constructors Constructor Description StandardDialScale()Creates a new instance of DialScale.StandardDialScale(double lowerBound, double upperBound, double startAngle, double extent, double majorTickIncrement, int minorTickCount)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleangleToValue(double angle)Converts the given angle to a data value, based on this scale.java.lang.Objectclone()Returns a clone of this instance.voiddraw(java.awt.Graphics2D g2, DialPlot plot, java.awt.geom.Rectangle2D frame, java.awt.geom.Rectangle2D view)Draws the scale on the dial plot.booleanequals(java.lang.Object obj)Tests thisStandardDialScalefor equality with an arbitrary object.doublegetExtent()Returns the extent.booleangetFirstTickLabelVisible()Returns a flag that controls whether or not the first tick label is visible.doublegetLowerBound()Returns the lower bound for the scale.doublegetMajorTickIncrement()Returns the increment (in data units) between major tick labels.doublegetMajorTickLength()Returns the length factor for the major tick marks.java.awt.PaintgetMajorTickPaint()Returns the major tick paint.java.awt.StrokegetMajorTickStroke()Returns the stroke used to draw the major tick marks.intgetMinorTickCount()Returns the number of minor tick marks between major tick marks.doublegetMinorTickLength()Returns the length factor for the minor tick marks.java.awt.PaintgetMinorTickPaint()Returns the paint used to draw the minor tick marks.java.awt.StrokegetMinorTickStroke()Returns the stroke used to draw the minor tick marks.doublegetStartAngle()Returns the start angle for the scale (in degrees using the same orientation as Java'sArc2Dclass).java.awt.FontgetTickLabelFont()Returns the font used to draw the tick labels.java.text.NumberFormatgetTickLabelFormatter()Returns the number formatter used to convert the tick label values to strings.doublegetTickLabelOffset()Returns the tick label offset.java.awt.PaintgetTickLabelPaint()Returns the paint used to draw the tick labels.booleangetTickLabelsVisible()Returnstrueif the tick labels should be displayed, andfalseotherwise.doublegetTickRadius()Returns the radius (as a percentage of the maximum space available) of the outer limit of the tick marks.doublegetUpperBound()Returns the upper bound for the scale.inthashCode()Returns a hash code for this instance.booleanisClippedToWindow()Returnstrueto indicate that this layer should be clipped within the dial window.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetExtent(double extent)Sets the extent and sends aDialLayerChangeEventto all registered listeners.voidsetFirstTickLabelVisible(boolean visible)Sets a flag that controls whether or not the first tick label is visible, and sends aDialLayerChangeEventto all registered listeners.voidsetLowerBound(double lower)Sets the lower bound for the scale and sends aDialLayerChangeEventto all registered listeners.voidsetMajorTickIncrement(double increment)Sets the increment (in data units) between major tick labels and sends aDialLayerChangeEventto all registered listeners.voidsetMajorTickLength(double length)Sets the length factor for the major tick marks and sends aDialLayerChangeEventto all registered listeners.voidsetMajorTickPaint(java.awt.Paint paint)Sets the major tick paint and sends aDialLayerChangeEventto all registered listeners.voidsetMajorTickStroke(java.awt.Stroke stroke)Sets the stroke used to draw the major tick marks and sends aDialLayerChangeEventto all registered listeners.voidsetMinorTickCount(int count)Sets the number of minor tick marks between major tick marks and sends aDialLayerChangeEventto all registered listeners.voidsetMinorTickLength(double length)Sets the length factor for the minor tick marks and sends aDialLayerChangeEventto all registered listeners.voidsetMinorTickPaint(java.awt.Paint paint)Sets the paint used to draw the minor tick marks and sends aDialLayerChangeEventto all registered listeners.voidsetMinorTickStroke(java.awt.Stroke stroke)Sets the stroke used to draw the minor tick marks and sends aDialLayerChangeEventto all registered listeners.voidsetStartAngle(double angle)Sets the start angle for the scale and sends aDialLayerChangeEventto all registered listeners.voidsetTickLabelFont(java.awt.Font font)Sets the font used to display the tick labels and sends aDialLayerChangeEventto all registered listeners.voidsetTickLabelFormatter(java.text.NumberFormat formatter)Sets the number formatter used to convert the tick label values to strings, and sends aDialLayerChangeEventto all registered listeners.voidsetTickLabelOffset(double offset)Sets the tick label offset and sends aDialLayerChangeEventto all registered listeners.voidsetTickLabelPaint(java.awt.Paint paint)Sets the paint used to draw the tick labels and sends aDialLayerChangeEventto all registered listeners.voidsetTickLabelsVisible(boolean visible)Sets the flag that controls whether or not the tick labels are displayed, and sends aDialLayerChangeEventto all registered listeners.voidsetTickRadius(double radius)Sets the tick radius and sends aDialLayerChangeEventto all registered listeners.voidsetUpperBound(double upper)Sets the upper bound for the scale and sends aDialLayerChangeEventto all registered listeners.doublevalueToAngle(double value)Converts a data value to an angle against this scale.private voidwriteObject(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
-
lowerBound
private double lowerBound
The minimum data value for the scale.
-
upperBound
private double upperBound
The maximum data value for the scale.
-
startAngle
private double startAngle
The start angle for the scale display, in degrees (using the same encoding as Arc2D).
-
extent
private double extent
The extent of the scale display.
-
tickRadius
private double tickRadius
The factor (in the range 0.0 to 1.0) that determines the outside limit of the tick marks.
-
majorTickIncrement
private double majorTickIncrement
The increment (in data units) between major tick marks.
-
majorTickLength
private double majorTickLength
The factor that is subtracted from the tickRadius to determine the inner point of the major ticks.
-
majorTickPaint
private transient java.awt.Paint majorTickPaint
The paint to use for major tick marks. This field is transient because it requires special handling for serialization.
-
majorTickStroke
private transient java.awt.Stroke majorTickStroke
The stroke to use for major tick marks. This field is transient because it requires special handling for serialization.
-
minorTickCount
private int minorTickCount
The number of minor ticks between each major tick.
-
minorTickLength
private double minorTickLength
The factor that is subtracted from the tickRadius to determine the inner point of the minor ticks.
-
minorTickPaint
private transient java.awt.Paint minorTickPaint
The paint to use for minor tick marks. This field is transient because it requires special handling for serialization.
-
minorTickStroke
private transient java.awt.Stroke minorTickStroke
The stroke to use for minor tick marks. This field is transient because it requires special handling for serialization.
-
tickLabelOffset
private double tickLabelOffset
The tick label offset.
-
tickLabelFont
private java.awt.Font tickLabelFont
The tick label font.
-
tickLabelsVisible
private boolean tickLabelsVisible
A flag that controls whether or not the tick labels are displayed.
-
tickLabelFormatter
private java.text.NumberFormat tickLabelFormatter
The number formatter for the tick labels.
-
firstTickLabelVisible
private boolean firstTickLabelVisible
A flag that controls whether or not the first tick label is displayed.
-
tickLabelPaint
private transient java.awt.Paint tickLabelPaint
The tick label paint. This field is transient because it requires special handling for serialization.
-
-
Constructor Detail
-
StandardDialScale
public StandardDialScale()
Creates a new instance of DialScale.
-
StandardDialScale
public StandardDialScale(double lowerBound, double upperBound, double startAngle, double extent, double majorTickIncrement, int minorTickCount)Creates a new instance.- Parameters:
lowerBound- the lower bound of the scale.upperBound- the upper bound of the scale.startAngle- the start angle (in degrees, using the same orientation as Java'sArc2Dclass).extent- the extent (in degrees, counter-clockwise).majorTickIncrement- the interval between major tick marks (must be > 0).minorTickCount- the number of minor ticks between major tick marks.
-
-
Method Detail
-
getLowerBound
public double getLowerBound()
Returns the lower bound for the scale.- Returns:
- The lower bound for the scale.
- See Also:
setLowerBound(double)
-
setLowerBound
public void setLowerBound(double lower)
Sets the lower bound for the scale and sends aDialLayerChangeEventto all registered listeners.- Parameters:
lower- the lower bound.- See Also:
getLowerBound()
-
getUpperBound
public double getUpperBound()
Returns the upper bound for the scale.- Returns:
- The upper bound for the scale.
- See Also:
setUpperBound(double)
-
setUpperBound
public void setUpperBound(double upper)
Sets the upper bound for the scale and sends aDialLayerChangeEventto all registered listeners.- Parameters:
upper- the upper bound.- See Also:
getUpperBound()
-
getStartAngle
public double getStartAngle()
Returns the start angle for the scale (in degrees using the same orientation as Java'sArc2Dclass).- Returns:
- The start angle.
- See Also:
setStartAngle(double)
-
setStartAngle
public void setStartAngle(double angle)
Sets the start angle for the scale and sends aDialLayerChangeEventto all registered listeners.- Parameters:
angle- the angle (in degrees).- See Also:
getStartAngle()
-
getExtent
public double getExtent()
Returns the extent.- Returns:
- The extent.
- See Also:
setExtent(double)
-
setExtent
public void setExtent(double extent)
Sets the extent and sends aDialLayerChangeEventto all registered listeners.- Parameters:
extent- the extent.- See Also:
getExtent()
-
getTickRadius
public double getTickRadius()
Returns the radius (as a percentage of the maximum space available) of the outer limit of the tick marks.- Returns:
- The tick radius.
- See Also:
setTickRadius(double)
-
setTickRadius
public void setTickRadius(double radius)
Sets the tick radius and sends aDialLayerChangeEventto all registered listeners.- Parameters:
radius- the radius.- See Also:
getTickRadius()
-
getMajorTickIncrement
public double getMajorTickIncrement()
Returns the increment (in data units) between major tick labels.- Returns:
- The increment between major tick labels.
- See Also:
setMajorTickIncrement(double)
-
setMajorTickIncrement
public void setMajorTickIncrement(double increment)
Sets the increment (in data units) between major tick labels and sends aDialLayerChangeEventto all registered listeners.- Parameters:
increment- the increment (must be > 0).- See Also:
getMajorTickIncrement()
-
getMajorTickLength
public double getMajorTickLength()
Returns the length factor for the major tick marks. The value is subtracted from the tick radius to determine the inner starting point for the tick marks.- Returns:
- The length factor.
- See Also:
setMajorTickLength(double)
-
setMajorTickLength
public void setMajorTickLength(double length)
Sets the length factor for the major tick marks and sends aDialLayerChangeEventto all registered listeners.- Parameters:
length- the length.- See Also:
getMajorTickLength()
-
getMajorTickPaint
public java.awt.Paint getMajorTickPaint()
Returns the major tick paint.- Returns:
- The major tick paint (never
null). - See Also:
setMajorTickPaint(Paint)
-
setMajorTickPaint
public void setMajorTickPaint(java.awt.Paint paint)
Sets the major tick paint and sends aDialLayerChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getMajorTickPaint()
-
getMajorTickStroke
public java.awt.Stroke getMajorTickStroke()
Returns the stroke used to draw the major tick marks.- Returns:
- The stroke (never
null). - See Also:
setMajorTickStroke(Stroke)
-
setMajorTickStroke
public void setMajorTickStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the major tick marks and sends aDialLayerChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getMajorTickStroke()
-
getMinorTickCount
public int getMinorTickCount()
Returns the number of minor tick marks between major tick marks.- Returns:
- The number of minor tick marks between major tick marks.
- See Also:
setMinorTickCount(int)
-
setMinorTickCount
public void setMinorTickCount(int count)
Sets the number of minor tick marks between major tick marks and sends aDialLayerChangeEventto all registered listeners.- Parameters:
count- the count.- See Also:
getMinorTickCount()
-
getMinorTickLength
public double getMinorTickLength()
Returns the length factor for the minor tick marks. The value is subtracted from the tick radius to determine the inner starting point for the tick marks.- Returns:
- The length factor.
- See Also:
setMinorTickLength(double)
-
setMinorTickLength
public void setMinorTickLength(double length)
Sets the length factor for the minor tick marks and sends aDialLayerChangeEventto all registered listeners.- Parameters:
length- the length.- See Also:
getMinorTickLength()
-
getMinorTickPaint
public java.awt.Paint getMinorTickPaint()
Returns the paint used to draw the minor tick marks.- Returns:
- The paint (never
null). - See Also:
setMinorTickPaint(Paint)
-
setMinorTickPaint
public void setMinorTickPaint(java.awt.Paint paint)
Sets the paint used to draw the minor tick marks and sends aDialLayerChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getMinorTickPaint()
-
getMinorTickStroke
public java.awt.Stroke getMinorTickStroke()
Returns the stroke used to draw the minor tick marks.- Returns:
- The paint (never
null). - See Also:
setMinorTickStroke(Stroke)
-
setMinorTickStroke
public void setMinorTickStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the minor tick marks and sends aDialLayerChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getMinorTickStroke()
-
getTickLabelOffset
public double getTickLabelOffset()
Returns the tick label offset.- Returns:
- The tick label offset.
- See Also:
setTickLabelOffset(double)
-
setTickLabelOffset
public void setTickLabelOffset(double offset)
Sets the tick label offset and sends aDialLayerChangeEventto all registered listeners.- Parameters:
offset- the offset.- See Also:
getTickLabelOffset()
-
getTickLabelFont
public java.awt.Font getTickLabelFont()
Returns the font used to draw the tick labels.- Returns:
- The font (never
null). - See Also:
setTickLabelFont(Font)
-
setTickLabelFont
public void setTickLabelFont(java.awt.Font font)
Sets the font used to display the tick labels and sends aDialLayerChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
getTickLabelFont()
-
getTickLabelPaint
public java.awt.Paint getTickLabelPaint()
Returns the paint used to draw the tick labels.- Returns:
- The paint (
nullnot permitted). - See Also:
setTickLabelPaint(Paint)
-
setTickLabelPaint
public void setTickLabelPaint(java.awt.Paint paint)
Sets the paint used to draw the tick labels and sends aDialLayerChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).
-
getTickLabelsVisible
public boolean getTickLabelsVisible()
Returnstrueif the tick labels should be displayed, andfalseotherwise.- Returns:
- A boolean.
- See Also:
setTickLabelsVisible(boolean)
-
setTickLabelsVisible
public void setTickLabelsVisible(boolean visible)
Sets the flag that controls whether or not the tick labels are displayed, and sends aDialLayerChangeEventto all registered listeners.- Parameters:
visible- the new flag value.- See Also:
getTickLabelsVisible()
-
getTickLabelFormatter
public java.text.NumberFormat getTickLabelFormatter()
Returns the number formatter used to convert the tick label values to strings.- Returns:
- The formatter (never
null). - See Also:
setTickLabelFormatter(NumberFormat)
-
setTickLabelFormatter
public void setTickLabelFormatter(java.text.NumberFormat formatter)
Sets the number formatter used to convert the tick label values to strings, and sends aDialLayerChangeEventto all registered listeners.- Parameters:
formatter- the formatter (nullnot permitted).- See Also:
getTickLabelFormatter()
-
getFirstTickLabelVisible
public boolean getFirstTickLabelVisible()
Returns a flag that controls whether or not the first tick label is visible.- Returns:
- A boolean.
- See Also:
setFirstTickLabelVisible(boolean)
-
setFirstTickLabelVisible
public void setFirstTickLabelVisible(boolean visible)
Sets a flag that controls whether or not the first tick label is visible, and sends aDialLayerChangeEventto all registered listeners.- Parameters:
visible- the new flag value.- See Also:
getFirstTickLabelVisible()
-
isClippedToWindow
public boolean isClippedToWindow()
Returnstrueto indicate that this layer should be clipped within the dial window.- Specified by:
isClippedToWindowin 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 scale on the dial plot.- Specified by:
drawin interfaceDialLayer- Parameters:
g2- the graphics target (nullnot permitted).plot- the dial plot (nullnot permitted).frame- the reference frame that is used to construct the geometry of the plot (nullnot permitted).view- the visible part of the plot (nullnot permitted).
-
valueToAngle
public double valueToAngle(double value)
Converts a data value to an angle against this scale.- Specified by:
valueToAnglein interfaceDialScale- Parameters:
value- the data value.- Returns:
- The angle (in degrees, using the same specification as Java's Arc2D class).
- See Also:
angleToValue(double)
-
angleToValue
public double angleToValue(double angle)
Converts the given angle to a data value, based on this scale.- Specified by:
angleToValuein interfaceDialScale- Parameters:
angle- the angle (in degrees).- Returns:
- The data value.
- See Also:
valueToAngle(double)
-
equals
public boolean equals(java.lang.Object obj)
Tests thisStandardDialScalefor equality with an arbitrary object.- Overrides:
equalsin classAbstractDialLayer- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCodein classAbstractDialLayer- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of this instance.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractDialLayer- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- if this instance is not cloneable.
-
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.
-
-