public class

MeterPlot

extends Plot
implements Serializable Cloneable
java.lang.Object
   ↳ org.jfree.chart.plot.Plot
     ↳ org.jfree.chart.plot.MeterPlot

Class Overview

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.

Summary

Constants
float DEFAULT_BORDER_SIZE The default border size.
float DEFAULT_CIRCLE_SIZE The default circle size.
int DEFAULT_METER_ANGLE The default meter angle.
[Expand]
Inherited Constants
From class org.jfree.chart.plot.Plot
Fields
public static final Font DEFAULT_LABEL_FONT The default label font.
protected static ResourceBundle localizationResources The resourceBundle for the localization.
[Expand]
Inherited Fields
From class org.jfree.chart.plot.Plot
Public Constructors
MeterPlot()
Creates a new plot with a default range of 0 to 100 and no value to display.
MeterPlot(ValueDataset dataset)
Creates a new plot that displays the value from the supplied dataset.
Public Methods
void addInterval(MeterInterval interval)
Adds an interval and sends a PlotChangeEvent to all registered listeners.
void clearIntervals()
Clears the intervals for the plot and sends a PlotChangeEvent to all registered listeners.
Object clone()
Returns an independent copy (clone) of the plot.
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).
boolean equals(Object obj)
Tests the plot for equality with an arbitrary object.
ValueDataset getDataset()
Returns the 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.
boolean getDrawBorder()
Returns a flag that controls whether or not a rectangular border is drawn around the plot area.
List getIntervals()
Returns an unmodifiable list of the intervals for the plot.
LegendItemCollection getLegendItems()
Returns an item for each interval.
int getMeterAngle()
Returns the meter angle in degrees.
Paint getNeedlePaint()
Returns the paint for the needle.
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.
Paint getTickLabelPaint()
Returns the tick label paint.
boolean getTickLabelsVisible()
Returns the flag that determines whether or not tick labels are visible.
Paint getTickPaint()
Returns the paint used to draw the ticks around the dial.
double getTickSize()
Returns the tick size (the interval between ticks on the dial).
String getUnits()
Returns a string describing the units for the dial.
Font getValueFont()
Returns the font for the value label.
Paint getValuePaint()
Returns the paint for the value label.
void setDataset(ValueDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one, and triggers a PlotChangeEvent.
void setDialBackgroundPaint(Paint paint)
Sets the paint used to fill the dial background.
void setDialOutlinePaint(Paint paint)
Sets the dial outline paint and sends a PlotChangeEvent to all registered listeners.
void setDialShape(DialShape shape)
Sets the dial shape and sends a PlotChangeEvent to all registered listeners.
void setDrawBorder(boolean draw)
Sets the flag that controls whether or not a rectangular border is drawn around the plot area and sends a PlotChangeEvent to all registered listeners.
void setMeterAngle(int angle)
Sets the angle (in degrees) for the whole range of the dial and sends a PlotChangeEvent to all registered listeners.
void setNeedlePaint(Paint paint)
Sets the paint used to display the needle and sends a PlotChangeEvent to all registered listeners.
void setRange(Range range)
Sets the range for the dial and sends a PlotChangeEvent to all registered listeners.
void setTickLabelFont(Font font)
Sets the tick label font and sends a PlotChangeEvent to all registered listeners.
void setTickLabelFormat(NumberFormat format)
Sets the format for the tick labels and sends a PlotChangeEvent to all registered listeners.
void setTickLabelPaint(Paint paint)
Sets the tick label paint and sends a PlotChangeEvent to all registered listeners.
void setTickLabelsVisible(boolean visible)
Sets the flag that controls whether or not the tick labels are visible and sends a PlotChangeEvent to all registered listeners.
void setTickPaint(Paint paint)
Sets the paint used to draw the tick labels around the dial and sends a PlotChangeEvent to all registered listeners.
void setTickSize(double size)
Sets the tick size and sends a PlotChangeEvent to all registered listeners.
void setUnits(String units)
Sets the units for the dial and sends a PlotChangeEvent to all registered listeners.
void setValueFont(Font font)
Sets the font used to display the value label and sends a PlotChangeEvent to all registered listeners.
void setValuePaint(Paint paint)
Sets the paint used to display the value label and sends a PlotChangeEvent to all registered listeners.
double valueToAngle(double value)
Translates a data value to an angle on the dial.
void zoom(double percent)
A zoom method that does nothing.
Protected Methods
void drawArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, Stroke stroke)
Draws an arc.
void drawArcForInterval(Graphics2D g2, Rectangle2D meterArea, MeterInterval interval)
Draws the arc to represent an interval.
void drawTick(Graphics2D g2, Rectangle2D meterArea, double value, boolean label)
Draws a tick on the dial.
void drawTick(Graphics2D g2, Rectangle2D meterArea, double value)
Draws a tick.
void drawTicks(Graphics2D g2, Rectangle2D meterArea, double minValue, double maxValue)
Draws the ticks that subdivide the overall range.
void drawValueLabel(Graphics2D g2, Rectangle2D area)
Draws the value label just below the center of the dial.
void fillArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, boolean dial)
Fills an arc on the dial between the given values.
[Expand]
Inherited Methods
From class org.jfree.chart.plot.Plot
From class java.lang.Object
From interface org.jfree.chart.LegendItemSource
From interface org.jfree.chart.event.AxisChangeListener
From interface org.jfree.chart.event.MarkerChangeListener
From interface org.jfree.data.general.DatasetChangeListener

