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 Details

    • NORMAL_DATA_RANGE

      public static final int NORMAL_DATA_RANGE
      Constant to indicate the normal data range.
      See Also:
      Constant Field Values
    • WARNING_DATA_RANGE

      public static final int WARNING_DATA_RANGE
      Constant to indicate the warning data range.
      See Also:
      Constant Field Values
    • CRITICAL_DATA_RANGE

      public static final int CRITICAL_DATA_RANGE
      Constant to indicate the critical data range.
      See Also:
      Constant Field Values
    • FULL_DATA_RANGE

      public static final int FULL_DATA_RANGE
      Constant to indicate the full data range.
      See Also:
      Constant Field Values
    • NORMAL_TEXT

      public static final String NORMAL_TEXT
      The default text for the normal level.
      See Also:
      Constant Field Values
    • WARNING_TEXT

      public static final String WARNING_TEXT
      The default text for the warning level.
      See Also:
      Constant Field Values
    • CRITICAL_TEXT

      public static final 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 Paint DEFAULT_BACKGROUND_PAINT
      The default background color.
    • DEFAULT_LABEL_FONT

      public static final 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
    • 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
  • Constructor Details

    • MeterPlot

      public MeterPlot()
      Creates a new plot with no dataset.
    • MeterPlot

      public MeterPlot​(ValueDataset dataset)
      Creates a new plot that displays the value in the supplied dataset.
      Parameters:
      dataset - the dataset (null permitted).
  • Method Details

    • getUnits

      public String getUnits()
      Returns the units for the dial.
      Returns:
      The units.
    • setUnits

      public void setUnits​(String units)
      Sets the units for the dial.
      Parameters:
      units - the units.
    • getRange

      public Range getRange()
      Returns the overall range for the dial.
      Returns:
      The overall range.
    • setRange

      public void setRange​(Range range)
      Sets the overall range for the dial.
      Parameters:
      range - the range.
    • getNormalRange

      public Range getNormalRange()
      Returns the normal range for the dial.
      Returns:
      The normal range.
    • setNormalRange

      public void setNormalRange​(Range range)
      Sets the normal range for the dial.
      Parameters:
      range - the range.
    • getWarningRange

      public Range getWarningRange()
      Returns the warning range for the dial.
      Returns:
      The warning range.
    • setWarningRange

      public void setWarningRange​(Range range)
      Sets the warning range for the dial.
      Parameters:
      range - the range.
    • getCriticalRange

      public Range getCriticalRange()
      Returns the critical range for the dial.
      Returns:
      The critical range.
    • setCriticalRange

      public void setCriticalRange​(Range range)
      Sets the critical range for the dial.
      Parameters:
      range - the range.
    • getDialShape

      public DialShape getDialShape()
      Returns the dial shape.
      Returns:
      The dial shape.
    • setDialShape

      public void setDialShape​(DialShape shape)
      Sets the dial shape.
      Parameters:
      shape - the shape.
    • getDialBackgroundPaint

      public Paint getDialBackgroundPaint()
      Returns the paint for the dial background.
      Returns:
      The paint (possibly null).
    • setDialBackgroundPaint

      public void setDialBackgroundPaint​(Paint paint)
      Sets the paint used to fill the dial background.
      Parameters:
      paint - the paint (null permitted).
    • getNeedlePaint

      public Paint getNeedlePaint()
      Returns the paint for the needle.
      Returns:
      The paint.
    • setNeedlePaint

      public void setNeedlePaint​(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 Font getValueFont()
      Returns the font for the value label.
      Returns:
      The font.
    • setValueFont

      public void setValueFont​(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 Paint getValuePaint()
      Returns the paint for the value label.
      Returns:
      The paint.
    • setValuePaint

      public void setValuePaint​(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 Paint getNormalPaint()
      Returns the paint for the 'normal' level.
      Returns:
      The paint.
    • setNormalPaint

      public void setNormalPaint​(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 Paint getWarningPaint()
      Returns the paint used to display the 'warning' range.
      Returns:
      The paint.
    • setWarningPaint

      public void setWarningPaint​(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 Paint getCriticalPaint()
      Returns the paint used to display the 'critical' range.
      Returns:
      The paint.
    • setCriticalPaint

      public void setCriticalPaint​(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 Font getTickLabelFont()
      Returns the tick label font.
      Returns:
      The font (never null).
    • setTickLabelFont

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

      public NumberFormat getTickLabelFormat()
      Returns the tick label format.
      Returns:
      The tick label format (never null).
    • setTickLabelFormat

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

      public Paint getDialOutlinePaint()
      Returns the dial outline paint.
      Returns:
      The paint.
    • setDialOutlinePaint

      public void setDialOutlinePaint​(Paint paint)
      Sets the dial outline paint.
      Parameters:
      paint - the paint.
    • getDataset

      public ValueDataset getDataset()
      Returns the primary dataset for the plot.
      Returns:
      The primary dataset (possibly null).
    • setDataset

      public void setDataset​(ValueDataset dataset)
      Sets the dataset for the plot, replacing the existing dataset if there is one.
      Parameters:
      dataset - the dataset (null permitted).
    • getLegendItemLabels

      public 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​(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo 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.
      parentState - the state from the parent plot, if there is one.
      info - collects info about the drawing.
    • getPlotType

      public 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 meter plot, 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.
    • equals

      public boolean equals​(Object object)
      Tests the plot for equality with an arbitrary object. Note that the dataset is ignored for the purposes of testing equality.
      Overrides:
      equals in class Plot
      Parameters:
      object - the object (null permitted).
      Returns:
      A boolean.
    • 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

      public Object clone() throws CloneNotSupportedException
      Correct cloning support, management of deeper copies and listeners
      Overrides:
      clone in class Plot
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if some component of the plot does not support cloning.
      See Also:
      Plot.clone()