Package org.jfree.chart.plot
Class ThermometerPlot
- java.lang.Object
-
- org.jfree.chart.plot.Plot
-
- org.jfree.chart.plot.ThermometerPlot
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,AnnotationChangeListener
,AxisChangeListener
,MarkerChangeListener
,LegendItemSource
,ValueAxisPlot
,Zoomable
,PublicCloneable
,DatasetChangeListener
public class ThermometerPlot extends Plot implements ValueAxisPlot, Zoomable, java.lang.Cloneable, java.io.Serializable
A plot that displays a single value (from aValueDataset
) in a thermometer type display.This plot supports a number of options:
- three sub-ranges which could be viewed as 'Normal', 'Warning' and 'Critical' ranges.
- the thermometer can be run in two modes:
- fixed range, or
- range adjusts to current sub-range.
- settable units to be displayed.
- settable display location for the value text.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
AXIS_GAP
The axis gap.private int
axisLocation
The position of the axisstatic int
BULB
A constant for the value label position (in the thermometer bulb).private int
bulbRadius
The value label position.private int
columnRadius
The column radius.static int
CRITICAL
A constant for the 'critical' range.private ValueDataset
dataset
The dataset for the plot.protected static int
DEFAULT_BULB_RADIUS
The default bulb radius.protected static int
DEFAULT_COLUMN_RADIUS
The default column radius.protected static int
DEFAULT_GAP
The default gap between the outlines representing the thermometer.protected static double
DEFAULT_LOWER_BOUND
The default lower bound.protected static double
DEFAULT_UPPER_BOUND
The default upper bound.protected static int
DISPLAY_HIGH
Index for display high value in subrangeInfo matrix.protected static int
DISPLAY_LOW
Index for display low value in subrangeInfo matrix.private boolean
followDataInSubranges
A flag that controls whether or not the axis range adjusts to the sub-ranges.private int
gap
The gap between the two outlines the represent the thermometer.static int
LEFT
A constant for the value label position (left of the thermometer).protected static java.util.ResourceBundle
localizationResources
The resourceBundle for the localization.private double
lowerBound
The lower bound for the thermometer.private java.awt.Paint
mercuryPaint
The default paint for the mercury in the thermometer.static int
NONE
A constant for the value label position (no label).static int
NORMAL
A constant for the 'normal' range.private RectangleInsets
padding
Blank space inside the plot area around the outside of the thermometer.protected static int
RANGE_HIGH
Index for high value in subrangeInfo matrix.protected static int
RANGE_LOW
Index for low value in subrangeInfo matrix.private ValueAxis
rangeAxis
The range axis.private java.awt.Stroke
rangeIndicatorStroke
The range indicator stroke.static int
RIGHT
A constant for the value label position (right of the thermometer).private static long
serialVersionUID
For serialization.private boolean
showValueLines
A flag that controls whether value lines are drawn.private int
subrange
The display sub-range.private java.awt.Stroke
subrangeIndicatorStroke
The stroke for the sub-range indicators.private boolean
subrangeIndicatorsVisible
A flag that controls whether the sub-range indicators are visible.private double[][]
subrangeInfo
The start and end values for the subranges.private java.awt.Paint[]
subrangePaint
Paint for each rangeprivate java.awt.Paint
thermometerPaint
Paint for drawing the thermometerprivate java.awt.Stroke
thermometerStroke
Stroke for drawing the thermometerprivate int
units
The display unitsprotected static java.lang.String[]
UNITS
The unit strings.static int
UNITS_CELCIUS
A constant for unit type 'Celcius'.static int
UNITS_FAHRENHEIT
A constant for unit type 'Fahrenheit'.static int
UNITS_KELVIN
A constant for unit type 'Kelvin'.static int
UNITS_NONE
A constant for unit type 'None'.private double
upperBound
The upper bound for the thermometer.private boolean
useSubrangePaint
A flag that controls whether or not the mercury paint changes with the subranges.private java.awt.Font
valueFont
The font to write the value inprivate java.text.NumberFormat
valueFormat
Number format for the valueprivate int
valueLocation
The value label position.private java.awt.Paint
valuePaint
Colour that the value is written instatic int
WARNING
A constant for the 'warning' range.-
Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_LEGEND_ITEM_BOX, DEFAULT_LEGEND_ITEM_CIRCLE, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO
-
-
Constructor Summary
Constructors Constructor Description ThermometerPlot()
Creates a new thermometer plot.ThermometerPlot(ValueDataset dataset)
Creates a new thermometer plot, using default attributes where necessary.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a clone of the plot.void
datasetChanged(DatasetChangeEvent event)
Checks to see if a new value means the axis range needs adjusting.void
draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).private static boolean
equal(double[][] array1, double[][] array2)
Tests two double[][] arrays for equality.boolean
equals(java.lang.Object obj)
Tests this plot for equality with another object.int
getAxisLocation()
Returns the axis location.int
getBulbDiameter()
Returns the bulb diameter, which is always twice the value returned bygetBulbRadius()
.int
getBulbRadius()
Returns the bulb radius, in Java2D units.int
getColumnDiameter()
Returns the column diameter, which is always twice the value returned bygetColumnRadius()
.int
getColumnRadius()
Returns the column radius, in Java2D units.private java.awt.Paint
getCurrentPaint()
Returns the mercury paint corresponding to the current data value.Range
getDataRange(ValueAxis axis)
Returns the data range.ValueDataset
getDataset()
Returns the dataset for the plot.boolean
getFollowDataInSubranges()
Returns a flag that controls whether or not the thermometer axis zooms to display the subrange within which the data value falls.int
getGap()
Returns the gap, in Java2D units, between the two outlines that represent the thermometer.LegendItemCollection
getLegendItems()
Returns the legend items for the plot.double
getLowerBound()
Returns the lower bound for the thermometer.java.awt.Paint
getMercuryPaint()
Returns the default mercury paint.PlotOrientation
getOrientation()
Returns the orientation of the plot.RectangleInsets
getPadding()
Returns the padding for the thermometer.java.lang.String
getPlotType()
Returns a short string describing the type of plot.ValueAxis
getRangeAxis()
Returns the range axis.java.awt.Paint
getSubrangePaint(int range)
Gets the paint used for a particular subrange.java.awt.Paint
getThermometerPaint()
Returns the paint used to draw the thermometer outline.java.awt.Stroke
getThermometerStroke()
Returns the stroke used to draw the thermometer outline.int
getUnits()
Returns a code indicating the unit display type.double
getUpperBound()
Returns the upper bound for the thermometer.boolean
getUseSubrangePaint()
Returns a flag that controls whether or not the mercury color changes for each subrange.java.awt.Font
getValueFont()
Gets the font used to display the current value.int
getValueLocation()
Returns a code indicating the location at which the value label is displayed.java.awt.Paint
getValuePaint()
Gets the paint used to display the current value.private boolean
inSubrange(int subrange, double value)
Returns true if the value is in the specified range, and false otherwise.boolean
isDomainZoomable()
Returnsfalse
.boolean
isRangeZoomable()
Returnstrue
.protected static boolean
isValidNumber(double d)
Determine whether a number is valid and finite.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setAxisLocation(int location)
Sets the location at which the axis is displayed relative to the thermometer, and sends aPlotChangeEvent
to all registered listeners.protected void
setAxisRange()
Sets the axis range to the current values in the rangeInfo array.void
setBulbRadius(int r)
Sets the bulb radius (in Java2D units) and sends aPlotChangeEvent
to all registered listeners.void
setColumnRadius(int r)
Sets the column radius (in Java2D units) and sends aPlotChangeEvent
to all registered listeners.void
setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one, and sends aPlotChangeEvent
to all registered listeners.void
setDisplayRange(int range, double low, double high)
Sets the displayed bounds for a sub range.void
setFollowDataInSubranges(boolean flag)
Sets the flag that controls whether or not the thermometer axis zooms to display the subrange within which the data value falls.void
setGap(int gap)
Sets the gap (in Java2D units) between the two outlines that represent the thermometer, and sends aPlotChangeEvent
to all registered listeners.void
setLowerBound(double lower)
Sets the lower bound for the thermometer.void
setMercuryPaint(java.awt.Paint paint)
Sets the default mercury paint and sends aPlotChangeEvent
to all registered listeners.void
setPadding(RectangleInsets padding)
Sets the padding for the thermometer and sends aPlotChangeEvent
to all registered listeners.void
setRange(double lower, double upper)
Sets the lower and upper bounds for the thermometer.void
setRangeAxis(ValueAxis axis)
Sets the range axis for the plot and sends aPlotChangeEvent
to all registered listeners.void
setSubrange(int range, double low, double high)
Sets the bounds for a subrange.void
setSubrangeInfo(int range, double low, double hi)
Sets information for a particular range.void
setSubrangeInfo(int range, double rangeLow, double rangeHigh, double displayLow, double displayHigh)
Sets the subrangeInfo attribute of the ThermometerPlot objectvoid
setSubrangePaint(int range, java.awt.Paint paint)
Sets the paint to be used for a subrange and sends aPlotChangeEvent
to all registered listeners.void
setThermometerPaint(java.awt.Paint paint)
Sets the paint used to draw the thermometer outline and sends aPlotChangeEvent
to all registered listeners.void
setThermometerStroke(java.awt.Stroke s)
Sets the stroke used to draw the thermometer outline and sends aPlotChangeEvent
to all registered listeners.void
setUnits(int u)
Sets the units to be displayed in the thermometer.void
setUpperBound(double upper)
Sets the upper bound for the thermometer.void
setUseSubrangePaint(boolean flag)
Sets the range colour change option.void
setValueFont(java.awt.Font f)
Sets the font used to display the current value.void
setValueFormat(java.text.NumberFormat formatter)
Sets the formatter for the value label and sends aPlotChangeEvent
to all registered listeners.void
setValueLocation(int location)
Sets the location at which the current value is displayed and sends aPlotChangeEvent
to all registered listeners.void
setValuePaint(java.awt.Paint paint)
Sets the paint used to display the current value and sends aPlotChangeEvent
to all registered listeners.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.void
zoom(double percent)
A zoom method that does nothing.void
zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, java.awt.geom.Point2D source)
This method does nothing.void
zoomDomainAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source)
Multiplies the range on the domain axis/axes by the specified factor.void
zoomDomainAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source, boolean useAnchor)
Multiplies the range on the domain axis/axes by the specified factor.void
zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, java.awt.geom.Point2D source)
Zooms the range axes.void
zoomRangeAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source)
Multiplies the range on the range axis/axes by the specified factor.void
zoomRangeAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source, boolean useAnchor)
Multiplies the range on the range axis/axes by the specified factor.-
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, annotationChanged, axisChanged, canEqual, createAndAddEntity, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fetchElementHintingFlag, fillBackground, fillBackground, fireChangeEvent, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getChart, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, hashCode, isNotify, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setChart, setDatasetGroup, setDrawingSupplier, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setNotify, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
UNITS_NONE
public static final int UNITS_NONE
A constant for unit type 'None'.- See Also:
- Constant Field Values
-
UNITS_FAHRENHEIT
public static final int UNITS_FAHRENHEIT
A constant for unit type 'Fahrenheit'.- See Also:
- Constant Field Values
-
UNITS_CELCIUS
public static final int UNITS_CELCIUS
A constant for unit type 'Celcius'.- See Also:
- Constant Field Values
-
UNITS_KELVIN
public static final int UNITS_KELVIN
A constant for unit type 'Kelvin'.- See Also:
- Constant Field Values
-
NONE
public static final int NONE
A constant for the value label position (no label).- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
A constant for the value label position (right of the thermometer).- See Also:
- Constant Field Values
-
LEFT
public static final int LEFT
A constant for the value label position (left of the thermometer).- See Also:
- Constant Field Values
-
BULB
public static final int BULB
A constant for the value label position (in the thermometer bulb).- See Also:
- Constant Field Values
-
NORMAL
public static final int NORMAL
A constant for the 'normal' range.- See Also:
- Constant Field Values
-
WARNING
public static final int WARNING
A constant for the 'warning' range.- See Also:
- Constant Field Values
-
CRITICAL
public static final int CRITICAL
A constant for the 'critical' range.- See Also:
- Constant Field Values
-
AXIS_GAP
protected static final int AXIS_GAP
The axis gap.- See Also:
- Constant Field Values
-
UNITS
protected static final java.lang.String[] UNITS
The unit strings.
-
RANGE_LOW
protected static final int RANGE_LOW
Index for low value in subrangeInfo matrix.- See Also:
- Constant Field Values
-
RANGE_HIGH
protected static final int RANGE_HIGH
Index for high value in subrangeInfo matrix.- See Also:
- Constant Field Values
-
DISPLAY_LOW
protected static final int DISPLAY_LOW
Index for display low value in subrangeInfo matrix.- See Also:
- Constant Field Values
-
DISPLAY_HIGH
protected static final int DISPLAY_HIGH
Index for display high value in subrangeInfo matrix.- See Also:
- Constant Field Values
-
DEFAULT_LOWER_BOUND
protected static final double DEFAULT_LOWER_BOUND
The default lower bound.- See Also:
- Constant Field Values
-
DEFAULT_UPPER_BOUND
protected static final double DEFAULT_UPPER_BOUND
The default upper bound.- See Also:
- Constant Field Values
-
DEFAULT_BULB_RADIUS
protected static final int DEFAULT_BULB_RADIUS
The default bulb radius.- See Also:
- Constant Field Values
-
DEFAULT_COLUMN_RADIUS
protected static final int DEFAULT_COLUMN_RADIUS
The default column radius.- See Also:
- Constant Field Values
-
DEFAULT_GAP
protected static final int DEFAULT_GAP
The default gap between the outlines representing the thermometer.- See Also:
- Constant Field Values
-
dataset
private ValueDataset dataset
The dataset for the plot.
-
rangeAxis
private ValueAxis rangeAxis
The range axis.
-
lowerBound
private double lowerBound
The lower bound for the thermometer.
-
upperBound
private double upperBound
The upper bound for the thermometer.
-
bulbRadius
private int bulbRadius
The value label position.
-
columnRadius
private int columnRadius
The column radius.
-
gap
private int gap
The gap between the two outlines the represent the thermometer.
-
padding
private RectangleInsets padding
Blank space inside the plot area around the outside of the thermometer.
-
thermometerStroke
private transient java.awt.Stroke thermometerStroke
Stroke for drawing the thermometer
-
thermometerPaint
private transient java.awt.Paint thermometerPaint
Paint for drawing the thermometer
-
units
private int units
The display units
-
valueLocation
private int valueLocation
The value label position.
-
axisLocation
private int axisLocation
The position of the axis
-
valueFont
private java.awt.Font valueFont
The font to write the value in
-
valuePaint
private transient java.awt.Paint valuePaint
Colour that the value is written in
-
valueFormat
private java.text.NumberFormat valueFormat
Number format for the value
-
mercuryPaint
private transient java.awt.Paint mercuryPaint
The default paint for the mercury in the thermometer.
-
showValueLines
private boolean showValueLines
A flag that controls whether value lines are drawn.
-
subrange
private int subrange
The display sub-range.
-
subrangeInfo
private double[][] subrangeInfo
The start and end values for the subranges.
-
followDataInSubranges
private boolean followDataInSubranges
A flag that controls whether or not the axis range adjusts to the sub-ranges.
-
useSubrangePaint
private boolean useSubrangePaint
A flag that controls whether or not the mercury paint changes with the subranges.
-
subrangePaint
private transient java.awt.Paint[] subrangePaint
Paint for each range
-
subrangeIndicatorsVisible
private boolean subrangeIndicatorsVisible
A flag that controls whether the sub-range indicators are visible.
-
subrangeIndicatorStroke
private transient java.awt.Stroke subrangeIndicatorStroke
The stroke for the sub-range indicators.
-
rangeIndicatorStroke
private transient java.awt.Stroke rangeIndicatorStroke
The range indicator stroke.
-
localizationResources
protected static java.util.ResourceBundle localizationResources
The resourceBundle for the localization.
-
-
Constructor Detail
-
ThermometerPlot
public ThermometerPlot()
Creates a new thermometer plot.
-
ThermometerPlot
public ThermometerPlot(ValueDataset dataset)
Creates a new thermometer plot, using default attributes where necessary.- Parameters:
dataset
- the data set.
-
-
Method Detail
-
getDataset
public ValueDataset getDataset()
Returns the dataset for the plot.- Returns:
- The dataset (possibly
null
). - See Also:
setDataset(ValueDataset)
-
setDataset
public void setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one, and sends aPlotChangeEvent
to all registered listeners.- Parameters:
dataset
- the dataset (null
permitted).- See Also:
getDataset()
-
getRangeAxis
public ValueAxis getRangeAxis()
Returns the range axis.- Returns:
- The range axis (never
null
). - See Also:
setRangeAxis(ValueAxis)
-
setRangeAxis
public void setRangeAxis(ValueAxis axis)
Sets the range axis for the plot and sends aPlotChangeEvent
to all registered listeners.- Parameters:
axis
- the new axis (null
not permitted).- See Also:
getRangeAxis()
-
getLowerBound
public double getLowerBound()
Returns the lower bound for the thermometer. The data value can be set lower than this, but it will not be shown in the thermometer.- Returns:
- The lower bound.
- See Also:
setLowerBound(double)
-
setLowerBound
public void setLowerBound(double lower)
Sets the lower bound for the thermometer.- Parameters:
lower
- the lower bound.- See Also:
getLowerBound()
-
getUpperBound
public double getUpperBound()
Returns the upper bound for the thermometer. The data value can be set higher than this, but it will not be shown in the thermometer.- Returns:
- The upper bound.
- See Also:
setUpperBound(double)
-
setUpperBound
public void setUpperBound(double upper)
Sets the upper bound for the thermometer.- Parameters:
upper
- the upper bound.- See Also:
getUpperBound()
-
setRange
public void setRange(double lower, double upper)
Sets the lower and upper bounds for the thermometer.- Parameters:
lower
- the lower bound.upper
- the upper bound.
-
getPadding
public RectangleInsets getPadding()
Returns the padding for the thermometer. This is the space inside the plot area.- Returns:
- The padding (never
null
). - See Also:
setPadding(RectangleInsets)
-
setPadding
public void setPadding(RectangleInsets padding)
Sets the padding for the thermometer and sends aPlotChangeEvent
to all registered listeners.- Parameters:
padding
- the padding (null
not permitted).- See Also:
getPadding()
-
getThermometerStroke
public java.awt.Stroke getThermometerStroke()
Returns the stroke used to draw the thermometer outline.- Returns:
- The stroke (never
null
). - See Also:
setThermometerStroke(Stroke)
,getThermometerPaint()
-
setThermometerStroke
public void setThermometerStroke(java.awt.Stroke s)
Sets the stroke used to draw the thermometer outline and sends aPlotChangeEvent
to all registered listeners.- Parameters:
s
- the new stroke (null
ignored).- See Also:
getThermometerStroke()
-
getThermometerPaint
public java.awt.Paint getThermometerPaint()
Returns the paint used to draw the thermometer outline.- Returns:
- The paint (never
null
). - See Also:
setThermometerPaint(Paint)
,getThermometerStroke()
-
setThermometerPaint
public void setThermometerPaint(java.awt.Paint paint)
Sets the paint used to draw the thermometer outline and sends aPlotChangeEvent
to all registered listeners.- Parameters:
paint
- the new paint (null
ignored).- See Also:
getThermometerPaint()
-
getUnits
public int getUnits()
Returns a code indicating the unit display type. This is one ofUNITS_NONE
,UNITS_FAHRENHEIT
,UNITS_CELCIUS
andUNITS_KELVIN
.- Returns:
- The units type.
- See Also:
setUnits(int)
-
setUnits
public void setUnits(int u)
Sets the units to be displayed in the thermometer. Use one of the following constants:- UNITS_NONE : no units displayed.
- UNITS_FAHRENHEIT : units displayed in Fahrenheit.
- UNITS_CELCIUS : units displayed in Celcius.
- UNITS_KELVIN : units displayed in Kelvin.
- Parameters:
u
- the new unit type.- See Also:
getUnits()
-
getValueLocation
public int getValueLocation()
Returns a code indicating the location at which the value label is displayed.
-
setValueLocation
public void setValueLocation(int location)
Sets the location at which the current value is displayed and sends aPlotChangeEvent
to all registered listeners.The location can be one of the constants:
NONE
,RIGHT
,LEFT
andBULB
.- Parameters:
location
- the location.
-
getAxisLocation
public int getAxisLocation()
Returns the axis location.- Returns:
- The location (one of
NONE
,LEFT
andRIGHT
). - See Also:
setAxisLocation(int)
-
setAxisLocation
public void setAxisLocation(int location)
Sets the location at which the axis is displayed relative to the thermometer, and sends aPlotChangeEvent
to all registered listeners.- Parameters:
location
- the location (one ofNONE
,LEFT
andRIGHT
).- See Also:
getAxisLocation()
-
getValueFont
public java.awt.Font getValueFont()
Gets the font used to display the current value.- Returns:
- The font.
- See Also:
setValueFont(Font)
-
setValueFont
public void setValueFont(java.awt.Font f)
Sets the font used to display the current value.- Parameters:
f
- the new font (null
not permitted).- See Also:
getValueFont()
-
getValuePaint
public java.awt.Paint getValuePaint()
Gets the paint used to display the current value.- Returns:
- The paint.
- See Also:
setValuePaint(Paint)
-
setValuePaint
public void setValuePaint(java.awt.Paint paint)
Sets the paint used to display the current value and sends aPlotChangeEvent
to all registered listeners.- Parameters:
paint
- the new paint (null
not permitted).- See Also:
getValuePaint()
-
setValueFormat
public void setValueFormat(java.text.NumberFormat formatter)
Sets the formatter for the value label and sends aPlotChangeEvent
to all registered listeners.- Parameters:
formatter
- the new formatter (null
not permitted).
-
getMercuryPaint
public java.awt.Paint getMercuryPaint()
Returns the default mercury paint.- Returns:
- The paint (never
null
). - See Also:
setMercuryPaint(Paint)
-
setMercuryPaint
public void setMercuryPaint(java.awt.Paint paint)
Sets the default mercury paint and sends aPlotChangeEvent
to all registered listeners.- Parameters:
paint
- the new paint (null
not permitted).- See Also:
getMercuryPaint()
-
setSubrangeInfo
public void setSubrangeInfo(int range, double low, double hi)
Sets information for a particular range.- Parameters:
range
- the range to specify information about.low
- the low value for the rangehi
- the high value for the range
-
setSubrangeInfo
public void setSubrangeInfo(int range, double rangeLow, double rangeHigh, double displayLow, double displayHigh)
Sets the subrangeInfo attribute of the ThermometerPlot object- Parameters:
range
- the new rangeInfo value.rangeLow
- the new rangeInfo valuerangeHigh
- the new rangeInfo valuedisplayLow
- the new rangeInfo valuedisplayHigh
- the new rangeInfo value
-
setSubrange
public void setSubrange(int range, double low, double high)
Sets the bounds for a subrange.- Parameters:
range
- the range type.low
- the low value.high
- the high value.
-
setDisplayRange
public void setDisplayRange(int range, double low, double high)
Sets the displayed bounds for a sub range.- Parameters:
range
- the range type.low
- the low value.high
- the high value.
-
getSubrangePaint
public java.awt.Paint getSubrangePaint(int range)
Gets the paint used for a particular subrange.- Parameters:
range
- the range (.- Returns:
- The paint.
- See Also:
setSubrangePaint(int, Paint)
-
setSubrangePaint
public void setSubrangePaint(int range, java.awt.Paint paint)
Sets the paint to be used for a subrange and sends aPlotChangeEvent
to all registered listeners.- Parameters:
range
- the range (0, 1 or 2).paint
- the paint to be applied (null
not permitted).- See Also:
getSubrangePaint(int)
-
getFollowDataInSubranges
public boolean getFollowDataInSubranges()
Returns a flag that controls whether or not the thermometer axis zooms to display the subrange within which the data value falls.- Returns:
- The flag.
-
setFollowDataInSubranges
public void setFollowDataInSubranges(boolean flag)
Sets the flag that controls whether or not the thermometer axis zooms to display the subrange within which the data value falls.- Parameters:
flag
- the flag.
-
getUseSubrangePaint
public boolean getUseSubrangePaint()
Returns a flag that controls whether or not the mercury color changes for each subrange.- Returns:
- The flag.
- See Also:
setUseSubrangePaint(boolean)
-
setUseSubrangePaint
public void setUseSubrangePaint(boolean flag)
Sets the range colour change option.- Parameters:
flag
- the new range colour change option- See Also:
getUseSubrangePaint()
-
getBulbRadius
public int getBulbRadius()
Returns the bulb radius, in Java2D units.- Returns:
- The bulb radius.
-
setBulbRadius
public void setBulbRadius(int r)
Sets the bulb radius (in Java2D units) and sends aPlotChangeEvent
to all registered listeners.- Parameters:
r
- the new radius (in Java2D units).- See Also:
getBulbRadius()
-
getBulbDiameter
public int getBulbDiameter()
Returns the bulb diameter, which is always twice the value returned bygetBulbRadius()
.- Returns:
- The bulb diameter.
-
getColumnRadius
public int getColumnRadius()
Returns the column radius, in Java2D units.- Returns:
- The column radius.
- See Also:
setColumnRadius(int)
-
setColumnRadius
public void setColumnRadius(int r)
Sets the column radius (in Java2D units) and sends aPlotChangeEvent
to all registered listeners.- Parameters:
r
- the new radius.- See Also:
getColumnRadius()
-
getColumnDiameter
public int getColumnDiameter()
Returns the column diameter, which is always twice the value returned bygetColumnRadius()
.- Returns:
- The column diameter.
-
getGap
public int getGap()
Returns the gap, in Java2D units, between the two outlines that represent the thermometer.- Returns:
- The gap.
- See Also:
setGap(int)
-
setGap
public void setGap(int gap)
Sets the gap (in Java2D units) between the two outlines that represent the thermometer, and sends aPlotChangeEvent
to all registered listeners.- Parameters:
gap
- the new gap.- See Also:
getGap()
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.awt.geom.Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).
-
zoom
public void zoom(double percent)
A zoom method that does nothing. Plots are required to support the zoom operation. In the case of a thermometer chart, it doesn't make sense to zoom in or out, so the method is empty.
-
getPlotType
public java.lang.String getPlotType()
Returns a short string describing the type of plot.- Specified by:
getPlotType
in classPlot
- Returns:
- A short string describing the type of plot.
-
datasetChanged
public void datasetChanged(DatasetChangeEvent event)
Checks to see if a new value means the axis range needs adjusting.- Specified by:
datasetChanged
in interfaceDatasetChangeListener
- Overrides:
datasetChanged
in classPlot
- Parameters:
event
- the dataset change event.
-
getDataRange
public Range getDataRange(ValueAxis axis)
Returns the data range.- Specified by:
getDataRange
in interfaceValueAxisPlot
- Parameters:
axis
- the axis.- Returns:
- The range of data displayed.
-
setAxisRange
protected void setAxisRange()
Sets the axis range to the current values in the rangeInfo array.
-
getLegendItems
public LegendItemCollection getLegendItems()
Returns the legend items for the plot.- Specified by:
getLegendItems
in interfaceLegendItemSource
- Overrides:
getLegendItems
in classPlot
- Returns:
null
.
-
getOrientation
public PlotOrientation getOrientation()
Returns the orientation of the plot.- Specified by:
getOrientation
in interfaceZoomable
- Returns:
- The orientation (always
PlotOrientation.VERTICAL
).
-
isValidNumber
protected static boolean isValidNumber(double d)
Determine whether a number is valid and finite.- Parameters:
d
- the number to be tested.- Returns:
true
if the number is valid and finite, andfalse
otherwise.
-
inSubrange
private boolean inSubrange(int subrange, double value)
Returns true if the value is in the specified range, and false otherwise.- Parameters:
subrange
- the subrange.value
- the value to check.- Returns:
- A boolean.
-
getCurrentPaint
private java.awt.Paint getCurrentPaint()
Returns the mercury paint corresponding to the current data value. Called from thedraw(Graphics2D, Rectangle2D, Point2D, PlotState, PlotRenderingInfo)
method.- Returns:
- The paint (never
null
).
-
equals
public boolean equals(java.lang.Object obj)
Tests this plot for equality with another object. The plot's dataset is not considered in the test.
-
equal
private static boolean equal(double[][] array1, double[][] array2)
Tests two double[][] arrays for equality.- Parameters:
array1
- the first array (null
permitted).array2
- the second arrray (null
permitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the plot.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classPlot
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if the plot 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.
-
zoomDomainAxes
public void zoomDomainAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source)
Multiplies the range on the domain axis/axes by the specified factor.- Specified by:
zoomDomainAxes
in interfaceZoomable
- Parameters:
factor
- the zoom factor.state
- the plot state.source
- the source point.- See Also:
Zoomable.zoomRangeAxes(double, PlotRenderingInfo, Point2D)
-
zoomDomainAxes
public void zoomDomainAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source, boolean useAnchor)
Multiplies the range on the domain axis/axes by the specified factor.- Specified by:
zoomDomainAxes
in interfaceZoomable
- Parameters:
factor
- the zoom factor.state
- the plot state.source
- the source point.useAnchor
- a flag that controls whether or not the source point is used for the zoom anchor.- See Also:
Zoomable.zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)
-
zoomRangeAxes
public void zoomRangeAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source)
Multiplies the range on the range axis/axes by the specified factor.- Specified by:
zoomRangeAxes
in interfaceZoomable
- Parameters:
factor
- the zoom factor.state
- the plot state.source
- the source point.- See Also:
Zoomable.zoomDomainAxes(double, PlotRenderingInfo, Point2D)
-
zoomRangeAxes
public void zoomRangeAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source, boolean useAnchor)
Multiplies the range on the range axis/axes by the specified factor.- Specified by:
zoomRangeAxes
in interfaceZoomable
- Parameters:
factor
- the zoom factor.state
- the plot state.source
- the source point.useAnchor
- a flag that controls whether or not the source point is used for the zoom anchor.- See Also:
Zoomable.zoomDomainAxes(double, PlotRenderingInfo, Point2D)
-
zoomDomainAxes
public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, java.awt.geom.Point2D source)
This method does nothing.- Specified by:
zoomDomainAxes
in interfaceZoomable
- Parameters:
lowerPercent
- the lower percent.upperPercent
- the upper percent.state
- the plot state.source
- the source point.- See Also:
Zoomable.zoomRangeAxes(double, double, PlotRenderingInfo, Point2D)
-
zoomRangeAxes
public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, java.awt.geom.Point2D source)
Zooms the range axes.- Specified by:
zoomRangeAxes
in interfaceZoomable
- Parameters:
lowerPercent
- the lower percent.upperPercent
- the upper percent.state
- the plot state.source
- the source point.- See Also:
Zoomable.zoomDomainAxes(double, double, PlotRenderingInfo, Point2D)
-
isDomainZoomable
public boolean isDomainZoomable()
Returnsfalse
.- Specified by:
isDomainZoomable
in interfaceZoomable
- Returns:
- A boolean.
- See Also:
Zoomable.isRangeZoomable()
-
isRangeZoomable
public boolean isRangeZoomable()
Returnstrue
.- Specified by:
isRangeZoomable
in interfaceZoomable
- Returns:
- A boolean.
- See Also:
Zoomable.isDomainZoomable()
-
-