SPT Core API

com.sptci.echo2.style
Class Color

java.lang.Object
  extended by nextapp.echo2.app.Color
      extended by com.sptci.echo2.style.Color
All Implemented Interfaces:
Serializable

public class Color
extends Color

A custom Color class to use in styles. This class is used to cache colours across sessions to reduce memory consumption.

The following shows the recommended way to use this class:

   import com.sptci.echo2.style.Color;

     ...
     Color one = Color.getInstance( 0xffccbb );
     Color two = Color.getInstance( 254, 176, 10 );
 

© Copyright 2007 Sans Pareil Technologies, Inc.

Version:
$Id: Color.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2007-09-15
See Also:
Serialized Form

Field Summary
protected static Map<Integer,Color> cache
          The cache of reusable colour instances.
 
Fields inherited from class nextapp.echo2.app.Color
BLACK, BLUE, CYAN, DARKGRAY, GREEN, LIGHTGRAY, MAGENTA, ORANGE, PINK, RED, WHITE, YELLOW
 
Constructor Summary
Color(int rgb)
          Deprecated. Use getInstance( int ) instead.
Color(int red, int green, int blue)
          Deprecated. Use getInstance( int, int, int ) instead.
 
Method Summary
static Color getInstance(int rgb)
          Return a cached colour instance representing the specified RGB value.
static Color getInstance(int red, int green, int blue)
          Return a cached colour instance representing the specified RGB value.
 
Methods inherited from class nextapp.echo2.app.Color
equals, getBlue, getGreen, getRed, getRgb, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

cache

protected static final Map<Integer,Color> cache
The cache of reusable colour instances. The key to the map is the Color.rgb value.

Constructor Detail

Color

@Deprecated
public Color(int rgb)
Deprecated. Use getInstance( int ) instead.

Create a new instance using the specified RGB value.

Parameters:
rgb - An integer representation for a color

Color

@Deprecated
public Color(int red,
                        int green,
                        int blue)
Deprecated. Use getInstance( int, int, int ) instead.

Create a new instance using the specified red, green, and blue values.

Parameters:
red - The red component of the colour
green - The green component of the colour
blue - The blue component of the colour
Method Detail

getInstance

public static Color getInstance(int rgb)
Return a cached colour instance representing the specified RGB value.

Parameters:
rgb - An integer representation of a colour.
Returns:
The cached colour instance.

getInstance

public static Color getInstance(int red,
                                int green,
                                int blue)
Return a cached colour instance representing the specified RGB value.

Parameters:
red - The red component of the colour
green - The green component of the colour
blue - The blue component of the colour
Returns:
The cached colour instance.

SPT Core API