Class MeterPlot

    • Constructor Detail

      • MeterPlot

        public MeterPlot()
        Creates a new plot with a default range of 0 to 100 and no value to display.
      • MeterPlot

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

      • getMeterAngle

        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).
        See Also:
        setMeterAngle(int)
      • setMeterAngle

        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:
        getMeterAngle()
      • getRange

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

        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:
        getRange()
      • getTickSize

        public double getTickSize()
        Returns the tick size (the interval between ticks on the dial).
        Returns:
        The tick size.
        See Also:
        setTickSize(double)
      • setTickSize

        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:
        getTickSize()
      • getTickPaint

        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).
        See Also:
        setTickPaint(Paint)
      • setTickPaint

        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:
        getTickPaint()
      • getUnits

        public String getUnits()
        Returns a string describing the units for the dial.
        Returns:
        The units (possibly null).
        See Also:
        setUnits(String)
      • setUnits

        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:
        getUnits()
      • isValueVisible

        public boolean isValueVisible()
        Returns the flag that controls whether or not the value is visible. The default value is true.
        Returns:
        A flag.
        Since:
        1.5.4
        See Also:
        setValueVisible(boolean)
      • setValueVisible

        public void setValueVisible​(boolean valueVisible)
        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:
        isValueVisible()
      • setValueFont

        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:
        getValueFont()
      • setValuePaint

        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:
        getValuePaint()
      • getDrawBorder

        public boolean getDrawBorder()
        Returns a flag that controls whether or not a rectangular border is drawn around the plot area.
        Returns:
        A flag.
        See Also:
        setDrawBorder(boolean)
      • setDrawBorder

        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:
        getDrawBorder()
      • setDataset

        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:
        getDataset()
      • getLegendItems

        public org.jfree.chart.legend.LegendItemCollection getLegendItems()
        Returns an item for each interval.
        Specified by:
        getLegendItems in interface org.jfree.chart.legend.LegendItemSource
        Overrides:
        getLegendItems in class Plot
        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).
        Specified by:
        draw in class Plot
        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.
      • 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 (null not permitted).
        dial - a flag that indicates whether the arc represents the whole dial.
      • valueToAngle

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

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

        protected void drawTick​(Graphics2D g2,
                                Rectangle2D meterArea,
                                double value)
        Draws a tick.
        Parameters:
        g2 - the graphics device.
        meterArea - the meter area.
        value - the value.
      • drawTick

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

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

        public String getPlotType()
        Returns a short string describing the type of plot.
        Specified by:
        getPlotType in class Plot
        Returns:
        A string describing the type of 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 obj)
        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:
        obj - the object (null permitted).
        Returns:
        A boolean.