Constants

public static final float DEFAULT_BORDER_SIZE

The default border size.

Constant Value: 3.0

public static final float DEFAULT_CIRCLE_SIZE

The default circle size.

Constant Value: 10.0

public static final int DEFAULT_METER_ANGLE

The default meter angle.

Constant Value: 270 (0x0000010e)

Fields

public static final Font DEFAULT_LABEL_FONT

The default label font.

protected static ResourceBundle localizationResources

The resourceBundle for the localization.

Public Constructors

public MeterPlot ()

Creates a new plot with a default range of 0 to 100 and no value to display.

public MeterPlot (ValueDataset dataset)

Creates a new plot that displays the value from the supplied dataset.

Parameters
dataset the dataset (null permitted).

Public Methods

public void addInterval (MeterInterval interval)

Adds an interval and sends a PlotChangeEvent to all registered listeners.

Parameters
interval the interval (null not permitted).

public void clearIntervals ()

Clears the intervals for the plot and sends a PlotChangeEvent to all registered listeners.

public Object 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.

Returns
  • A clone.
Throws
CloneNotSupportedException if some component of the plot cannot be cloned.

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).

Parameters
g2 the graphics device.
area the area within which the plot should be drawn.
anchor the anchor point (null permitted).
parentState the state from the parent plot, if there is one.
info collects info about the drawing.

public boolean equals (Object obj)

Tests the plot for equality with an arbitrary object. Note that the dataset is ignored for the purposes of testing equality.

Parameters
obj the object (null permitted).
Returns
  • A boolean.

public ValueDataset getDataset ()

Returns the dataset for the plot.

Returns
  • The dataset (possibly null).

public Paint getDialBackgroundPaint ()

Returns the paint for the dial background.

Returns
  • The paint (possibly null).

public Paint getDialOutlinePaint ()

Returns the dial outline paint.

Returns
  • The paint.

public DialShape getDialShape ()

Returns the dial shape. The default is CIRCLE).

Returns
  • The dial shape (never null).

public boolean getDrawBorder ()

Returns a flag that controls whether or not a rectangular border is drawn around the plot area.

Returns
  • A flag.

public List getIntervals ()

Returns an unmodifiable list of the intervals for the plot.

Returns
  • A list.

public LegendItemCollection getLegendItems ()

Returns an item for each interval.

Returns
  • A collection of legend items.

public int 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).

public Paint getNeedlePaint ()

Returns the paint for the needle.

Returns
  • The paint (never null).

public String getPlotType ()

Returns a short string describing the type of plot.

Returns
  • A string describing the type of plot.

public Range getRange ()

Returns the overall range for the dial.

Returns
  • The overall range (never null).
See Also

public Font getTickLabelFont ()

Returns the tick label font.

Returns
  • The font (never null).

public NumberFormat getTickLabelFormat ()

Returns the tick label format.

Returns
  • The tick label format (never null).

public Paint getTickLabelPaint ()

Returns the tick label paint.

Returns
  • The paint (never null).

public boolean getTickLabelsVisible ()

Returns the flag that determines whether or not tick labels are visible.

Returns
  • The flag.

public Paint 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).

public double getTickSize ()

Returns the tick size (the interval between ticks on the dial).

Returns
  • The tick size.

public String getUnits ()

