com.jrefinery.chart
Class ThermometerPlot

java.lang.Object
  extended by com.jrefinery.chart.Plot
      extended by com.jrefinery.chart.ThermometerPlot
All Implemented Interfaces:
AxisConstants, com.jrefinery.chart.event.AxisChangeListener, VerticalValuePlot, DatasetChangeListener

public class ThermometerPlot
extends Plot
implements VerticalValuePlot

A plot that displays a single value in a thermometer type display. NOTE: The Thermometer plot utilises a meter data set, however range options within this data set are not currently utilised. This is currently under consideration / development. The Thermometer supports a number of options 1. 3 ranges which could be viewed as Critical, Warning and Normal ranges. 2. The thermometer can be run in two modes: a. fixed range where colour changes on value, or b. 3 seperate ranges where colour changes with range changes. 3. Settable units to be displayed. 4. Settable display location for the value text


Field Summary
static int BULB
           
protected static int bulbDiameter
           
protected static int bulbRadius
          Some basic sizing options for the thermometer
protected static int columnDiameter
           
protected static int columnRadius
           
static int CRITICAL
           
protected  MeterDataset data
           
protected static int DISPLAY_HI
           
protected static int DISPLAY_LOW
           
protected static int DISPLAY_RANGE
           
protected  boolean drawLines
           
protected  boolean followValue
           
protected static int gapDiameter
           
protected static int gapRadius
           
protected  boolean ignoreDataModelRangeChanges
          Data Model Type : Basically used to enable / disable the code for supporting data model range changes.
static int LEFT
           
protected static int legendWidth
           
static int NONE
          the selection of where value is written on screen
static int NORMAL
          The three ranges
protected  java.awt.Color outerColour
          Colour for the outline of the thermometer
protected  java.awt.Stroke outerStroke
          Stokes for drawing
protected  int range
          Two range variables are utilised to track which range is the current for the display and data.
protected static int RANGE_HI
          Index to Range information matrix
protected static int RANGE_LOW
           
protected  ValueAxis rangeAxis
           
protected  int rangeData
           
protected  int rangeIndcatorStrokeSize
           
protected  double[][] rangeInfo
          Matrix of range data
protected  java.awt.Stroke rangeInidcatorStroke
           
protected  java.awt.Paint[] rangePaint
          Paint for each range
protected  int units
          The currently selected display units
protected static java.lang.String[] UNITS
           
static int UNITS_CELCIUS
           
static int UNITS_FARINHEIGHT
           
static int UNITS_NONE
          Units to be displayed
protected  java.awt.Color valueColour
          Colour that the value is written in
protected  java.awt.Font valueFont
          The font to write the value in
protected  java.text.DecimalFormat valueFormat
          Number format for the value
protected  int valueLocation
          Current location of where the value is written on screean
static int WARNING
           
 
Fields inherited from class com.jrefinery.chart.Plot
backgroundAlpha, backgroundImage, backgroundPaint, dataset, DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, firstSeriesIndex, foregroundAlpha, insets, listeners, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, outlinePaint, outlineStroke, seriesOutlinePaint, seriesOutlineStroke, seriesPaint, seriesStroke, shapeFactory, ZERO
 
Fields inherited from interface com.jrefinery.chart.AxisConstants
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_STROKE
 
Constructor Summary
ThermometerPlot()
           
ThermometerPlot(MeterDataset data)
          Constructor for the ThermometerPlot object
ThermometerPlot(MeterDataset data, java.awt.Insets insets, java.awt.Paint backgroundPaint, java.awt.Image backgroundImage, float backgroundAlpha, java.awt.Stroke outlineStroke, java.awt.Paint outlinePaint, float foregroundAlpha)
          Constructs a new plot.
 
