Package org.jfree.chart.plot
Class MeterPlot
java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.MeterPlot
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AnnotationChangeListener,AxisChangeListener,MarkerChangeListener,LegendItemSource,PublicCloneable,DatasetChangeListener
A plot that displays a single value in the form of a needle on a dial.
Defined ranges (for example, 'normal', 'warning' and 'critical') can be
highlighted on the dial.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatThe default border size.static final floatThe default circle size.static final FontThe default label font.static final intThe default meter angle.protected static ResourceBundleThe resourceBundle for the localization.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
ConstructorsConstructorDescriptionCreates a new plot with a default range of0to100and no value to display.MeterPlot(ValueDataset dataset) Creates a new plot that displays the value from the supplied dataset. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInterval(MeterInterval interval) Adds an interval and sends aPlotChangeEventto all registered listeners.voidClears the intervals for the plot and sends aPlotChangeEventto all registered listeners.clone()Returns an independent copy (clone) of the plot.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).protected voiddrawArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, Stroke stroke) Draws an arc.protected voiddrawArcForInterval(Graphics2D g2, Rectangle2D meterArea, MeterInterval interval) Draws the arc to represent an interval.protected voiddrawTick(Graphics2D g2, Rectangle2D meterArea, double value) Draws a tick.protected voiddrawTick(Graphics2D g2, Rectangle2D meterArea, double value, boolean label) Draws a tick on the dial.protected voiddrawTicks(Graphics2D g2, Rectangle2D meterArea, double minValue, double maxValue) Draws the ticks that subdivide the overall range.protected voiddrawValueLabel(Graphics2D g2, Rectangle2D area) Draws the value label just below the center of the dial.booleanTests the plot for equality with an arbitrary object.protected voidfillArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, boolean dial) Fills an arc on the dial between the given values.Returns the dataset for the plot.Returns the paint for the dial background.Returns the dial outline paint.Returns the dial shape.booleanReturns a flag that controls whether or not a rectangular border is drawn around the plot area.Returns an unmodifiable list of the intervals for the plot.Returns an item for each interval.intReturns the meter angle in degrees.Returns the paint for the needle.Returns a short string describing the type of plot.getRange()Returns the overall range for the dial.Returns the tick label font.Returns the tick label format.Returns the tick label paint.booleanReturns the flag that determines whether or not tick labels are visible.Returns the paint used to draw the ticks around the dial.doubleReturns the tick size (the interval between ticks on the dial).getUnits()Returns a string describing the units for the dial.Returns the font for the value label.Returns the paint for the value label.booleanReturns the flag that controls whether or not the value is visible.voidsetDataset(ValueDataset dataset) Sets the dataset for the plot, replacing the existing dataset if there is one, and triggers aPlotChangeEvent.voidsetDialBackgroundPaint(Paint paint) Sets the paint used to fill the dial background.voidsetDialOutlinePaint(Paint paint) Sets the dial outline paint and sends aPlotChangeEventto all registered listeners.voidsetDialShape(DialShape shape) Sets the dial shape and sends aPlotChangeEventto all registered listeners.voidsetDrawBorder(boolean draw) Sets the flag that controls whether or not a rectangular border is drawn around the plot area and sends aPlotChangeEventto all registered listeners.voidsetMeterAngle(int angle) Sets the angle (in degrees) for the whole range of the dial and sends aPlotChangeEventto all registered listeners.voidsetNeedlePaint(Paint paint) Sets the paint used to display the needle and sends aPlotChangeEventto all registered listeners.voidSets the range for the dial and sends aPlotChangeEventto all registered listeners.voidsetTickLabelFont(Font font) Sets the tick label font and sends aPlotChangeEventto all registered listeners.voidsetTickLabelFormat(NumberFormat format) Sets the format for the tick labels and sends aPlotChangeEventto all registered listeners.voidsetTickLabelPaint(Paint paint) Sets the tick label paint and sends aPlotChangeEventto all registered listeners.voidsetTickLabelsVisible(boolean visible) Sets the flag that controls whether or not the tick labels are visible and sends aPlotChangeEventto all registered listeners.voidsetTickPaint(Paint paint) Sets the paint used to draw the tick labels around the dial and sends aPlotChangeEventto all registered listeners.voidsetTickSize(double size) Sets the tick size and sends aPlotChangeEventto all registered listeners.voidSets the units for the dial and sends aPlotChangeEventto all registered listeners.voidsetValueFont(Font font) Sets the font used to display the value label and sends aPlotChangeEventto all registered listeners.voidsetValuePaint(Paint paint) Sets the paint used to display the value label and sends aPlotChangeEventto all registered listeners.voidsetValueVisible(boolean valueVisible) Sets the flag that controls whether or not the value is visible and sends a change event to all registered listeners.doublevalueToAngle(double value) Translates a data value to an angle on the dial.voidzoom(double percent) A zoom method that does nothing.Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, annotationChanged, axisChanged, canEqual, createAndAddEntity, datasetChanged, 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 Details
-
DEFAULT_METER_ANGLE
The default meter angle.- See Also:
-
DEFAULT_BORDER_SIZE
The default border size.- See Also:
-
DEFAULT_CIRCLE_SIZE
The default circle size.- See Also:
-
DEFAULT_LABEL_FONT
The default label font. -
localizationResources
The resourceBundle for the localization.
-
-
Constructor Details
-
MeterPlot
public MeterPlot()Creates a new plot with a default range of0to100and no value to display. -
MeterPlot
Creates a new plot that displays the value from the supplied dataset.- Parameters:
dataset- the dataset (nullpermitted).
-
-
Method Details
-
getDialShape
Returns the dial shape. The default isDialShape.CIRCLE).- Returns:
- The dial shape (never
null). - See Also:
-
setDialShape
Sets the dial shape and sends aPlotChangeEventto all registered listeners.- Parameters:
shape- the shape (nullnot permitted).- See Also:
-
getMeterAngle
Returns the meter angle in degrees. This defines, in part, the shape of the dial. The default is 270 degrees.- Returns:
- The meter angle (in degrees).
- See Also:
-
setMeterAngle
Sets the angle (in degrees) for the whole range of the dial and sends aPlotChangeEventto all registered listeners.- Parameters:
angle- the angle (in degrees, in the range 1-360).- See Also:
-
getRange
Returns the overall range for the dial.- Returns:
- The overall range (never
null). - See Also:
-
setRange
Sets the range for the dial and sends aPlotChangeEventto all registered listeners.- Parameters:
range- the range (nullnot permitted and zero-length ranges not permitted).- See Also:
-
getTickSize
Returns the tick size (the interval between ticks on the dial).- Returns:
- The tick size.
- See Also:
-
setTickSize
Sets the tick size and sends aPlotChangeEventto all registered listeners.- Parameters:
size- the tick size (must be > 0).- See Also:
-
getTickPaint
Returns the paint used to draw the ticks around the dial.- Returns:
- The paint used to draw the ticks around the dial (never
null). - See Also:
-
setTickPaint
Sets the paint used to draw the tick labels around the dial and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getUnits
Returns a string describing the units for the dial.- Returns:
- The units (possibly
null). - See Also:
-
setUnits
Sets the units for the dial and sends aPlotChangeEventto all registered listeners.- Parameters:
units- the units (nullpermitted).- See Also:
-
getNeedlePaint
Returns the paint for the needle.- Returns:
- The paint (never
null). - See Also:
-
setNeedlePaint
Sets the paint used to display the needle and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getTickLabelsVisible
Returns the flag that determines whether or not tick labels are visible.- Returns:
- The flag.
- See Also:
-
setTickLabelsVisible
Sets the flag that controls whether or not the tick labels are visible and sends aPlotChangeEventto all registered listeners.- Parameters:
visible- the flag.- See Also:
-
getTickLabelFont
Returns the tick label font.- Returns:
- The font (never
null). - See Also:
-
setTickLabelFont
Sets the tick label font and sends aPlotChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
-
getTickLabelPaint
Returns the tick label paint.- Returns:
- The paint (never
null). - See Also:
-
setTickLabelPaint
Sets the tick label paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
isValueVisible
Returns the flag that controls whether or not the value is visible. The default value istrue.- Returns:
- A flag.
- Since:
- 1.5.4
- See Also:
-
setValueVisible
Sets the flag that controls whether or not the value is visible and sends a change event to all registered listeners.- Parameters:
valueVisible- the new flag value.- Since:
- 1.5.4
- See Also:
-
getTickLabelFormat
Returns the tick label format.- Returns:
- The tick label format (never
null). - See Also:
-
setTickLabelFormat
Sets the format for the tick labels and sends aPlotChangeEventto all registered listeners.- Parameters:
format- the format (nullnot permitted).- See Also:
-
getValueFont
Returns the font for the value label.- Returns:
- The font (never
null). - See Also:
-
setValueFont
Sets the font used to display the value label and sends aPlotChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
-
getValuePaint
Returns the paint for the value label.- Returns:
- The paint (never
null). - See Also:
-
setValuePaint
Sets the paint used to display the value label and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getDialBackgroundPaint
Returns the paint for the dial background.- Returns:
- The paint (possibly
null). - See Also:
-
setDialBackgroundPaint
Sets the paint used to fill the dial background. Set this tonullfor no background.- Parameters:
paint- the paint (nullpermitted).- See Also:
-
getDrawBorder
Returns a flag that controls whether or not a rectangular border is drawn around the plot area.- Returns:
- A flag.
- See Also:
-
setDrawBorder
Sets the flag that controls whether or not a rectangular border is drawn around the plot area and sends aPlotChangeEventto all registered listeners.- Parameters:
draw- the flag.- See Also:
-
getDialOutlinePaint
Returns the dial outline paint.- Returns:
- The paint.
- See Also:
-
setDialOutlinePaint
Sets the dial outline paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint.- See Also:
-
getDataset
Returns the dataset for the plot.- Returns:
- The dataset (possibly
null). - See Also:
-
setDataset
Sets the dataset for the plot, replacing the existing dataset if there is one, and triggers aPlotChangeEvent.- Parameters:
dataset- the dataset (nullpermitted).- See Also:
-
getIntervals
Returns an unmodifiable list of the intervals for the plot.- Returns:
- A list.
- See Also:
-
addInterval
Adds an interval and sends aPlotChangeEventto all registered listeners.- Parameters:
interval- the interval (nullnot permitted).- See Also:
-
clearIntervals
Clears the intervals for the plot and sends aPlotChangeEventto all registered listeners.- See Also:
-
getLegendItems
Returns an item for each interval.- Specified by:
getLegendItemsin interfaceLegendItemSource- Overrides:
getLegendItemsin classPlot- Returns:
- A collection of legend items.
-
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). -
drawArcForInterval
Draws the arc to represent an interval.- Parameters:
g2- the graphics device.meterArea- the drawing area.interval- the interval.
-
drawArc
protected void drawArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, Stroke stroke) Draws an arc.- Parameters:
g2- the graphics device.area- the plot area.minValue- the minimum value.maxValue- the maximum value.paint- the paint.stroke- the stroke.
-
fillArc
protected void fillArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, boolean dial) Fills an arc on the dial between the given values.- Parameters:
g2- the graphics device.area- the plot area.minValue- the minimum data value.maxValue- the maximum data value.paint- the background paint (nullnot permitted).dial- a flag that indicates whether the arc represents the whole dial.
-
valueToAngle
Translates a data value to an angle on the dial.- Parameters:
value- the value.- Returns:
- The angle on the dial.
-
drawTicks
Draws the ticks that subdivide the overall range.- Parameters:
g2- the graphics device.meterArea- the meter area.minValue- the minimum value.maxValue- the maximum value.
-
drawTick
Draws a tick.- Parameters:
g2- the graphics device.meterArea- the meter area.value- the value.
-
drawTick
Draws a tick on the dial.- Parameters:
g2- the graphics device.meterArea- the meter area.value- the tick value.label- a flag that controls whether or not a value label is drawn.
-
drawValueLabel
Draws the value label just below the center of the dial.- Parameters:
g2- the graphics device.area- the plot area.
-
getPlotType
Returns a short string describing the type of plot.- Specified by:
getPlotTypein classPlot- Returns:
- A string describing the type of plot.
-
zoom
A zoom method that does nothing. Plots are required to support the zoom operation. In the case of a meter plot, it doesn't make sense to zoom in or out, so the method is empty. -
equals
Tests the plot for equality with an arbitrary object. Note that the dataset is ignored for the purposes of testing equality. -
clone
Returns an independent copy (clone) of the plot. The dataset is NOT cloned - both the original and the clone will have a reference to the same dataset.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classPlot- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if some component of the plot cannot be cloned.
-