org.deegree_impl.model.resources
Class Colors

java.lang.Object
  extended byorg.deegree_impl.model.resources.Colors

public final class Colors
extends java.lang.Object

Utilities methods for handling of colors informations.

Version:
1.0
Author:
Martin Desruisseaux

Field Summary
private static double EPS
          Small number for rounding errors.
 
Constructor Summary
private Colors()
          Do not allow instantiation of this class.
 
Method Summary
static void expand(java.awt.Color[] colors, int[] ARGB, int lower, int upper)
          Copy colors into array ARGB from index lower inclusive to index upper exclusive.
static int getBitCount(int mapSize)
          Returns a suggered bit count for an IndexColorModel of mapSize colors.
static java.awt.image.IndexColorModel getIndexColorModel(int[] ARGB)
          Returns an index color model for specified ARGB codes.
private static int getTransferType(int mapSize)
          Returns a suggered type for an IndexColorModel of mapSize colors.
private static int round(double value)
          Round a float value and clamp the result between 0 and 255 inclusive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPS

private static final double EPS
Small number for rounding errors.

See Also:
Constant Field Values
Constructor Detail

Colors

private Colors()
Do not allow instantiation of this class.

Method Detail

expand

public static void expand(java.awt.Color[] colors,
                          int[] ARGB,
                          int lower,
                          int upper)
Copy colors into array ARGB from index lower inclusive to index upper exclusive. If upper-lower is not equals to the length of colors array, then colors will be interpolated.

Parameters:
colors - Colors to copy into the ARGB array.
ARGB - Array of integer to write ARGB values to.
lower - Index (inclusive) of the first element of ARGB to change.
upper - Index (exclusive) of the last element of ARGB to change.

round

private static int round(double value)
Round a float value and clamp the result between 0 and 255 inclusive.


getIndexColorModel

public static java.awt.image.IndexColorModel getIndexColorModel(int[] ARGB)
Returns an index color model for specified ARGB codes. If the specified array has not transparent color (i.e. all alpha values are 255), then the returned color model will be opaque. Otherwise, if the specified array has one and only one color with alpha value of 0, the returned color model will have only this transparent color. Otherwise, the returned color model will be translucide.

Parameters:
ARGB - An array of ARGB values.
Returns:
An index color model for the specified array.

getBitCount

public static int getBitCount(int mapSize)
Returns a suggered bit count for an IndexColorModel of mapSize colors. This method returns 1, 2, 4, 8 or 16 according the value of mapSize. It is guaranteed that the following relation is hold:
(1 << getBitCount(mapSize)) >= mapSize


getTransferType

private static int getTransferType(int mapSize)
Returns a suggered type for an IndexColorModel of mapSize colors. This method returns DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT.