org.jfree.chart.plot

Class ThermometerPlot

public class ThermometerPlot extends Plot implements ValueAxisPlot, Zoomable, Cloneable, Serializable

A plot that displays a single value (from a ValueDataset) in a thermometer type display.

This plot supports a number of options:

  1. three sub-ranges which could be viewed as 'Normal', 'Warning' and 'Critical' ranges.
  2. the thermometer can be run in two modes:
    • fixed range, or
    • range adjusts to current sub-range.
  3. settable units to be displayed.
  4. settable display location for the value text.
Field Summary
protected static intAXIS_GAP
The axis gap.
static intBULB
A constant for the value label position (in the thermometer bulb).
protected static intBULB_DIAMETER
The bulb diameter.
protected static intBULB_RADIUS
The bulb radius.
protected static intCOLUMN_DIAMETER
The column diameter.
protected static intCOLUMN_RADIUS
The column radius.
static intCRITICAL
A constant for the 'critical' range.
protected static doubleDEFAULT_LOWER_BOUND
The default lower bound.
protected static doubleDEFAULT_UPPER_BOUND
The default upper bound.
protected static intDISPLAY_HIGH
Index for display high value in subrangeInfo matrix.
protected static intDISPLAY_LOW
Index for display low value in subrangeInfo matrix.
protected static intGAP_DIAMETER
The gap diameter.
protected static intGAP_RADIUS
The gap radius.
protected static ResourceBundlelocalizationResources
The resourceBundle for the localization.
static intLEFT
A constant for the value label position (left of the thermometer).
static intNONE
A constant for the value label position (no label).
static intNORMAL
A constant for the 'normal' range.
protected static intRANGE_HIGH
Index for high value in subrangeInfo matrix.
protected static intRANGE_LOW
Index for low value in subrangeInfo matrix.
static intRIGHT
A constant for the value label position (right of the thermometer).
protected static String[]UNITS
The unit strings.
static intUNITS_CELCIUS
A constant for unit type 'Celcius'.
static intUNITS_FAHRENHEIT
A constant for unit type 'Fahrenheit'.
static intUNITS_KELVIN
A constant for unit type 'Kelvin'.
static intUNITS_NONE
A constant for unit type 'None'.
static intWARNING
A constant for the 'warning' range.
Constructor Summary
ThermometerPlot()
Creates a new thermometer plot.
ThermometerPlot(ValueDataset dataset)
Creates a new thermometer plot, using default attributes where necessary.
Method Summary
Objectclone()
Returns a clone of the plot.
voiddatasetChanged(DatasetChangeEvent event)
Checks to see if a new value means the axis range needs adjusting.
voiddraw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).
booleanequals(Object obj)
Tests this plot for equality with another object.
intgetAxisLocation()
Returns the axis location.
RangegetDataRange(ValueAxis axis)
Returns the data range.
ValueDatasetgetDataset()
Returns the primary dataset for the plot.
booleangetFollowDataInSubranges()
Returns a flag that controls whether or not the thermometer axis zooms to display the subrange within which the data value falls.
LegendItemCollectiongetLegendItems()
Returns the legend items for the plot.
doublegetLowerBound()
Returns the lower bound for the thermometer.
NumbergetMaximumVerticalDataValue()
Returns the maximum value in either the domain or the range, whichever is displayed against the vertical axis for the particular type of plot implementing this interface.
PaintgetMercuryPaint()
Returns the default mercury paint.
NumbergetMinimumVerticalDataValue()
Returns the minimum value in either the domain or the range, whichever is displayed against the vertical axis for the particular type of plot implementing this interface.
PlotOrientationgetOrientation()
Returns the orientation of the plot.
RectangleInsetsgetPadding()
Returns the padding for the thermometer.
StringgetPlotType()
Returns a short string describing the type of plot.
ValueAxisgetRangeAxis()
Returns the range axis.
booleangetShowValueLines()
Returns the flag that controls whether not value lines are displayed.
PaintgetSubrangePaint(int range)
Gets the paint used for a particular subrange.
PaintgetThermometerPaint()
Returns the paint used to draw the thermometer outline.
StrokegetThermometerStroke()
Returns the stroke used to draw the thermometer outline.
intgetUnits()
Returns the unit display type (none/Fahrenheit/Celcius/Kelvin).
doublegetUpperBound()
Returns the upper bound for the thermometer.
booleangetUseSubrangePaint()
Returns a flag that controls whether or not the mercury color changes for each subrange.
FontgetValueFont()
Gets the font used to display the current value.
intgetValueLocation()
Returns the value location.
PaintgetValuePaint()
Gets the paint used to display the current value.
booleanisDomainZoomable()
Returns false.
booleanisRangeZoomable()
Returns true.
protected static booleanisValidNumber(double d)
Determine whether a number is valid and finite.
voidsetAxisLocation(int location)
Sets the location at which the axis is displayed with reference to the bulb.
protected voidsetAxisRange()
Sets the axis range to the current values in the rangeInfo array.
voidsetDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.
voidsetDisplayRange(int range, double low, double high)
Sets the display range.
voidsetFollowDataInSubranges(boolean flag)
Sets the flag that controls whether or not the thermometer axis zooms to display the subrange within which the data value falls.
voidsetLowerBound(double lower)
Sets the lower bound for the thermometer.
voidsetMercuryPaint(Paint paint)
Sets the default mercury paint.
voidsetPadding(RectangleInsets padding)
Sets the padding for the thermometer.
voidsetRange(double lower, double upper)
Sets the lower and upper bounds for the thermometer.
voidsetRangeAxis(ValueAxis axis)
Sets the range axis for the plot.
voidsetShowValueLines(boolean b)
Sets the display as to whether to show value lines in the output.
voidsetSubrange(int range, double low, double high)
Sets the range.
voidsetSubrangeInfo(int range, double low, double hi)
Sets information for a particular range.
voidsetSubrangeInfo(int range, double rangeLow, double rangeHigh, double displayLow, double displayHigh)
Sets the subrangeInfo attribute of the ThermometerPlot object
voidsetSubrangePaint(int range, Paint paint)
Sets the paint to be used for a range.
voidsetThermometerPaint(Paint paint)
Sets the paint used to draw the thermometer outline.
voidsetThermometerStroke(Stroke s)
Sets the stroke used to draw the thermometer outline.
voidsetUnits(int u)
Sets the units to be displayed in the thermometer.
voidsetUnits(String u)
Sets the unit type.
voidsetUpperBound(double upper)
Sets the upper bound for the thermometer.
voidsetUseSubrangePaint(boolean flag)
Sets the range colour change option.
voidsetValueFont(Font f)
Sets the font used to display the current value.
voidsetValueFormat(NumberFormat formatter)
Sets the formatter for the value label.
voidsetValueLocation(int location)
Sets the location at which the current value is displayed.
voidsetValuePaint(Paint p)
Sets the paint used to display the current value.
voidzoom(double percent)
A zoom method that does nothing.
voidzoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source)
Multiplies the range on the domain axis/axes by the specified factor.
voidzoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
This method does nothing.
voidzoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source)
Multiplies the range on the range axis/axes by the specified factor.
voidzoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
Zooms the range axes.