Returns a string describing the units for the dial.

Returns
  • The units (possibly null).
See Also

public Font getValueFont ()

Returns the font for the value label.

Returns
  • The font (never null).

public Paint getValuePaint ()

Returns the paint for the value label.

Returns
  • The paint (never null).

public void setDataset (ValueDataset dataset)

Sets the dataset for the plot, replacing the existing dataset if there is one, and triggers a PlotChangeEvent.

Parameters
dataset the dataset (null permitted).
See Also

public void setDialBackgroundPaint (Paint paint)

Sets the paint used to fill the dial background. Set this to null for no background.

Parameters
paint the paint (null permitted).

public void setDialOutlinePaint (Paint paint)

Sets the dial outline paint and sends a PlotChangeEvent to all registered listeners.

Parameters
paint the paint.

public void setDialShape (DialShape shape)

Sets the dial shape and sends a PlotChangeEvent to all registered listeners.

Parameters
shape the shape (null not permitted).
See Also

public void setDrawBorder (boolean draw)

Sets the flag that controls whether or not a rectangular border is drawn around the plot area and sends a PlotChangeEvent to all registered listeners.

Parameters
draw the flag.
See Also

public void setMeterAngle (int angle)

Sets the angle (in degrees) for the whole range of the dial and sends a PlotChangeEvent to all registered listeners.

Parameters
angle the angle (in degrees, in the range 1-360).
See Also

public void setNeedlePaint (Paint paint)

Sets the paint used to display the needle and sends a PlotChangeEvent to all registered listeners.

Parameters
paint the paint (null not permitted).
See Also

public void setRange (Range range)

Sets the range for the dial and sends a PlotChangeEvent to all registered listeners.

Parameters
range the range (null not permitted and zero-length ranges not permitted).
See Also

public void setTickLabelFont (Font font)

Sets the tick label font and sends a PlotChangeEvent to all registered listeners.

Parameters
font the font (null not permitted).

public void setTickLabelFormat (NumberFormat format)

Sets the format for the tick labels and sends a PlotChangeEvent to all registered listeners.

Parameters
format the format (null not permitted).

public void setTickLabelPaint (Paint paint)

Sets the tick label paint and sends a PlotChangeEvent to all registered listeners.

Parameters
paint the paint (null not permitted).

public void setTickLabelsVisible (boolean visible)

Sets the flag that controls whether or not the tick labels are visible and sends a PlotChangeEvent to all registered listeners.

Parameters
visible the flag.

public void setTickPaint (Paint paint)

Sets the paint used to draw the tick labels around the dial and sends a PlotChangeEvent to all registered listeners.

Parameters
paint the paint (null not permitted).
See Also

public void setTickSize (double size)

Sets the tick size and sends a PlotChangeEvent to all registered listeners.

Parameters
size the tick size (must be > 0).
See Also

public void setUnits (String units)

Sets the units for the dial and sends a PlotChangeEvent to all registered listeners.

Parameters
units the units (null permitted).
See Also

public void setValueFont (Font font)

Sets the font used to display the value label and sends a PlotChangeEvent to all registered listeners.

Parameters
font the font (null not permitted).
See Also

public void setValuePaint (Paint paint)

Sets the paint used to display the value label and sends a PlotChangeEvent to all registered listeners.

Parameters
paint the paint (null not permitted).
See Also

public double valueToAngle (double value)

Translates a data value to an angle on the dial.

Parameters
value the value.
Returns
  • The angle on the dial.

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.

Parameters
percent The zoom percentage.

Protected Methods

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.

protected void drawArcForInterval (Graphics2D g2, Rectangle2D meterArea, MeterInterval interval)

Draws the arc to represent an interval.

Parameters
g2 the graphics device.
meterArea the drawing area.
interval the interval.

protected void drawTick (Graphics2D g2, Rectangle2D meterArea, double value, boolean label)

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.

protected void drawTick (Graphics2D g2, Rectangle2D meterArea, double value)

Draws a tick.

Parameters
g2 the graphics device.
meterArea the meter area.
value the value.

protected void drawTicks (Graphics2D g2, Rectangle2D meterArea, double minValue, double maxValue)

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.

protected void drawValueLabel (Graphics2D g2, Rectangle2D area)

Draws the value label just below the center of the dial.

Parameters
g2 the graphics device.
area the plot area.

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 (null not permitted).
dial a flag that indicates whether the arc represents the whole dial.