Class SymbolAxis

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, PublicCloneable

    public class SymbolAxis
    extends NumberAxis
    implements java.io.Serializable
    A standard linear value axis that replaces integer values with symbols.
    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        For serialization.
        See Also:
        Constant Field Values
      • DEFAULT_GRID_BAND_PAINT

        public static final java.awt.Paint DEFAULT_GRID_BAND_PAINT
        The default grid band paint.
      • DEFAULT_GRID_BAND_ALTERNATE_PAINT

        public static final java.awt.Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT
        The default paint for alternate grid bands.
      • symbols

        private java.util.List symbols
        The list of symbols to display instead of the numeric values.
      • gridBandsVisible

        private boolean gridBandsVisible
        Flag that indicates whether or not grid bands are visible.
      • gridBandPaint

        private transient java.awt.Paint gridBandPaint
        The paint used to color the grid bands (if the bands are visible).
      • gridBandAlternatePaint

        private transient java.awt.Paint gridBandAlternatePaint
        The paint used to fill the alternate grid bands.
    • Constructor Detail

      • SymbolAxis

        public SymbolAxis​(java.lang.String label,
                          java.lang.String[] sv)
        Constructs a symbol axis, using default attribute values where necessary.
        Parameters:
        label - the axis label (null permitted).
        sv - the list of symbols to display instead of the numeric values.
    • Method Detail

      • getSymbols

        public java.lang.String[] getSymbols()
        Returns an array of the symbols for the axis.
        Returns:
        The symbols.
      • isGridBandsVisible

        public boolean isGridBandsVisible()
        Returns the flag that controls whether or not grid bands are drawn for the axis. The default value is true.
        Returns:
        A boolean.
        See Also:
        setGridBandsVisible(boolean)
      • setGridBandsVisible

        public void setGridBandsVisible​(boolean flag)
        Sets the flag that controls whether or not grid bands are drawn for this axis and notifies registered listeners that the axis has been modified. Each band is the area between two adjacent gridlines running perpendicular to the axis. When the bands are drawn they are filled with the colors getGridBandPaint() and getGridBandAlternatePaint() in an alternating sequence.
        Parameters:
        flag - the new setting.
        See Also:
        isGridBandsVisible()
      • setGridBandPaint

        public void setGridBandPaint​(java.awt.Paint paint)
        Sets the grid band paint and notifies registered listeners that the axis has been changed. See the setGridBandsVisible(boolean) method for more information about grid bands.
        Parameters:
        paint - the paint (null not permitted).
        See Also:
        getGridBandPaint()
      • selectAutoTickUnit

        protected void selectAutoTickUnit​(java.awt.Graphics2D g2,
                                          java.awt.geom.Rectangle2D dataArea,
                                          RectangleEdge edge)
        This operation is not supported by this axis.
        Overrides:
        selectAutoTickUnit in class NumberAxis
        Parameters:
        g2 - the graphics device.
        dataArea - the area in which the plot and axes should be drawn.
        edge - the edge along which the axis is drawn.
      • draw

        public AxisState draw​(java.awt.Graphics2D g2,
                              double cursor,
                              java.awt.geom.Rectangle2D plotArea,
                              java.awt.geom.Rectangle2D dataArea,
                              RectangleEdge edge,
                              PlotRenderingInfo plotState)
        Draws the axis on a Java 2D graphics device (such as the screen or a printer).
        Overrides:
        draw in class NumberAxis
        Parameters:
        g2 - the graphics device (null not permitted).
        cursor - the cursor location.
        plotArea - the area within which the plot and axes should be drawn (null not permitted).
        dataArea - the area within which the data should be drawn (null not permitted).
        edge - the axis location (null not permitted).
        plotState - collects information about the plot (null permitted).
        Returns:
        The axis state (never null).
      • drawGridBands

        protected void drawGridBands​(java.awt.Graphics2D g2,
                                     java.awt.geom.Rectangle2D plotArea,
                                     java.awt.geom.Rectangle2D dataArea,
                                     RectangleEdge edge,
                                     java.util.List ticks)
        Draws the grid bands (alternate bands are colored using getGridBandPaint() and getGridBandAlternatePaint().
        Parameters:
        g2 - the graphics target (null not permitted).
        plotArea - the area within which the plot is drawn (null not permitted).
        dataArea - the data area to which the axes are aligned (null not permitted).
        edge - the edge to which the axis is aligned (null not permitted).
        ticks - the ticks (null not permitted).
      • drawGridBandsHorizontal

        protected void drawGridBandsHorizontal​(java.awt.Graphics2D g2,
                                               java.awt.geom.Rectangle2D plotArea,
                                               java.awt.geom.Rectangle2D dataArea,
                                               boolean firstGridBandIsDark,
                                               java.util.List ticks)
        Draws the grid bands for the axis when it is at the top or bottom of the plot.
        Parameters:
        g2 - the graphics target (null not permitted).
        plotArea - the area within which the plot is drawn (not used here).
        dataArea - the area for the data (to which the axes are aligned, null not permitted).
        firstGridBandIsDark - True: the first grid band takes the color of gridBandPaint. False: the second grid band takes the color of gridBandPaint.
        ticks - a list of ticks (null not permitted).
      • drawGridBandsVertical

        protected void drawGridBandsVertical​(java.awt.Graphics2D g2,
                                             java.awt.geom.Rectangle2D plotArea,
                                             java.awt.geom.Rectangle2D dataArea,
                                             boolean firstGridBandIsDark,
                                             java.util.List ticks)
        Draws the grid bands for an axis that is aligned to the left or right of the data area (that is, a vertical axis).
        Parameters:
        g2 - the graphics target (null not permitted).
        plotArea - the area within which the plot is drawn (not used here).
        dataArea - the area for the data (to which the axes are aligned, null not permitted).
        firstGridBandIsDark - True: the first grid band takes the color of gridBandPaint. False: the second grid band takes the color of gridBandPaint.
        ticks - a list of ticks (null not permitted).
      • autoAdjustRange

        protected void autoAdjustRange()
        Rescales the axis to ensure that all data is visible.
        Overrides:
        autoAdjustRange in class NumberAxis
      • refreshTicks

        public java.util.List refreshTicks​(java.awt.Graphics2D g2,
                                           AxisState state,
                                           java.awt.geom.Rectangle2D dataArea,
                                           RectangleEdge edge)
        Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
        Overrides:
        refreshTicks in class NumberAxis
        Parameters:
        g2 - the graphics device.
        state - the axis state.
        dataArea - the area in which the data should be drawn.
        edge - the location of the axis.
        Returns:
        A list of ticks.
      • refreshTicksHorizontal

        protected java.util.List refreshTicksHorizontal​(java.awt.Graphics2D g2,
                                                        java.awt.geom.Rectangle2D dataArea,
                                                        RectangleEdge edge)
        Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
        Overrides:
        refreshTicksHorizontal in class NumberAxis
        Parameters:
        g2 - the graphics device.
        dataArea - the area in which the data should be drawn.
        edge - the location of the axis.
        Returns:
        The ticks.
      • refreshTicksVertical

        protected java.util.List refreshTicksVertical​(java.awt.Graphics2D g2,
                                                      java.awt.geom.Rectangle2D dataArea,
                                                      RectangleEdge edge)
        Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
        Overrides:
        refreshTicksVertical in class NumberAxis
        Parameters:
        g2 - the graphics device.
        dataArea - the area in which the plot should be drawn.
        edge - the location of the axis.
        Returns:
        The ticks.
      • valueToString

        public java.lang.String valueToString​(double value)
        Converts a value to a string, using the list of symbols.
        Parameters:
        value - value to convert.
        Returns:
        The symbol.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this axis for equality with an arbitrary object.
        Overrides:
        equals in class NumberAxis
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • 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.