Class Style

  • All Implemented Interfaces:
    Cloneable

    public final class Style
    extends Object
    implements Cloneable
    This class represents a style used to draw a graphic object, such as a bar, a line or the graph key. To control the font and layout of text, see the TextStyle class
    • Constructor Detail

      • Style

        public Style​(Paint color)
        Create a new Style
        Parameters:
        color - the color to use
      • Style

        public Style​(Style style)
        Create a new Style that's a clone of the specified style
    • Method Detail

      • setOverflow

        public void setOverflow​(boolean overflow)
        Set whether any lines or markers in this style should overflow the graph - if this is set, the item it is set on will not contribute to the calculated dimensions of the graph. Usually it should be left to the default value of false.
        Since:
        2.4.7
      • ensureSolidColor

        public void ensureSolidColor()
        If this style has a color object that's a GradientPaint or LinearGradientPaint instance then replace it with a solid color instance instead.
      • setColor

        public void setColor​(Paint color)
        Set the color of this style
        Parameters:
        color - the color to use
      • setBorderColor

        public void setBorderColor​(Color color)
        Set the border color for this style
        Parameters:
        color - the color to use to draw borders in this style, or null not to draw any borders
      • setLineThickness

        public void setLineThickness​(double thick)
        Set the line thickness for this style. 1 is the default, 0.5 is half as thick, and so on.
        Parameters:
        thick - the line thickness of this style. Must be > 0
      • setLineDash

        public void setLineDash​(double[] dash)
        Set the line dashing for this style. The "dash" parameter is an array of 2*n values, where the first in each pair is the length of the dash, the second is the length of the space. So, for example, setLineDash(new double[] { 5, 5 }) would create a regular dash pattern of 5 on, 5 off, and setLineDash(new double[] { 6, 2, 2, 2 }) would create a dash-dot type pattern. To turn dashing off completely, pass in a zero length array or null.
        Parameters:
        dash - an array of doubles which must be even in length and have every value > 0
        Throws:
        IllegalArgumentException - if the array is odd in length or if it contains any values <= 0
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • createPattern

        public static Paint createPattern​(String name,
                                          Color foreground,
                                          Color background)
        Create a TexturePaint object from one of several predefined patterns. These may be used for tiling paints - useful in environments where color is limited to black and white. The available patterns are:

        bricks circles crosshatch crosshatch30 crosshatch45 fishscales gray0 gray10 gray15 gray20 gray25 gray30 gray35 gray40 gray45 gray5 gray50 gray55 gray60 gray65 gray70 gray75 gray80 gray85 gray90 gray95 hexagons horizontal horizontalsaw hs_bdiagonal hs_cross hs_diagcross hs_fdiagonal hs_horizontal hs_vertical left30 left45 leftshingle octagons right30 right45 rightshingle scatter1 scatter2 smallfishscales vertical verticalbricks verticalleftshingle verticalrightshingle verticalsaw weave

        Alternatively the full URL of a PBM format image may be specified.
        Parameters:
        name - the name or URL of the pattern to use.
        foreground - the foreground color. May be null, in which case it defaults to black.
        background - the background color. May be null, in which case it defaults to white.
        Since:
        2.1.1
      • createLinearGradientPaint

        public static Paint createLinearGradientPaint​(double[] values,
                                                      Color[] colors)
        Return a LinearGradientPaint that can be used to paint objects in the PDF. The advantage of calling this method instead of the LinearGradientPaint constructor is that the values can be specified in units that relate to the values on the graph. For instance, to create a BarSeries that changes color from yellow to red above the value 5, call
           Paint paint = Style.createLinearGradientPaint(new double[] { 5, 5.001 },
                                           new Color[] { Color.yellow, Color.red });
           style.setColor(paint);
           series.setStyle(style);
         
        Note that the java.awt.LinearGradientPaint class is a Java 1.6 class
        Since:
        2.4.2