Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## echopointng.util
Class ColorKit

    java.lang.Object
      echopointng.util.ColorKit

    public class ColorKit

extends java.lang.Object

A utility to class to help with Color manipulation

Field Summary
`static double` | `COLOR_FACTOR` The default scale factor applied to the brighter and darker functions
`static java.lang.String[]` | `ColorConstantStrings` Array for acceptable Color Constant strings
`static Color[]` | `ColorConstantValues` An array for Color values matching ColorConstantStrings
`static int` | `SWAP_OP_BGR` swapRGB Operation - R = B, G = G, B = R
`static int` | `SWAP_OP_BRG` swapRGB Operation - R = B, G = R, B = G
`static int` | `SWAP_OP_GBR` swapRGB Operation - R = G, G = B, B = R
`static int` | `SWAP_OP_GRB` swapRGB Operation - R = G, G = R, B = B
`static int` | `SWAP_OP_RBG` swapRGB Operation - R = R, G = B, B = G

Method Summary
`static Color` | `brighter(Color color)` Creates a brighter version of this color.
`static Color` | `brighter(Color color, double factor)` Creates a brighter version of this color, according to the provided factor.
`static Color` | `clr(int rgb)` Shortcut synonym for makeColor(rgb);
`static Color` | `clr(int r, int g, int b)` Shortcut synonym for makeColor(r,g,b);
`static Color` | `clr(java.lang.String colorString)` Shortcut synonym for makeColor(colorString);
`static Color` | `darker(Color color)` Creates a darker version of this color.
`static Color` | `darker(Color color, double factor)` Creates a darker version of this color, according to the provided factor.
`static Color` | `findBackground(Component comp)` Searchs the heirarchy tree of the component and finds the first non null background Color object.
`static Color` | `findForeground(Component comp)` Searchs the heirarchy tree of the component and finds the first non null foreground Color object.
`static Color` | `invertColor(Color color)` Returns the inversion of a color.
`static boolean` | `isColor(java.lang.String colorString)` Returns true if the propertyValue is a valid representation of a Color value.
`static java.awt.Color` | `makeAwtColor(Color echoColor, java.awt.Color defaultAwtColor)` Creates an java.awt.Color object from a nextapp.echo.Color object, or uses the default AWT if the `echoColor` object is null
`static Color` | `makeColor(int rgb)` Returns a Color object from the red, green and blue integer values.
`static Color` | `makeColor(int r, int g, int b)` Returns a Color object from the red, green and blue integer values.
`static Color` | `makeColor(java.lang.String colorString)` Returns a Color object from the string representation The color string must be in the format : - #rrggbb where rr, gg, bb are hexidecimal integer values - rgb( r, g, b) where r,g,b are integer values - color( r, g, b) where r,g,b are integer values - null will return a null color otherwise an IllegalArgumentException is thrown.
`static java.lang.String` | `makeColorString(Color color)` Returns the Color in the form : color(r,g,b);
`static java.lang.String` | `makeCSSColor(Color color)` Returns the Hex W3C CSS color string for a given color ie #rrggbb
`static java.lang.String` | `makeHexColor(Color color)` Returns the Hex string for a given color for example 'rrggbb' Note it does NOT have the # character at the front
`static Color` | `swapRGB(Color swapColor, int swapOperation)` This will swap the red/green/blue elements of a color according to the swapOperation, which may be one of : SWAP_OP_RBG SWAP_OP_BGR SWAP_OP_BRG SWAP_OP_GRB SWAP_OP_GBR
`static Color` | `tint(Color clr, double red, double green, double blue)` Tints a given color by a factor given in red, blue and green.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ColorConstantStrings

    public static java.lang.String[] ColorConstantStrings

  Array for acceptable Color Constant strings

### ColorConstantValues

    public static Color[] ColorConstantValues

  An array for Color values matching ColorConstantStrings

### COLOR_FACTOR

    public static final double COLOR_FACTOR

  The default scale factor applied to the brighter and darker functions

  See Also:
    Constant Field Values

### SWAP_OP_BGR

    public static final int SWAP_OP_BGR

  swapRGB Operation - R = B, G = G, B = R

  See Also:
    Constant Field Values

### SWAP_OP_BRG

    public static final int SWAP_OP_BRG

  swapRGB Operation - R = B, G = R, B = G

  See Also:
    Constant Field Values

### SWAP_OP_GBR

    public static final int SWAP_OP_GBR

  swapRGB Operation - R = G, G = B, B = R

  See Also:
    Constant Field Values

### SWAP_OP_GRB

    public static final int SWAP_OP_GRB

  swapRGB Operation - R = G, G = R, B = B

  See Also:
    Constant Field Values

### SWAP_OP_RBG

    public static final int SWAP_OP_RBG

  swapRGB Operation - R = R, G = B, B = G

  See Also:
    Constant Field Values

Method Detail

### brighter

    public static Color brighter(Color color)

  Creates a brighter version of this color.

  This method applies a 0.7 scale factor to each of the three RGB components of the color to create a brighter version of the same color. Although `brighter` and `darker` are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.

  Parameters:
    `color` - - the color to make brighter
  Returns:
    a new `Color` object, a brighter version of the color.

### brighter

    public static Color brighter(Color color,
                                 double factor)

  Creates a brighter version of this color, according to the provided factor.

  This method applies an the scale factor to each of the three RGB components of the color to create a brighter version of the same color. Although `brighter` and `darker` are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.

  Parameters:
    `color` - - the color to make brighter
    `factor` - - the factor by which to make it brighter.
  Returns:
    a new `Color` object, a brighter version of the color.

