Class DialPlot

    • Field Detail

      • background

        private DialLayer background
        The background layer (optional).
      • cap

        private DialLayer cap
        The needle cap (optional).
      • dialFrame

        private DialFrame dialFrame
        The dial frame.
      • datasets

        private ObjectList datasets
        The dataset(s) for the dial plot.
      • scales

        private ObjectList scales
        The scale(s) for the dial plot.
      • datasetToScaleMap

        private ObjectList datasetToScaleMap
        Storage for keys that map datasets to scales.
      • layers

        private java.util.List layers
        The drawing layers for the dial plot.
      • pointers

        private java.util.List pointers
        The pointer(s) for the dial.
      • viewX

        private double viewX
        The x-coordinate for the view window.
      • viewY

        private double viewY
        The y-coordinate for the view window.
      • viewW

        private double viewW
        The width of the view window, expressed as a percentage.
      • viewH

        private double viewH
        The height of the view window, expressed as a percentage.
    • Constructor Detail

      • DialPlot

        public DialPlot()
        Creates a new instance of DialPlot.
      • DialPlot

        public DialPlot​(ValueDataset dataset)
        Creates a new instance of DialPlot.
        Parameters:
        dataset - the dataset (null permitted).
    • Method Detail

      • setBackground

        public void setBackground​(DialLayer background)
        Sets the background layer and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        background - the background layer (null permitted).
        See Also:
        getBackground()
      • setCap

        public void setCap​(DialLayer cap)
        Sets the cap and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        cap - the cap (null permitted).
        See Also:
        getCap()
      • setDialFrame

        public void setDialFrame​(DialFrame frame)
        Sets the dial's frame and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        frame - the frame (null not permitted).
        See Also:
        getDialFrame()
      • getViewX

        public double getViewX()
        Returns the x-coordinate of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
        Returns:
        The x-coordinate of the viewing rectangle.
        See Also:
        setView(double, double, double, double)
      • getViewY

        public double getViewY()
        Returns the y-coordinate of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
        Returns:
        The y-coordinate of the viewing rectangle.
        See Also:
        setView(double, double, double, double)
      • getViewWidth

        public double getViewWidth()
        Returns the width of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
        Returns:
        The width of the viewing rectangle.
        See Also:
        setView(double, double, double, double)
      • getViewHeight

        public double getViewHeight()
        Returns the height of the viewing rectangle. This is specified in the range 0.0 to 1.0, relative to the dial's framing rectangle.
        Returns:
        The height of the viewing rectangle.
        See Also:
        setView(double, double, double, double)
      • setView

        public void setView​(double x,
                            double y,
                            double w,
                            double h)
        Sets the viewing rectangle, relative to the dial's framing rectangle, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        x - the x-coordinate (in the range 0.0 to 1.0).
        y - the y-coordinate (in the range 0.0 to 1.0).
        w - the width (in the range 0.0 to 1.0).
        h - the height (in the range 0.0 to 1.0).
        See Also:
        getViewX(), getViewY(), getViewWidth(), getViewHeight()
      • addLayer

        public void addLayer​(DialLayer layer)
        Adds a layer to the plot and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        layer - the layer (null not permitted).
      • getLayerIndex

        public int getLayerIndex​(DialLayer layer)
        Returns the index for the specified layer.
        Parameters:
        layer - the layer (null not permitted).
        Returns:
        The layer index.
      • removeLayer

        public void removeLayer​(int index)
        Removes the layer at the specified index and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        index - the index.
      • removeLayer

        public void removeLayer​(DialLayer layer)
        Removes the specified layer and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        layer - the layer (null not permitted).
      • addPointer

        public void addPointer​(DialPointer pointer)
        Adds a pointer to the plot and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        pointer - the pointer (null not permitted).
      • getPointerIndex

        public int getPointerIndex​(DialPointer pointer)
        Returns the index for the specified pointer.
        Parameters:
        pointer - the pointer (null not permitted).
        Returns:
        The pointer index.
      • removePointer

        public void removePointer​(int index)
        Removes the pointer at the specified index and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        index - the index.
      • removePointer

        public void removePointer​(DialPointer pointer)
        Removes the specified pointer and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        pointer - the pointer (null not permitted).
      • getPointerForDataset

        public DialPointer getPointerForDataset​(int datasetIndex)
        Returns the dial pointer that is associated with the specified dataset, or null.
        Parameters:
        datasetIndex - the dataset index.
        Returns:
        The pointer.
      • getDataset

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

        public ValueDataset getDataset​(int index)
        Returns the dataset at the given index.
        Parameters:
        index - the dataset index.
        Returns:
        The dataset (possibly null).
      • setDataset

        public void setDataset​(ValueDataset dataset)
        Sets the dataset for the plot, replacing the existing dataset, if there is one, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        dataset - the dataset (null permitted).
      • setDataset

        public void setDataset​(int index,
                               ValueDataset dataset)
        Sets a dataset for the plot.
        Parameters:
        index - the dataset index.
        dataset - the dataset (null permitted).
      • getDatasetCount

        public int getDatasetCount()
        Returns the number of datasets.
        Returns:
        The number of datasets.
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D area,
                         java.awt.geom.Point2D anchor,
                         PlotState parentState,
                         PlotRenderingInfo info)
        Draws the plot. This method is usually called by the JFreeChart instance that manages the plot.
        Specified by:
        draw in class Plot
        Parameters:
        g2 - the graphics target.
        area - the area in which the plot should be drawn.
        anchor - the anchor point (typically the last point that the mouse clicked on, null is permitted).
        parentState - the state for the parent plot (if any).
        info - used to collect plot rendering info (null permitted).
      • viewToFrame

        private java.awt.geom.Rectangle2D viewToFrame​(java.awt.geom.Rectangle2D view)
        Returns the frame surrounding the specified view rectangle.
        Parameters:
        view - the view rectangle (null not permitted).
        Returns:
        The frame rectangle.
      • getValue

        public double getValue​(int datasetIndex)
        Returns the value from the specified dataset.
        Parameters:
        datasetIndex - the dataset index.
        Returns:
        The data value.
      • addScale

        public void addScale​(int index,
                             DialScale scale)
        Adds a dial scale to the plot and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        index - the scale index.
        scale - the scale (null not permitted).
      • getScale

        public DialScale getScale​(int index)
        Returns the scale at the given index.
        Parameters:
        index - the scale index.
        Returns:
        The scale (possibly null).
      • mapDatasetToScale

        public void mapDatasetToScale​(int index,
                                      int scaleIndex)
        Maps a dataset to a particular scale.
        Parameters:
        index - the dataset index (zero-based).
        scaleIndex - the scale index (zero-based).
      • getScaleForDataset

        public DialScale getScaleForDataset​(int datasetIndex)
        Returns the dial scale for a specific dataset.
        Parameters:
        datasetIndex - the dataset index.
        Returns:
        The dial scale.
      • rectangleByRadius

        public static java.awt.geom.Rectangle2D rectangleByRadius​(java.awt.geom.Rectangle2D rect,
                                                                  double radiusW,
                                                                  double radiusH)
        A utility method that computes a rectangle using relative radius values.
        Parameters:
        rect - the reference rectangle (null not permitted).
        radiusW - the width radius (must be > 0.0)
        radiusH - the height radius.
        Returns:
        A new rectangle.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this DialPlot instance for equality with an arbitrary object. The plot's dataset(s) is (are) not included in the test.
        Overrides:
        equals in class Plot
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • hashCode

        public int hashCode()
        Returns a hash code for this instance.
        Overrides:
        hashCode in class Plot
        Returns:
        The hash code.
      • getPlotType

        public java.lang.String getPlotType()
        Returns the plot type.
        Specified by:
        getPlotType in class Plot
        Returns:
        "DialPlot"
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream stream)
                          throws java.io.IOException
        Provides serialization support.
        Parameters:
        stream - the output stream.
        Throws:
        java.io.IOException - if there is an I/O error.
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Provides serialization support.
        Parameters:
        stream - the input stream.
        Throws:
        java.io.IOException - if there is an I/O error.
        java.lang.ClassNotFoundException - if there is a classpath problem.