org.jfree.chart.plot
Class MeterPlot

java.lang.Object
  |
  +--org.jfree.chart.plot.Plot
        |
        +--org.jfree.chart.plot.MeterPlot
All Implemented Interfaces:
AxisChangeListener, AxisConstants, DatasetChangeListener, java.util.EventListener, java.io.Serializable

public class MeterPlot
extends Plot
implements java.io.Serializable

A plot that displays a single value in the context of several ranges ('normal', 'warning' and 'critical').

Author:
Hari
See Also:
Serialized Form

Field Summary
static java.lang.String CRITICAL_TEXT
          The default text for the critical level.
static java.awt.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 java.awt.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 NO_LABELS
          Constant for the label type.
static java.lang.String NORMAL_TEXT
          The default text for the normal level.
static int VALUE_LABELS
          Constant for the label type.
static java.lang.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
 
Fields inherited from interface org.jfree.chart.axis.AxisConstants
BOTTOM, DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE, LEFT, RIGHT, TOP
 
Constructor Summary
MeterPlot(MeterDataset data)
          Default constructor.
 
Method Summary
 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).
 java.awt.Paint getCriticalPaint()
          Returns the paint used to display the 'critical' range.
 java.awt.Paint getDialBackgroundPaint()
          Returns the paint for the dial background.
 java.awt.Color getDialBorderColor()
          Returns the color of the border for the dial.
 int getDialType()
          Returns the type of dial (DIALTYPE_PIE, DIALTYPE_CIRCLE, DIALTYPE_CHORD).
 boolean getDrawBorder()
          Returns a flag that controls whether or not a rectangular border is drawn around the plot area.
 java.util.List getLegendItemLabels()
          Deprecated. use getLegendItems().
 LegendItemCollection getLegendItems()
          Returns null.
 int getMeterAngle()
          Returns the meter angle.
 MeterDataset getMeterDataset()
          Returns the dataset for the plot, cast as a MeterDataset.
 java.awt.Paint getNeedlePaint()
          Returns the paint for the needle.
 java.awt.Paint getNormalPaint()
          Returns the paint for the 'normal' level.
 java.lang.String getPlotType()
          Returns a short string describing the type of plot.
 java.awt.Font getTickLabelFont()
          Returns the tick label font.
 int getTickLabelType()
          Returns the tick label type.
 java.awt.Font getValueFont()
          Returns the font for the value label.
 java.awt.Paint getValuePaint()
          Returns the paint for the value label.
 java.awt.Paint getWarningPaint()
          Returns the paint used to display the 'warning' range.
 void setCriticalPaint(java.awt.Paint paint)
          Sets the paint used to display the 'critical' range.
 void setDialBackgroundPaint(java.awt.Paint paint)
          Sets the paint used to fill the dial background.
 void setDialBorderColor(java.awt.Color color)
          Sets the color for the border of the dial.
 void setDialType(int type)
          Sets the dial type (background shape).
 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(java.awt.Paint paint)
          Sets the paint used to display the needle.
 void setNormalPaint(java.awt.Paint paint)
          Sets the paint used to display the 'normal' range.
 void setTickLabelFont(java.awt.Font font)
          Sets the tick label font and notifies registered listeners that the plot has been changed.
 void setTickLabelType(int type)
          Sets the tick label type.
 void setValueFont(java.awt.Font font)
          Sets the font used to display the value label.
 void setValuePaint(java.awt.Paint paint)
          Sets the paint used to display the value label.
 void setWarningPaint(java.awt.Paint paint)
          Sets the paint used to display the 'warning' range.
 void zoom(double percent)
          A zoom method that does nothing.
 
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, datasetChanged, drawBackground, drawNoDataMessage, drawOutline, equals, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDataset, getDatasetGroup, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOppositeAxisLocation, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, getSecondaryDataset, handleClick, isSubplot, notifyListeners, removeChangeListener, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDataset, setDatasetGroup, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent, setSecondaryDataset
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIALTYPE_PIE

public static final int DIALTYPE_PIE
Constant for meter type 'pie'.

See Also:
Constant Field Values

DIALTYPE_CIRCLE

public static final int DIALTYPE_CIRCLE
Constant for meter type 'circle'.

See Also:
Constant Field Values

DIALTYPE_CHORD

public static final int DIALTYPE_CHORD
Constant for meter type 'chord'.

See Also:
Constant Field Values

NORMAL_TEXT

public static final java.lang.String NORMAL_TEXT
The default text for the normal level.