### darker

    public static Color darker(Color color)

  Creates a darker version of this color.

  This method applies an arbitrary 0.7 scale factor to each of the three RGB components of the color to create a darker version of the same color. Although `brighter` and `darker` are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.

  Parameters:
    `color` - - the color to make darker
  Returns:
    a new `Color` object,a darker version of this color.

### darker

    public static Color darker(Color color,
                               double factor)

  Creates a darker version of this color, according to the provided factor.

  This method applies an the scale factor to each of the three RGB components of the color to create a darker version of the same color. Although `brighter` and `darker` are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.

  Parameters:
    `color` - - the color to make darker
    `factor` - - the factor by whcih to make it darker.
  Returns:
    a new `Color` object,a darker version of the color.

### findBackground

    public static Color findBackground(Component comp)

  Searchs the heirarchy tree of the component and finds the first non null background Color object. It will return `Color.WHITE` if no ancestor components have a background set, but in practice this is unlikely to be the case.

  Parameters:
    `comp` - - the component to start searching at
  Returns:
    - the background color of the component or its parents

### findForeground

    public static Color findForeground(Component comp)

  Searchs the heirarchy tree of the component and finds the first non null foreground Color object. It will return `Color.BLACK.` if no ancestor components have a background set, but in practice this is unlikely to be the case.

  Parameters:
    `comp` - - the component to start searching at
  Returns:
    - the foreground color of the component or its parents

### invertColor

    public static Color invertColor(Color color)

  Returns the inversion of a color.

  Parameters:
    `color` - - the color to invert
  Returns:
    the inverted color

### makeAwtColor

    public static java.awt.Color makeAwtColor(Color echoColor,
                                              java.awt.Color defaultAwtColor)

  Creates an java.awt.Color object from a nextapp.echo.Color object, or uses the default AWT if the `echoColor` object is null

  Parameters:
    `echoColor` - - the nextapp.echo2.app.Color object to convert
    `defaultAwtColor` - - the AWT color to use if the echoColor is null
  Returns:
    a new AWT color object

### makeCSSColor

    public static java.lang.String makeCSSColor(Color color)

  Returns the Hex W3C CSS color string for a given color ie #rrggbb

  Parameters:
    `color` - - the color to convert to a W3C hex CSS string value
  Returns:
    the W3C hex CSS string value

### makeColorString

    public static java.lang.String makeColorString(Color color)

  Returns the Color in the form : color(r,g,b);

  Parameters:
    `color` - - the color to convert to a color string representation
  Returns:
    the color string representation

### makeHexColor

    public static java.lang.String makeHexColor(Color color)

  Returns the Hex string for a given color for example 'rrggbb' Note it does NOT have the # character at the front

  Parameters:
    `color` - the color in question
  Returns:
    the string in the form rrggbb

### makeColor

    public static Color makeColor(java.lang.String colorString)

  Returns a Color object from the string representation

  The color string must be in the format :
  - #rrggbb where rr, gg, bb are hexidecimal integer values
  - rgb( r, g, b) where r,g,b are integer values
  - color( r, g, b) where r,g,b are integer values
  - null will return a null color

  otherwise an IllegalArgumentException is thrown.

  The results of these operations are cached in a static cache, so that Color objects can be re-used. This is okay since Color objects are immutable.

  Parameters:
    `colorString` - - the color string representation
  Returns:
    a new Color object
  Throws:
    `java.lang.IllegalArgumentException` - - if the string cannot be converted to a color

### isColor

    public static boolean isColor(java.lang.String colorString)

  Returns true if the propertyValue is a valid representation of a Color value.

  The allowable forms are :

  - colorconstant where colorconstant in (red,blue,green...) - #rrggbb where rr, gg, bb are hexidecimal integer values
  - rgb( r, g, b) where r,g,b are integer values
  - color( r, g, b) where r,g,b are integer values

### clr

    public static Color clr(java.lang.String colorString)

  Shortcut synonym for makeColor(colorString);

  See Also:
    `makeColor(String)`

### clr

    public static Color clr(int r,
                            int g,
                            int b)

  Shortcut synonym for makeColor(r,g,b);

  See Also:
    `makeColor(int, int, int)`

### clr

    public static Color clr(int rgb)

  Shortcut synonym for makeColor(rgb);

  See Also:
    `makeColor(int)`

### makeColor

    public static Color makeColor(int r,
                                  int g,
                                  int b)

  Returns a Color object from the red, green and blue integer values.

  The results of these operations are cached in a static cache, so that Color objects can be re-used. This is okay since Color objects are immutable.

  Parameters:
    `r` - - the red color component
    `g` - - the green color component
    `b` - - the blue color component
  Returns:
    a new Color object

### makeColor

    public static Color makeColor(int rgb)

  Returns a Color object from the red, green and blue integer values.

  The results of these operations are cached in a static cache, so that Color objects can be re-used. This is okay since Color objects are immutable.

  Parameters:
    `rgb` - - the red/blue/green integer color value
  Returns:
    a new Color object

### tint

    public static Color tint(Color clr,
                             double red,
                             double green,
                             double blue)

  Tints a given color by a factor given in red, blue and green.

  The red, green and blue arguments should be around 1.0

### swapRGB

    public static Color swapRGB(Color swapColor,
                                int swapOperation)

  This will swap the red/green/blue elements of a color according to the swapOperation, which may be one of :
  - SWAP_OP_RBG
  - SWAP_OP_BGR
  - SWAP_OP_BRG
  - SWAP_OP_GRB
  - SWAP_OP_GBR

  Parameters:
    `swapColor` - - the color to swap the RGB elements
    `swapOperation` - - the operation to perform
  Returns:
    - a new swapped Color or null if the swapColor was null.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD