OMColor (OpenMap API)
Date: 2016-12-09

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

## com.bbn.openmap.omGraphics
Class OMColor

    java.lang.Object
      java.awt.Color
          com.bbn.openmap.omGraphics.OMColor

All Implemented Interfaces:
  java.awt.Paint, java.awt.Transparency, java.io.Serializable

    public class OMColor

extends java.awt.Color

The OMColor exists to provide a way to make a color that can have some degree of transparency. The class lets you set the alpha value of the color which lets the color be invisible (0) to opaque (255). A while ago, the java.awt.Graphics class did not support transparency for drawing objects (OMLines, OMRects, OMCircles, etc.) but the transparent colors work for OMBitmap and OMRaster pixel values.

The OMColor object captures all calls that reference the package-internal `java.awt.Color.value` slot, and re-route them through the local argb slot.

NOTE concerning the OpenMap 4.0 release. As of 4.0, OpenMap now has a minimum jdk 1.2 requirement, which means that OMColor seems to duplicate java.awt.Color. We're going to keep this class around, however, in case someone needs a mutable Color.

See Also:
  `ColorFactory`, Serialized Form

Field Summary
`static java.awt.Color` | `ALMOST_CLEAR` We need ALMOST_CLEAR so that the buffered image has a slight background to it if any of the layers are semi-transparent.
`protected int` | `argb` The 32bit ARGB value used.
`static java.awt.Color` | `clear` Default transparent color.

Fields inherited from class java.awt.Color
`black, BLACK, blue, BLUE, cyan, CYAN, DARK_GRAY, darkGray, gray, GRAY, green, GREEN, LIGHT_GRAY, lightGray, magenta, MAGENTA, orange, ORANGE, pink, PINK, red, RED, white, WHITE, yellow, YELLOW`

Fields inherited from interface java.awt.Transparency
`BITMASK, OPAQUE, TRANSLUCENT`

Constructor Summary
`OMColor(float a, float r, float g, float b)` Deprecated. This function does not correctly override the JDK // * 1.2 java.awt.Color constructor with the same type/number of // * arguments. It should be OMColor(float r, float g, float b, float a).
`OMColor(int argb)` Create a color with the specified ARGB (Alpha, Red, Green, and Blue) values.
`OMColor(int a, int r, int g, int b)` Deprecated. This function does not correctly override the JDK // * 1.2 java.awt.Color constructor with the same type/number of // * arguments. It should be OMColor(int r, int g, int b, int a).

Method Summary
`boolean` | `equals(java.lang.Object obj)` Determines whether another object is equal to this color.
`int` | `getAlpha()` Return the transparency value of the color (the value of the 24-31 bits).
`int` | `getBlue()` Return the blue value of the color (the value of the 0-7 bits).
`int` | `getGreen()` Return the green value of the color (the value of the 8-15 bits).
`int` | `getRed()` Return the red value of the color (the value of the 16-23 bits).
`int` | `getRGB()` Get the ARGB (alpha, red, green and blue) value representing the color in the default RGB ColorModel.
`int` | `hashCode()` Computes the hash code for this color.
`static boolean` | `isClear(java.awt.Color value)` Checks if the color is transparent.
`void` | `setAlpha(int value)` Set the transparency value of the OMColor.
`void` | `setBlue(int value)` Set the blue value of the OMColor.
`void` | `setGreen(int value)` Set the green value of the OMColor.
`void` | `setRed(int value)` Set the red value of the OMColor.
`void` | `setRGB(int value)` Change the ARGB value of the color the input value.
`static int` | `setTransparentValue(int colorValue, float transValue)` Return a color value that has the transparency alpha value set to a percentage value between 0.0 and 1.0.
`static int` | `setTransparentValue(int colorValue, int transValue)` Return a color integer that has the transparency alpha value set to a value between 0-255.
`java.lang.String` | `toString()` Returns a string representation of this color.

Methods inherited from class java.awt.Color
`brighter, createContext, darker, decode, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getHSBColor, getRGBColorComponents, getRGBComponents, getTransparency, HSBtoRGB, RGBtoHSB`

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

Field Detail

### clear

    public static final transient java.awt.Color clear

  Default transparent color. Clear is a standard color that has all the bit values set to zero. This will give you a transparent pixel for images, and black for situations where transparency is not supported.

### ALMOST_CLEAR

    public static final transient java.awt.Color ALMOST_CLEAR

  We need ALMOST_CLEAR so that the buffered image has a slight background to it if any of the layers are semi-transparent. If there is no background, the semi-transparent layers get washed out. Adding a touch of something to the background of the buffer lets them render normally.

### argb

    protected int argb

  The 32bit ARGB value used.

Constructor Detail

### OMColor

    public OMColor(int a,
                   int r,
                   int g,
                   int b)

  Deprecated. This function does not correctly override the JDK // * 1.2 java.awt.Color constructor with the same type/number of // * arguments. It should be OMColor(int r, int g, int b, int a).

  Create a color with the specified alpha, red, green, and blue components. The four arguments must each be in the range 0-255. // *

### OMColor

    public OMColor(int argb)

  Create a color with the specified ARGB (Alpha, Red, Green, and Blue) values. The alpha component is in bits 24-31 of the argument, the red component is in bits 16-23 of the argument, the green component is in bits 8-15 of the argument, and the blue component is in bits 0-7.

  Parameters:
    `argb` - 32bit Hex ARGB value

### OMColor

    public OMColor(float a,
                   float r,
                   float g,
                   float b)

  Deprecated. This function does not correctly override the JDK // * 1.2 java.awt.Color constructor with the same type/number of // * arguments. It should be OMColor(float r, float g, float b, float a).

  Create a color with the specified red, green, and blue values, where each of the values is in the range 0.0-1.0. The value 0.0 indicates no contribution from the primary color component. The value 1.0 indicates the maximum intensity of the primary color component. // *

Method Detail

### getRGB

    public int getRGB()

  Get the ARGB (alpha, red, green and blue) value representing the color in the default RGB ColorModel. The alpha, red, green, and blue components of the color are each scaled to be a value between 0 (absence of the color) and 255 (complete saturation). Bits 24-31 of the returned integer are the alpha value, bits 16-23 are the red value, bit 8-15 are the green value, and bits 0-7 are the blue value.

  Overrides:
    `getRGB` in class `java.awt.Color`
  Returns:
    the integer value of the color.

### setRGB

    public void setRGB(int value)

  Change the ARGB value of the color the input value. See the constructor comments that accepts the int parameter.

  Parameters:
    `value` - the transparency value between 0-255.

### getRed

    public int getRed()

  Return the red value of the color (the value of the 16-23 bits).

  Overrides:
    `getRed` in class `java.awt.Color`
  Returns:
    the integer red value.

### setRed

    public void setRed(int value)

  Set the red value of the OMColor.

  Parameters:
    `value` - the red value between 0-255.

### getGreen

    public int getGreen()

  Return the green value of the color (the value of the 8-15 bits).

  Overrides:
    `getGreen` in class `java.awt.Color`
  Returns:
    the integer green value.

### setGreen

    public void setGreen(int value)

  Set the green value of the OMColor.

  Parameters:
    `value` - the green value between 0-255.

### getBlue

    public int getBlue()

  Return the blue value of the color (the value of the 0-7 bits).

  Overrides:
    `getBlue` in class `java.awt.Color`
  Returns:
    the integer blue value.

### setBlue

    public void setBlue(int value)

  Set the blue value of the OMColor.

  Parameters:
    `value` - the blue value between 0-255.

### getAlpha

    public int getAlpha()

  Return the transparency value of the color (the value of the 24-31 bits).

  Overrides:
    `getAlpha` in class `java.awt.Color`
  Returns:
    the integer transparency value.

### setAlpha

    public void setAlpha(int value)

  Set the transparency value of the OMColor.

  Parameters:
    `value` - the transparency value between 0-255.

### setTransparentValue

    public static int setTransparentValue(int colorValue,
                                          int transValue)

  Return a color integer that has the transparency alpha value set to a value between 0-255. It cleans out the old alpha setting, and inserts the new one.

  Parameters:
    `colorValue` - the ARGB value of a color to be changed.
    `transValue` - the integer (0-255) representing the opaqueness of the return value. 0 is transparent, 255 is opaque.
  Returns:
    the integer color value with the transparency value.

### setTransparentValue

    public static int setTransparentValue(int colorValue,
                                          float transValue)

  Return a color value that has the transparency alpha value set to a percentage value between 0.0 and 1.0.

  Parameters:
    `colorValue` - the RGB value of a color to be changed.
    `transValue` - the percentage of opaqueness (0-1) of the return value. 0 is transparent, 1 is opaque.
  Returns:
    the integer color value with the transparency value.

### isClear

    public static boolean isClear(java.awt.Color value)

  Checks if the color is transparent. The alpha bits (31-24) of the color determine this.

  Parameters:
    `value` - Color to be checked
  Returns:
    true if Color is null or transparent

### hashCode

    public int hashCode()

  Computes the hash code for this color.

  Overrides:
    `hashCode` in class `java.awt.Color`
  Returns:
    a hash code value for this object.

### equals

    public boolean equals(java.lang.Object obj)

  Determines whether another object is equal to this color.

  The result is `true` if and only if the argument is not `null` and is a `Color` object that has the same alpha, red, green, and blue values as this object.

  Overrides:
    `equals` in class `java.awt.Color`
  Parameters:
    `obj` - the Color to compare.
  Returns:
    true if the objects are the same, false otherwise.

### toString

    public java.lang.String toString()

  Returns a string representation of this color. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be `null`.

  Overrides:
    `toString` in class `java.awt.Color`
  Returns:
    a string representation of this color.

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

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details