Field Detail

AXIS_GAP

protected static final int AXIS_GAP
The axis gap.

BULB

public static final int BULB
A constant for the value label position (in the thermometer bulb).

BULB_DIAMETER

protected static final int BULB_DIAMETER
The bulb diameter.

BULB_RADIUS

protected static final int BULB_RADIUS
The bulb radius.

COLUMN_DIAMETER

protected static final int COLUMN_DIAMETER
The column diameter.

COLUMN_RADIUS

protected static final int COLUMN_RADIUS
The column radius.

CRITICAL

public static final int CRITICAL
A constant for the 'critical' range.

DEFAULT_LOWER_BOUND

protected static final double DEFAULT_LOWER_BOUND
The default lower bound.

DEFAULT_UPPER_BOUND

protected static final double DEFAULT_UPPER_BOUND
The default upper bound.

DISPLAY_HIGH

protected static final int DISPLAY_HIGH
Index for display high value in subrangeInfo matrix.

DISPLAY_LOW

protected static final int DISPLAY_LOW
Index for display low value in subrangeInfo matrix.

GAP_DIAMETER

protected static final int GAP_DIAMETER
The gap diameter.

GAP_RADIUS

protected static final int GAP_RADIUS
The gap radius.

localizationResources

protected static ResourceBundle localizationResources
The resourceBundle for the localization.