See Also:
Constant Field Values

WARNING_TEXT

public static final java.lang.String WARNING_TEXT
The default text for the warning level.

See Also:
Constant Field Values

CRITICAL_TEXT

public static final java.lang.String CRITICAL_TEXT
The default text for the critical level.

See Also:
Constant Field Values

DEFAULT_METER_ANGLE

public static final int DEFAULT_METER_ANGLE
The default meter angle.

See Also:
Constant Field Values

DEFAULT_BORDER_SIZE

public static final float DEFAULT_BORDER_SIZE
The default border size.

See Also:
Constant Field Values

DEFAULT_CIRCLE_SIZE

public static final float DEFAULT_CIRCLE_SIZE
The default circle size.

See Also:
Constant Field Values

DEFAULT_BACKGROUND_PAINT

public static final java.awt.Paint DEFAULT_BACKGROUND_PAINT
The default background color.


DEFAULT_LABEL_FONT

public static final java.awt.Font DEFAULT_LABEL_FONT
The default label font.


NO_LABELS

public static final int NO_LABELS
Constant for the label type.

See Also:
Constant Field Values

VALUE_LABELS

public static final int VALUE_LABELS
Constant for the label type.

See Also:
Constant Field Values
Constructor Detail

MeterPlot

public MeterPlot(MeterDataset data)
Default constructor.

Parameters:
data - The dataset.
Method Detail

getDialType

public int getDialType()
Returns the type of dial (DIALTYPE_PIE, DIALTYPE_CIRCLE, DIALTYPE_CHORD).

Returns:
The dial type.

setDialType

public void setDialType(int type)
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.

getDialBackgroundPaint

public java.awt.Paint getDialBackgroundPaint()
Returns the paint for the dial background.

Returns:
The paint.

setDialBackgroundPaint

public void setDialBackgroundPaint(java.awt.Paint paint)
Sets the paint used to fill the dial background.

If you set this to null, it will revert to the default color.

Parameters:
paint - The paint.

getNeedlePaint

public java.awt.Paint getNeedlePaint()
Returns the paint for the needle.

Returns:
The paint.

setNeedlePaint

public void setNeedlePaint(java.awt.Paint paint)
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

public java.awt.Font getValueFont()
Returns the font for the value label.

Returns:
The font.

setValueFont

public void setValueFont(java.awt.Font font)
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

public java.awt.Paint getValuePaint()
Returns the paint for the value label.

Returns:
The paint.

setValuePaint

public void setValuePaint(java.awt.Paint paint)
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

public java.awt.Paint getNormalPaint()
Returns the paint for the 'normal' level.

Returns:
The paint.

setNormalPaint

public void setNormalPaint(java.awt.Paint paint)
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

public java.awt.Paint getWarningPaint()
Returns the paint used to display the 'warning' range.

Returns:
The paint.

setWarningPaint

public void setWarningPaint(java.awt.Paint paint)
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

public java.awt.Paint getCriticalPaint()
Returns the paint used to display the 'critical' range.

Returns:
The paint.

setCriticalPaint

public void setCriticalPaint(java.awt.Paint paint)
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 - either NO_LABELS or VALUE_LABELS

getTickLabelFont

public java.awt.Font getTickLabelFont()
Returns the tick label font.

Returns:
The tick label font.

setTickLabelFont

public void setTickLabelFont(java.awt.Font font)
Sets the tick label font and notifies registered listeners that the plot has been changed.

Parameters:
font - The new tick label font.

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.

getDialBorderColor

public java.awt.Color getDialBorderColor()
Returns the color of the border for the dial.

Returns:
the color of the border for the dial.

setDialBorderColor

public void setDialBorderColor(java.awt.Color color)
Sets the color for the border of the dial.

Parameters:
color - the color.

getMeterDataset

public MeterDataset getMeterDataset()
Returns the dataset for the plot, cast as a MeterDataset.

Provided for convenience.

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

getLegendItemLabels

public java.util.List getLegendItemLabels()
Deprecated. use getLegendItems().

Returns a list of legend item labels.

Returns:
the legend item labels.

getLegendItems

public LegendItemCollection getLegendItems()
Returns null.

Overrides:
getLegendItems in class Plot
Returns:
null.

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.

getPlotType

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

Specified by:
getPlotType in class Plot
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 pie chart, it doesn't make sense to zoom in or out, so the method is empty.

Overrides:
zoom in class Plot
Parameters:
percent - The zoom percentage.