Method Summary
 void datasetChanged(DatasetChangeEvent event)
          This is experimental, an early attempt to support data model ranges being changed
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, ChartRenderingInfo info)
          Draws the plot on a Java 2D graphics device (such as the screen or a printer).
 MeterDataset getData()
          Returns the dataset.
 boolean getFollowData()
          Get whether the thermometer paint changes with data (true) or range (false)
 java.util.List getLegendItemLabels()
           
 java.lang.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.
 java.lang.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.
 java.awt.Stroke getOuterStroke()
           
 java.lang.String getPlotType()
          Returns a short string describing the type of plot.
 int getRangeIndicatorWidth()
          Gets the width of the range inidictators
 java.awt.Paint getRangePaint(int range)
          Gets the paint used for a particular range
 boolean getShowValueLines(boolean b)
           
 int getUnits()
          Gets the display units
 int getValueDisplayLocation()
          Gets the display location for the value
 java.awt.Font getValueFont()
          Gets the Font used to display the current value
 Range getVerticalDataRange()
          Returns the range for the data to be plotted against the vertical axis.
 ValueAxis getVerticalValueAxis()
           
 boolean isCompatibleHorizontalAxis(Axis axis)
          Returns true if the axis is compatible with the meter plot, and false otherwise.
 boolean isCompatibleRangeAxis(ValueAxis axis)
          Checks the compatibility of a range axis, returning true if the axis is compatible with the plot, and false otherwise.
 boolean isCompatibleVerticalAxis(Axis axis)
          Returns true if the axis is compatible with the meter plot, and false otherwise.
protected static boolean isValidNumber(double i)
          Determine whether a number is valid and finite
 void propertyChange()
           
protected  void setAxisRange()
           
 void setData(MeterDataset data)
          Sets the data for the chart, replacing any existing data.
 void setDisplayLocation(int loc)
           
 void setDisplayRange(int range, double low, double hi)
           
 void setFollowData(boolean v)
          Sets the range colour change option.
 void setFont(java.awt.Font f)
          Sets the font for the thermometer plot.
 void setOuterStoke(java.awt.Stroke s)
           
 void setRange(int range, double low, double hi)
           
 void setRangeAxis(ValueAxis axis)
          Sets the range axis for the plot.
 void setRangeIndicatorWidth(int width)
          Sets the width of the range inidctators.
 void setRangeInfo(int range, double low, double hi)
          Sets information for a particular range
 void setRangeInfo(int range, double range_low, double range_hi, double display_low, double display_hi)
          Sets the rangeInfo attribute of the ThermometerPlot object
 void setRangePaint(int range, java.awt.Paint paint)
          Sets the paint to be used for a range
 void setShowValueLines(boolean b)
          Sets the display as to whether to show value lines in the output.
 void setThermometerColor(java.awt.Color c)
          Set the outline colour of the thermometer
 void setUnits(int u)
          Sets the units for this thermometer
 void setValueFont(java.awt.Font f)
          Sets the font for the current value display
 void setValueFormat(java.text.DecimalFormat fo)
          Sets the format attribute for the value label
 void zoom(double percent)
          A zoom method that does nothing.
 
Methods inherited from class com.jrefinery.chart.Plot
addChangeListener, axisChanged, drawOutlineAndBackground, getBackgroundAlpha, getBackgroundPaint, getDataset, getFirstSeriesIndex, getForegroundAlpha, getInsets, getOutlinePaint, getOutlineStroke, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesStroke, getShape, getShape, getShapeFactory, handleClick, isSubplot, notifyListeners, removeChangeListener, setBackgroundAlpha, setBackgroundImage, setBackgroundPaint, setDataset, setFirstSeriesIndex, setForegroundAlpha, setInsets, setOutlinePaint, setOutlineStroke, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesStroke, setSeriesStroke, setShapeFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNITS_NONE

public static final int UNITS_NONE
Units to be displayed

See Also:
Constant Field Values

UNITS_FARINHEIGHT

public static final int UNITS_FARINHEIGHT
See Also:
Constant Field Values

UNITS_CELCIUS

public static final int UNITS_CELCIUS
See Also:
Constant Field Values

UNITS

protected static final java.lang.String[] UNITS

data

protected MeterDataset data

units

protected int units
The currently selected display units


NONE

public static final int NONE
the selection of where value is written on screen

See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

BULB

public static final int BULB
See Also:
Constant Field Values

valueLocation

protected int valueLocation
Current location of where the value is written on screean


bulbRadius

protected static final int bulbRadius
Some basic sizing options for the thermometer

See Also:
Constant Field Values

bulbDiameter

protected static final int bulbDiameter
See Also:
Constant Field Values

columnRadius

protected static final int columnRadius
See Also:
Constant Field Values

columnDiameter

protected static final int columnDiameter
See Also:
Constant Field Values

gapRadius

protected static final int gapRadius
See Also:
Constant Field Values

gapDiameter

protected static final int gapDiameter
See Also:
Constant Field Values