LEFT

public static final int LEFT
A constant for the value label position (left of the thermometer).

NONE

public static final int NONE
A constant for the value label position (no label).

NORMAL

public static final int NORMAL
A constant for the 'normal' range.

RANGE_HIGH

protected static final int RANGE_HIGH
Index for high value in subrangeInfo matrix.

RANGE_LOW

protected static final int RANGE_LOW
Index for low value in subrangeInfo matrix.

RIGHT

public static final int RIGHT
A constant for the value label position (right of the thermometer).

UNITS

protected static final String[] UNITS
The unit strings.

UNITS_CELCIUS

public static final int UNITS_CELCIUS
A constant for unit type 'Celcius'.

UNITS_FAHRENHEIT

public static final int UNITS_FAHRENHEIT
A constant for unit type 'Fahrenheit'.

UNITS_KELVIN

public static final int UNITS_KELVIN
A constant for unit type 'Kelvin'.

UNITS_NONE

public static final int UNITS_NONE
A constant for unit type 'None'.

WARNING

public static final int WARNING
A constant for the 'warning' range.

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

clone

public Object clone()
Returns a clone of the plot.

Returns: A clone.

Throws: CloneNotSupportedException if the plot cannot be cloned.

datasetChanged

public void datasetChanged(DatasetChangeEvent event)
Checks to see if a new value means the axis range needs adjusting.

Parameters: event the dataset change event.

draw

public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

Parameters: g2 the graphics device. area the area within which the plot should be drawn. anchor the anchor point (null permitted). parentState the state from the parent plot, if there is one. info collects info about the drawing.

equals

public boolean equals(Object obj)
Tests this plot for equality with another object. The plot's dataset is not considered in the test.

Parameters: obj the object (null permitted).

Returns: true or false.

getAxisLocation

public int getAxisLocation()
Returns the axis location.

Returns: The location.

getDataRange

public Range getDataRange(ValueAxis axis)
Returns the data range.

Parameters: axis the axis.

Returns: The range of data displayed.

getDataset

public ValueDataset getDataset()
Returns the primary dataset for the plot.

Returns: The primary dataset (possibly null).

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.

getLegendItems

public LegendItemCollection getLegendItems()
Returns the legend items for the plot.

Returns: null.

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.

getMaximumVerticalDataValue

public Number getMaximumVerticalDataValue()
Returns the maximum value in either the domain or the range, whichever is displayed against the vertical axis for the particular type of plot implementing this interface.

Returns: The maximum value in either the domain or the range

getMercuryPaint

public Paint getMercuryPaint()
Returns the default mercury paint.

Returns: The paint.

getMinimumVerticalDataValue

public Number getMinimumVerticalDataValue()
Returns the minimum value in either the domain or the range, whichever is displayed against the vertical axis for the particular type of plot implementing this interface.

Returns: The minimum value in either the domain or the range.

getOrientation

public PlotOrientation getOrientation()
Returns the orientation of the plot.

Returns: The orientation (always VERTICAL).

getPadding

public RectangleInsets getPadding()
Returns the padding for the thermometer. This is the space inside the plot area.

Returns: The padding.

getPlotType

public String getPlotType()
Returns a short string describing the type of plot.

Returns: A short string describing the type of plot.

getRangeAxis

public ValueAxis getRangeAxis()
Returns the range axis.

Returns: The range axis.

getShowValueLines

public boolean getShowValueLines()
Returns the flag that controls whether not value lines are displayed.

Returns: The flag.

getSubrangePaint

public Paint getSubrangePaint(int range)
Gets the paint used for a particular subrange.

Parameters: range the range.

Returns: The paint.

getThermometerPaint

public Paint getThermometerPaint()
Returns the paint used to draw the thermometer outline.

Returns: The paint.

getThermometerStroke

public Stroke getThermometerStroke()
Returns the stroke used to draw the thermometer outline.

Returns: The stroke.

getUnits

public int getUnits()
Returns the unit display type (none/Fahrenheit/Celcius/Kelvin).

Returns: The units type.

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.

getUseSubrangePaint

public boolean getUseSubrangePaint()
Returns a flag that controls whether or not the mercury color changes for each subrange.

