Package org.jfree.chart.plot
Class ThermometerPlot
java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.ThermometerPlot
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AxisChangeListener,ValueAxisPlot,DatasetChangeListener
public class ThermometerPlot extends Plot implements ValueAxisPlot, Cloneable, Serializable
A plot that displays a single value (from a
ValueDataset) 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.
- Author:
- Bryan Scott
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static intBULBA constant for the value label position (in the thermometer bulb).static intCRITICALA constant for the 'critical' range.static intLEFTA constant for the value label position (left of the thermometer).static intNONEA constant for the value label position (no label).static intNORMALA constant for the 'normal' range.static intRIGHTA constant for the value label position (right of the thermometer).static intUNITS_CELCIUSA constant for unit type 'Celcius'.static intUNITS_FAHRENHEITA constant for unit type 'Fahrenheit'.static intUNITS_KELVINA constant for unit type 'Kelvin'.static intUNITS_NONEA constant for unit type 'None'.static intWARNINGA 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_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
Modifier and Type Method Description 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 plotArea, 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.intgetAxisocation()Returns the axis location.ValueDatasetgetData()Deprecated.Use getDataset() instead.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.ListgetLegendItemLabels()Deprecated.use getLegendItems().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.org.jfree.ui.SpacergetPadding()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.ValueAxisgetVerticalValueAxis()Returns the vertical value axis.voidsetAxisLocation(int location)Sets the location at which the axis is displayed with reference to the bulb.voidsetData(ValueDataset dataset)Deprecated.Use setDataset(...) instead.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(org.jfree.ui.Spacer 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 objectvoidsetSubrangePaint(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.voidzoomHorizontalAxes(double factor)Multiplies the range on the horizontal axis/axes by the specified factor.voidzoomHorizontalAxes(double lowerPercent, double upperPercent)Zooms the horizontal axes.voidzoomVerticalAxes(double factor)Multiplies the range on the vertical axis/axes by the specified factor.voidzoomVerticalAxes(double lowerPercent, double upperPercent)Zooms the vertical axes.Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, draw, drawBackground, drawOutline, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRootPlot, handleClick, isPlotShowing, isSubplot, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent, setPlotShowing
-
Field Details
-
UNITS_NONE
public static final int UNITS_NONEA constant for unit type 'None'.- See Also:
- Constant Field Values
-
UNITS_FAHRENHEIT
public static final int UNITS_FAHRENHEITA constant for unit type 'Fahrenheit'.- See Also:
- Constant Field Values
-
UNITS_CELCIUS
public static final int UNITS_CELCIUSA constant for unit type 'Celcius'.- See Also:
- Constant Field Values
-
UNITS_KELVIN
public static final int UNITS_KELVINA constant for unit type 'Kelvin'.- See Also:
- Constant Field Values
-
NONE
public static final int NONEA constant for the value label position (no label).- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHTA constant for the value label position (right of the thermometer).- See Also:
- Constant Field Values
-
LEFT
public static final int LEFTA constant for the value label position (left of the thermometer).- See Also:
- Constant Field Values
-
BULB
public static final int BULBA constant for the value label position (in the thermometer bulb).- See Also:
- Constant Field Values
-
NORMAL
public static final int NORMALA constant for the 'normal' range.- See Also:
- Constant Field Values
-
WARNING
public static final int WARNINGA constant for the 'warning' range.- See Also:
- Constant Field Values
-
CRITICAL
public static final int CRITICALA constant for the 'critical' range.- See Also:
- Constant Field Values
-
-
Constructor Details
-
ThermometerPlot
public ThermometerPlot()Creates a new thermometer plot. -
ThermometerPlot
Creates a new thermometer plot, using default attributes where necessary.- Parameters:
dataset- the data set.
-
-
Method Details
-
getDataset
Returns the primary dataset for the plot.- Returns:
- The primary dataset (possibly
null).
-
setDataset
Sets the dataset for the plot, replacing the existing dataset if there is one.- Parameters:
dataset- the dataset (nullpermitted).
-
getData
Deprecated.Use getDataset() instead.Returns the dataset cast toValueDataset(provided for convenience).- Returns:
- the dataset for the plot, cast as a
ValueDataset.
-
setData
Deprecated.Use setDataset(...) instead.Sets the data for the chart, replacing any existing data.Registered listeners are notified that the plot has been modified (this will normally trigger a chart redraw).
- Parameters:
dataset- the new dataset.
-
getRangeAxis
Returns the range axis.- Returns:
- the range axis.
-
setRangeAxis
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.
-
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.
-
setLowerBound
public void setLowerBound(double lower)Sets the lower bound for the thermometer.- Parameters:
lower- the lower bound.
-
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.
-
setUpperBound
public void setUpperBound(double upper)Sets the upper bound for the thermometer.- Parameters:
upper- the upper bound.
-
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 org.jfree.ui.Spacer getPadding()Returns the padding for the thermometer. This is the space inside the plot area.- Returns:
- the padding.
-
setPadding
public void setPadding(org.jfree.ui.Spacer padding)Sets the padding for the thermometer.- Parameters:
padding- the padding.
-
getThermometerStroke
Returns the stroke used to draw the thermometer outline.- Returns:
- the stroke.
-
setThermometerStroke
Sets the stroke used to draw the thermometer outline.- Parameters:
s- the new stroke (null ignored).
-
getThermometerPaint
Returns the paint used to draw the thermometer outline.- Returns:
- the paint.
-
setThermometerPaint
Sets the paint used to draw the thermometer outline.- Parameters:
paint- the new paint (null ignored).
-
getUnits
public int getUnits()Returns the unit display type (none/Fahrenheit/Celcius/Kelvin).- Returns:
- the units type.
-
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.
-
setUnits
Sets the unit type.- Parameters:
u- the unit type (null ignored).
-
getValueLocation
public int getValueLocation()Returns the value location.- Returns:
- the location.
-
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,RIGHTLEFTandBULB.- Parameters:
location- the location.
-
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,RIGHTandLEFT.- Parameters:
location- the location.
-
getAxisocation
public int getAxisocation()Returns the axis location.- Returns:
- the location.
-
getValueFont
Gets the font used to display the current value.- Returns:
- The font.
-
setValueFont
Sets the font used to display the current value.- Parameters:
f- the new font.
-
getValuePaint
Gets the paint used to display the current value.- Returns:
- the paint.
-
setValuePaint
Sets the paint used to display the current value.- Parameters:
p- the new paint.
-
setValueFormat
Sets the formatter for the value label.- Parameters:
formatter- the new formatter.
-
getMercuryPaint
Returns the default mercury paint.- Returns:
- the paint.
-
setMercuryPaint
Sets the default mercury paint.- Parameters:
paint- the new paint.
-
getShowValueLines
public boolean getShowValueLines()Returns the flag that controls whether not value lines are displayed.- Returns:
- the flag.
-
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
-
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 range.- 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 display range.- Parameters:
range- the range type.low- the low value.high- the high value.
-
getSubrangePaint
Gets the paint used for a particular subrange.- Parameters:
range- the range.- Returns:
- the paint.
-
setSubrangePaint
Sets the paint to be used for a range.- Parameters:
range- the range.paint- the paint to be applied.
-
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.
-
setUseSubrangePaint
public void setUseSubrangePaint(boolean flag)Sets the range colour change option.- Parameters:
flag- The new range colour change option
-
draw
public void draw(Graphics2D g2, Rectangle2D plotArea, 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
Returns a short string describing the type of plot.- Specified by:
getPlotTypein classPlot- Returns:
- a short string describing the type of plot.
-
datasetChanged
Checks to see if a new value means the axis range needs adjusting.- Specified by:
datasetChangedin interfaceDatasetChangeListener- Overrides:
datasetChangedin classPlot- Parameters:
event- the dataset change event.
-
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.
-
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
-
getDataRange
Returns the data range.- Specified by:
getDataRangein interfaceValueAxisPlot- Parameters:
axis- the axis.- Returns:
- The range of data displayed.
-
getLegendItemLabels
Deprecated.use getLegendItems().Returns null, since the thermometer plot won't require a legend.- Returns:
- null.
-
getLegendItems
Returns the legend items for the plot.- Overrides:
getLegendItemsin classPlot- Returns:
- null.
-
getVerticalValueAxis
Returns the vertical value axis.This is required by the VerticalValuePlot interface, but not used in this class.
- Returns:
- the vertical value axis.
-
equals
Tests this plot for equality with another object. -
clone
Returns a clone of the plot.- Overrides:
clonein classPlot- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if the plot cannot be cloned.
-
zoomHorizontalAxes
public void zoomHorizontalAxes(double factor)Multiplies the range on the horizontal axis/axes by the specified factor.- Specified by:
zoomHorizontalAxesin interfaceValueAxisPlot- Parameters:
factor- the zoom factor.
-
zoomVerticalAxes
public void zoomVerticalAxes(double factor)Multiplies the range on the vertical axis/axes by the specified factor.- Specified by:
zoomVerticalAxesin interfaceValueAxisPlot- Parameters:
factor- the zoom factor.
-
zoomHorizontalAxes
public void zoomHorizontalAxes(double lowerPercent, double upperPercent)Zooms the horizontal axes.- Specified by:
zoomHorizontalAxesin interfaceValueAxisPlot- Parameters:
lowerPercent- the lower percent.upperPercent- the upper percent.
-
zoomVerticalAxes
public void zoomVerticalAxes(double lowerPercent, double upperPercent)Zooms the vertical axes.- Specified by:
zoomVerticalAxesin interfaceValueAxisPlot- Parameters:
lowerPercent- the lower percent.upperPercent- the upper percent.
-