legendWidth

protected static final int legendWidth
See Also:
Constant Field Values

NORMAL

public static int NORMAL
The three ranges


WARNING

public static int WARNING

CRITICAL

public static int CRITICAL

range

protected int range
Two range variables are utilised to track which range is the current for the display and data.


rangeData

protected int rangeData

RANGE_HI

protected static final int RANGE_HI
Index to Range information matrix

See Also:
Constant Field Values

RANGE_LOW

protected static final int RANGE_LOW
See Also:
Constant Field Values

DISPLAY_HI

protected static final int DISPLAY_HI
See Also:
Constant Field Values

DISPLAY_LOW

protected static final int DISPLAY_LOW
See Also:
Constant Field Values

DISPLAY_RANGE

protected static final int DISPLAY_RANGE
See Also:
Constant Field Values

rangeInfo

protected double[][] rangeInfo
Matrix of range data


rangePaint

protected java.awt.Paint[] rangePaint
Paint for each range


outerColour

protected java.awt.Color outerColour
Colour for the outline of the thermometer


valueColour

protected java.awt.Color valueColour
Colour that the value is written in


valueFont

protected java.awt.Font valueFont
The font to write the value in


valueFormat

protected java.text.DecimalFormat valueFormat
Number format for the value


outerStroke

protected java.awt.Stroke outerStroke
Stokes for drawing


rangeInidcatorStroke

protected java.awt.Stroke rangeInidcatorStroke

rangeIndcatorStrokeSize

protected int rangeIndcatorStrokeSize

followValue

protected boolean followValue

drawLines

protected boolean drawLines

ignoreDataModelRangeChanges

protected boolean ignoreDataModelRangeChanges
Data Model Type : Basically used to enable / disable the code for supporting data model range changes. Currently set to true as only experimetal and not functional.


rangeAxis

protected ValueAxis rangeAxis
Constructor Detail

ThermometerPlot

public ThermometerPlot()

ThermometerPlot

public ThermometerPlot(MeterDataset data)
Constructor for the ThermometerPlot object


ThermometerPlot

public ThermometerPlot(MeterDataset data,
                       java.awt.Insets insets,
                       java.awt.Paint backgroundPaint,
                       java.awt.Image backgroundImage,
                       float backgroundAlpha,
                       java.awt.Stroke outlineStroke,
                       java.awt.Paint outlinePaint,
                       float foregroundAlpha)
Constructs a new plot.

Parameters:
insets - Amount of blank space around the plot area.
backgroundPaint - An optional color for the plot's background.
backgroundImage - An optional image for the plot's background.
backgroundAlpha - Alpha-transparency for the plot's background.
outlineStroke - The Stroke used to draw an outline around the plot.
outlinePaint - The color used to draw an outline around the plot.
foregroundAlpha - The alpha-transparency for the plot foreground.
Method Detail

setRangeAxis

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

An exception is thrown if the new axis and the plot are not mutually compatible.

Parameters:
axis - The new axis (null permitted).
Throws:
AxisNotCompatibleException

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.

Specified by:
zoom in class Plot
Parameters:
percent - The zoom percentage.

getPlotType

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

Specified by:
getPlotType in class Plot
Returns:
The plotType value

getData

public MeterDataset getData()
Returns the dataset.

Provided for convenience.

Returns:
The dataset for the plot, cast as a MeterDataset.

setData

public void setData(MeterDataset data)
Sets the data for the chart, replacing any existing data.

Registered listeners are notified that the chart has been modified.

Parameters:
data - The new dataset.

isCompatibleHorizontalAxis

public boolean isCompatibleHorizontalAxis(Axis axis)
Returns true if the axis is compatible with the meter plot, and false otherwise. Since a Thermometer plot requires no horizontal axes, only a null axis is compatible.

Parameters:
axis - The axis.
Returns:
The compatibleHorizontalAxis value

isCompatibleVerticalAxis

public boolean isCompatibleVerticalAxis(Axis axis)
Returns true if the axis is compatible with the meter plot, and false otherwise. Since a Thermometer plot requires a VerticalNumberAxis, only a VerticalNumberAxis axis is compatible.

Parameters:
axis - The axis.
Returns:
The compatibleVerticalAxis value

isValidNumber

protected static boolean isValidNumber(double i)
Determine whether a number is valid and finite