Returns: The flag.

getValueFont

public Font getValueFont()
Gets the font used to display the current value.

Returns: The font.

getValueLocation

public int getValueLocation()
Returns the value location.

Returns: The location.

getValuePaint

public Paint getValuePaint()
Gets the paint used to display the current value.

Returns: The paint.

isDomainZoomable

public boolean isDomainZoomable()
Returns false.

Returns: A boolean.

isRangeZoomable

public boolean isRangeZoomable()
Returns true.

Returns: A boolean.

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, and false otherwise.

setAxisLocation

public void setAxisLocation(int location)
Sets the location at which the axis is displayed with reference to the bulb.

The location can be one of the constants: NONE, RIGHT and LEFT.

Parameters: location the location.

setAxisRange

protected void setAxisRange()
Sets the axis range to the current values in the rangeInfo array.

setDataset

public void setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.

Parameters: dataset the dataset (null permitted).

setDisplayRange

public void setDisplayRange(int range, double low, double high)
Sets the display range.

Parameters: range the range type. low the low value. high the high value.

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.

setLowerBound

public void setLowerBound(double lower)
Sets the lower bound for the thermometer.

Parameters: lower the lower bound.

setMercuryPaint

public void setMercuryPaint(Paint paint)
Sets the default mercury paint.

Parameters: paint the new paint.

setPadding

public void setPadding(RectangleInsets padding)
Sets the padding for the thermometer.

Parameters: padding the padding.

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.

setRangeAxis

public void setRangeAxis(ValueAxis axis)
Sets the range axis for the plot.

Parameters: axis the new axis.

setShowValueLines

public void setShowValueLines(boolean b)
Sets the display as to whether to show value lines in the output.

Parameters: b Whether to show value lines in the thermometer

setSubrange

public void setSubrange(int range, double low, double high)
Sets the range.

Parameters: range the range type. low the low value. high the high value.

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 range hi 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 value rangeHigh the new rangeInfo value displayLow the new rangeInfo value displayHigh the new rangeInfo value

setSubrangePaint

public void setSubrangePaint(int range, Paint paint)
Sets the paint to be used for a range.

Parameters: range the range. paint the paint to be applied.

setThermometerPaint

public void setThermometerPaint(Paint paint)
Sets the paint used to draw the thermometer outline.

Parameters: paint the new paint (null ignored).

setThermometerStroke

public void setThermometerStroke(Stroke s)
Sets the stroke used to draw the thermometer outline.

Parameters: s the new stroke (null ignored).

setUnits

public void setUnits(int u)
Sets the units to be displayed in the thermometer.

Use one of the following constants:

Parameters: u the new unit type.

setUnits

public void setUnits(String u)
Sets the unit type.

Parameters: u the unit type (null ignored).

setUpperBound

public void setUpperBound(double upper)
Sets the upper bound for the thermometer.

Parameters: upper the upper bound.

setUseSubrangePaint

public void setUseSubrangePaint(boolean flag)
Sets the range colour change option.

Parameters: flag The new range colour change option

setValueFont

public void setValueFont(Font f)
Sets the font used to display the current value.

Parameters: f the new font.

setValueFormat

public void setValueFormat(NumberFormat formatter)
Sets the formatter for the value label.

Parameters: formatter the new formatter.

setValueLocation

public void setValueLocation(int location)
Sets the location at which the current value is displayed.

The location can be one of the constants: NONE, RIGHT LEFT and BULB.

Parameters: location the location.

setValuePaint

public void setValuePaint(Paint p)
Sets the paint used to display the current value.

Parameters: p the new paint.

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.

Parameters: percent the zoom percentage.

zoomDomainAxes

public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source)
Multiplies the range on the domain axis/axes by the specified factor.

Parameters: factor the zoom factor. state the plot state. source the source point.

zoomDomainAxes

public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
This method does nothing.

Parameters: lowerPercent the lower percent. upperPercent the upper percent. state the plot state. source the source point.

zoomRangeAxes

public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source)
Multiplies the range on the range axis/axes by the specified factor.

Parameters: factor the zoom factor. state the plot state. source the source point.

zoomRangeAxes

public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source)
Zooms the range axes.

Parameters: lowerPercent the lower percent. upperPercent the upper percent. state the plot state. source the source point.