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
,AxisChangeListener
,DatasetChangeListener
public class MeterPlot extends Plot implements Serializable, Cloneable
A plot that displays a single value in the context of several ranges
('normal', 'warning' and 'critical').
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static int
CRITICAL_DATA_RANGE
Constant to indicate the critical data range.static String
CRITICAL_TEXT
The default text for the critical level.static Paint
DEFAULT_BACKGROUND_PAINT
The default background color.static float
DEFAULT_BORDER_SIZE
The default border size.static float
DEFAULT_CIRCLE_SIZE
The default circle size.static Font
DEFAULT_LABEL_FONT
The default label font.static int
DEFAULT_METER_ANGLE
The default meter angle.static int
DIALTYPE_CHORD
Constant for meter type 'chord'.static int
DIALTYPE_CIRCLE
Constant for meter type 'circle'.static int
DIALTYPE_PIE
Constant for meter type 'pie'.static int
FULL_DATA_RANGE
Constant to indicate the full data range.static int
NO_LABELS
Constant for the label type.static int
NORMAL_DATA_RANGE
Constant to indicate the normal data range.static String
NORMAL_TEXT
The default text for the normal level.static int
VALUE_LABELS
Constant for the label type.static int
WARNING_DATA_RANGE
Constant to indicate the warning data range.static String
WARNING_TEXT
The default text for the warning level.Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, 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 MeterPlot()
Creates a new plot with no dataset.MeterPlot(ValueDataset dataset)
Creates a new plot that displays the value in the supplied dataset. -
Method Summary
Modifier and Type Method Description Object
clone()
Correct cloning support, management of deeper copies and listenersvoid
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).boolean
equals(Object object)
Tests the plot for equality with an arbitrary object.Paint
getCriticalPaint()
Returns the paint used to display the 'critical' range.Range
getCriticalRange()
Returns the critical range for the dial.ValueDataset
getDataset()
Returns the primary dataset for the plot.Paint
getDialBackgroundPaint()
Returns the paint for the dial background.Paint
getDialOutlinePaint()
Returns the dial outline paint.DialShape
getDialShape()
Returns the dial shape.int
getDialType()
Deprecated.Use getDialShape().boolean
getDrawBorder()
Returns a flag that controls whether or not a rectangular border is drawn around the plot area.List
getLegendItemLabels()
Deprecated.use getLegendItems().LegendItemCollection
getLegendItems()
Returns null.int
getMeterAngle()
Returns the meter angle.Paint
getNeedlePaint()
Returns the paint for the needle.Paint
getNormalPaint()
Returns the paint for the 'normal' level.Range
getNormalRange()
Returns the normal range for the dial.String
getPlotType()
Returns a short string describing the type of plot.Range
getRange()
Returns the overall range for the dial.Font
getTickLabelFont()
Returns the tick label font.NumberFormat
getTickLabelFormat()
Returns the tick label format.int
getTickLabelType()
Returns the tick label type.String
getUnits()
Returns the units for the dial.Font
getValueFont()
Returns the font for the value label.Paint
getValuePaint()
Returns the paint for the value label.Paint
getWarningPaint()
Returns the paint used to display the 'warning' range.Range
getWarningRange()
Returns the warning range for the dial.void
setCriticalPaint(Paint paint)
Sets the paint used to display the 'critical' range.void
setCriticalRange(Range range)
Sets the critical range for the dial.void
setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.void
setDialBackgroundPaint(Paint paint)
Sets the paint used to fill the dial background.void
setDialOutlinePaint(Paint paint)
Sets the dial outline paint.void
setDialShape(DialShape shape)
Sets the dial shape.void
setDialType(int type)
Deprecated.Use setDialShape(...).void
setDrawBorder(boolean draw)
Sets the flag that controls whether or not a rectangular border is drawn around the plot area.void
setMeterAngle(int angle)
Sets the range through which the dial's needle is free to rotate.void
setNeedlePaint(Paint paint)
Sets the paint used to display the needle.void
setNormalPaint(Paint paint)
Sets the paint used to display the 'normal' range.void
setNormalRange(Range range)
Sets the normal range for the dial.void
setRange(Range range)
Sets the overall range for the dial.void
setTickLabelFont(Font font)
Sets the tick label font and sends aPlotChangeEvent
to all registered listeners.void
setTickLabelFormat(NumberFormat format)
Sets the format for the tick labels and sends aPlotChangeEvent
to all registered listeners.void
setTickLabelType(int type)
Sets the tick label type.void
setUnits(String units)
Sets the units for the dial.void
setValueFont(Font font)
Sets the font used to display the value label.void
setValuePaint(Paint paint)
Sets the paint used to display the value label.void
setWarningPaint(Paint paint)
Sets the paint used to display the 'warning' range.void
setWarningRange(Range range)
Sets the warning range for the dial.void
zoom(double percent)
A zoom method that does nothing.Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, datasetChanged, 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
-
NORMAL_DATA_RANGE
public static final int NORMAL_DATA_RANGEConstant to indicate the normal data range.- See Also:
- Constant Field Values
-
WARNING_DATA_RANGE
public static final int WARNING_DATA_RANGEConstant to indicate the warning data range.- See Also:
- Constant Field Values
-
CRITICAL_DATA_RANGE
public static final int CRITICAL_DATA_RANGEConstant to indicate the critical data range.- See Also:
- Constant Field Values
-
FULL_DATA_RANGE
public static final int FULL_DATA_RANGEConstant to indicate the full data range.- See Also:
- Constant Field Values
-
NORMAL_TEXT
The default text for the normal level.- See Also:
- Constant Field Values
-
WARNING_TEXT
The default text for the warning level.- See Also:
- Constant Field Values
-
CRITICAL_TEXT
The default text for the critical level.- See Also:
- Constant Field Values
-
DEFAULT_METER_ANGLE
public static final int DEFAULT_METER_ANGLEThe default meter angle.- See Also:
- Constant Field Values
-
DEFAULT_BORDER_SIZE
public static final float DEFAULT_BORDER_SIZEThe default border size.- See Also:
- Constant Field Values
-
DEFAULT_CIRCLE_SIZE
public static final float DEFAULT_CIRCLE_SIZEThe default circle size.- See Also:
- Constant Field Values
-
DEFAULT_BACKGROUND_PAINT
The default background color. -
DEFAULT_LABEL_FONT
The default label font. -
NO_LABELS
public static final int NO_LABELSConstant for the label type.- See Also:
- Constant Field Values
-
VALUE_LABELS
public static final int VALUE_LABELSConstant for the label type.- See Also:
- Constant Field Values
-
DIALTYPE_PIE
public static final int DIALTYPE_PIEConstant for meter type 'pie'.- See Also:
- Constant Field Values
-
DIALTYPE_CIRCLE
public static final int DIALTYPE_CIRCLEConstant for meter type 'circle'.- See Also:
- Constant Field Values
-
DIALTYPE_CHORD
public static final int DIALTYPE_CHORDConstant for meter type 'chord'.- See Also:
- Constant Field Values
-
-
Constructor Details
-
MeterPlot
public MeterPlot()Creates a new plot with no dataset. -
MeterPlot
Creates a new plot that displays the value in the supplied dataset.- Parameters:
dataset
- the dataset (null
permitted).
-
-
Method Details
-
getUnits
Returns the units for the dial.- Returns:
- The units.
-
setUnits
Sets the units for the dial.- Parameters:
units
- the units.
-
getRange
Returns the overall range for the dial.- Returns:
- The overall range.
-
setRange
Sets the overall range for the dial.- Parameters:
range
- the range.
-
getNormalRange
Returns the normal range for the dial.- Returns:
- The normal range.
-
setNormalRange
Sets the normal range for the dial.- Parameters:
range
- the range.
-
getWarningRange
Returns the warning range for the dial.- Returns:
- The warning range.
-
setWarningRange
Sets the warning range for the dial.- Parameters:
range
- the range.
-
getCriticalRange
Returns the critical range for the dial.- Returns:
- The critical range.
-
setCriticalRange
Sets the critical range for the dial.- Parameters:
range
- the range.
-
getDialShape
Returns the dial shape.- Returns:
- The dial shape.
-
setDialShape
Sets the dial shape.- Parameters:
shape
- the shape.
-
getDialBackgroundPaint
Returns the paint for the dial background.- Returns:
- The paint (possibly
null
).
-
setDialBackgroundPaint
Sets the paint used to fill the dial background.- Parameters:
paint
- the paint (null
permitted).
-
getNeedlePaint
Returns the paint for the needle.- Returns:
- The paint.
-
setNeedlePaint
Sets the paint used to display the needle.If you set this to null, it will revert to the default color.
- Parameters:
paint
- The paint.
-
getValueFont
Returns the font for the value label.- Returns:
- The font.
-
setValueFont
Sets the font used to display the value label.If you set this to null, it will revert to the default font.
- Parameters:
font
- The font.
-
getValuePaint
Returns the paint for the value label.- Returns:
- The paint.
-
setValuePaint
Sets the paint used to display the value label.If you set this to null, it will revert to the default paint.
- Parameters:
paint
- The paint.
-
getNormalPaint
Returns the paint for the 'normal' level.- Returns:
- The paint.
-
setNormalPaint
Sets the paint used to display the 'normal' range.If you set this to null, it will revert to the default color.
- Parameters:
paint
- The paint.
-
getWarningPaint
Returns the paint used to display the 'warning' range.- Returns:
- The paint.
-
setWarningPaint
Sets the paint used to display the 'warning' range.If you set this to null, it will revert to the default color.
- Parameters:
paint
- The paint.
-
getCriticalPaint
Returns the paint used to display the 'critical' range.- Returns:
- The paint.
-
setCriticalPaint
Sets the paint used to display the 'critical' range.If you set this to null, it will revert to the default color.
- Parameters:
paint
- The paint.
-
getTickLabelType
public int getTickLabelType()Returns the tick label type. Defined by the constants: NO_LABELS, VALUE_LABELS.- Returns:
- The tick label type.
-
setTickLabelType
public void setTickLabelType(int type)Sets the tick label type.- Parameters:
type
- the type of tick labels - eitherNO_LABELS
orVALUE_LABELS
-
getTickLabelFont
Returns the tick label font.- Returns:
- The font (never
null
).
-
setTickLabelFont
Sets the tick label font and sends aPlotChangeEvent
to all registered listeners.- Parameters:
font
- the font (null
not permitted).
-
getTickLabelFormat
Returns the tick label format.- Returns:
- The tick label format (never
null
).
-
setTickLabelFormat
Sets the format for the tick labels and sends aPlotChangeEvent
to all registered listeners.- Parameters:
format
- the format (null
not permitted).
-
getDrawBorder
public boolean getDrawBorder()Returns a flag that controls whether or not a rectangular border is drawn around the plot area.- Returns:
- A flag.
-
setDrawBorder
public void setDrawBorder(boolean draw)Sets the flag that controls whether or not a rectangular border is drawn around the plot area.Note: it looks like the true setting needs some work to provide some insets.
- Parameters:
draw
- the flag.
-
getMeterAngle
public int getMeterAngle()Returns the meter angle.- Returns:
- the meter angle.
-
setMeterAngle
public void setMeterAngle(int angle)Sets the range through which the dial's needle is free to rotate.- Parameters:
angle
- the angle.
-
getDialOutlinePaint
Returns the dial outline paint.- Returns:
- The paint.
-
setDialOutlinePaint
Sets the dial outline paint.- Parameters:
paint
- the paint.
-
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 (null
permitted).
-
getLegendItemLabels
Deprecated.use getLegendItems().Returns a list of legend item labels.- Returns:
- the legend item labels.
-
getLegendItems
Returns null.- Overrides:
getLegendItems
in classPlot
- Returns:
- null.
-
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). -
getPlotType
Returns a short string describing the type of plot.- Specified by:
getPlotType
in classPlot
- Returns:
- always Meter Plot.
-
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 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. -
getDialType
public int getDialType()Deprecated.Use getDialShape().Returns the type of dial (DIALTYPE_PIE, DIALTYPE_CIRCLE, DIALTYPE_CHORD).- Returns:
- The dial type.
-
setDialType
public void setDialType(int type)Deprecated.Use setDialShape(...).Sets the dial type (background shape).This controls the shape of the dial background. Use one of the constants: DIALTYPE_PIE, DIALTYPE_CIRCLE, or DIALTYPE_CHORD.
- Parameters:
type
- The dial type.
-
clone
Correct cloning support, management of deeper copies and listeners- Overrides:
clone
in classPlot
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if some component of the plot does not support cloning.- See Also:
Plot.clone()
-