Parameters:
i - The number to be tested
Returns:
where or not the number is valid and not infinite.

setValueFormat

public void setValueFormat(java.text.DecimalFormat fo)
Sets the format attribute for the value label

Parameters:
fo - The new value format

getValueDisplayLocation

public int getValueDisplayLocation()
Gets the display location for the value

Returns:
The display location for the value

setUnits

public void setUnits(int u)
Sets the units for this thermometer

Parameters:
u - The new units value

setFont

public void setFont(java.awt.Font f)
Sets the font for the thermometer plot.

Parameters:
f - The new font value.

setValueFont

public void setValueFont(java.awt.Font f)
Sets the font for the current value display

Parameters:
f - The new value font

getUnits

public int getUnits()
Gets the display units

Returns:
The units value

getValueFont

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

Returns:
The current value font

setRangePaint

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

Parameters:
range - The range
paint - The paint to be applied

getRangePaint

public java.awt.Paint getRangePaint(int range)
Gets the paint used for a particular range

Parameters:
range - The range
Returns:
The paint used

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 ChartRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

Specified by:
draw in class Plot
Parameters:
g2 - The graphics device.
plotArea - The area within which the plot should be drawn.
info - Collects info about the drawing.

setRangeInfo

public void setRangeInfo(int range,
                         double low,
                         double hi)
Sets information for a particular range

Parameters:
range - The range to specify information about
hi - The High value for the range
low - The Low value for the range

setRangeInfo

public void setRangeInfo(int range,
                         double range_low,
                         double range_hi,
                         double display_low,
                         double display_hi)
Sets the rangeInfo attribute of the ThermometerPlot object

Parameters:
range - The new rangeInfo value
range_hi - The new rangeInfo value
range_low - The new rangeInfo value
display_hi - The new rangeInfo value
display_low - The new rangeInfo value

setRange

public void setRange(int range,
                     double low,
                     double hi)

setDisplayRange

public void setDisplayRange(int range,
                            double low,
                            double hi)

setDisplayLocation

public void setDisplayLocation(int loc)

setThermometerColor

public void setThermometerColor(java.awt.Color c)
Set the outline colour of the thermometer

Parameters:
c - new colour to set the outline of the thermometer

datasetChanged

public void datasetChanged(DatasetChangeEvent event)
This is experimental, an early attempt to support data model ranges being changed

Specified by:
datasetChanged in interface DatasetChangeListener
Overrides:
datasetChanged in class Plot
Parameters:
event - Information about the event (not used here).

getMinimumVerticalDataValue

public java.lang.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.


getMaximumVerticalDataValue

public java.lang.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.


getVerticalDataRange

public Range getVerticalDataRange()
Description copied from interface: VerticalValuePlot
Returns the range for the data to be plotted against the vertical axis.

Specified by:
getVerticalDataRange in interface VerticalValuePlot
Returns:
The range.

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

getShowValueLines

public boolean getShowValueLines(boolean b)

setFollowData

public void setFollowData(boolean v)
Sets the range colour change option.

Parameters:
b - The new range colour change option

getFollowData

public boolean getFollowData()
Get whether the thermometer paint changes with data (true) or range (false)

Returns:
the value for follow data

setRangeIndicatorWidth

public void setRangeIndicatorWidth(int width)
Sets the width of the range inidctators. Set to 0 to disable range inidcator display.

Parameters:
size - the width of the inidcator. valid range 0-15 inclusive

getRangeIndicatorWidth

public int getRangeIndicatorWidth()
Gets the width of the range inidictators

Returns:
the width of range indicators

setOuterStoke

public void setOuterStoke(java.awt.Stroke s)

getOuterStroke

public java.awt.Stroke getOuterStroke()

propertyChange

public void propertyChange()

setAxisRange

protected void setAxisRange()

getLegendItemLabels

public java.util.List getLegendItemLabels()
Specified by:
getLegendItemLabels in class Plot

isCompatibleRangeAxis

public boolean isCompatibleRangeAxis(ValueAxis axis)
Checks the compatibility of a range axis, returning true if the axis is compatible with the plot, and false otherwise.

Parameters:
axis - The proposed axis.
Returns:
True if the axis is compatible with the plot, and false otherwise.

getVerticalValueAxis

public ValueAxis getVerticalValueAxis()
Specified by:
getVerticalValueAxis in interface VerticalValuePlot


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.