Class ChartColor

java.lang.Object
java.awt.Color
org.jfree.chart.ChartColor
All Implemented Interfaces:
Paint, Transparency, Serializable

public class ChartColor extends Color
Class to extend the number of Colors available to the charts. This extends the java.awt.Color object and extends the number of final Colors publicly accessible.
See Also:
  • Field Details

  • Constructor Details

    • ChartColor

      public ChartColor(int r, int g, int b)
      Creates a Color with an opaque sRGB with red, green and blue values in range 0-255.
      Parameters:
      r - the red component in range 0x00-0xFF.
      g - the green component in range 0x00-0xFF.
      b - the blue component in range 0x00-0xFF.
  • Method Details

    • createDefaultPaintArray

      public static Paint[] createDefaultPaintArray()
      Convenience method to return an array of Paint objects that represent the pre-defined colors in the Color and ChartColor objects.
      Returns:
      An array of objects with the Paint interface.
      See Also:
    • createDefaultColorArray

      public static Color[] createDefaultColorArray()
      Convenience method to return an array of Color objects that represent the pre-defined colors in the Color and ChartColor objects.
      Returns:
      An array of objects with the Color interface.
    • createDarkerColorArray

      public static Color[] createDarkerColorArray(Color[] colors)
      Creates an array of darker colors to use for e.g. borders.
      Parameters:
      colors - original colors
      Returns:
      a new array containing darker instances of the original colors.
    • getContrastColor

      public static Color getContrastColor(Color color)
      Returns either black or white, depending on the provided color to achieve the best contrast for e.g. text labels.
      The color is converted from RGB to YIQ and the luminance value (Y; ≈[0 .. 255]) is used to determine if color is closer to either black or white.
      Parameters:
      color - the color for which the contrasted color is computed
      Returns:
      either black or white, depending on color