fang
Class Palette

java.lang.Object
  extended by fang.Palette

public class Palette
extends Object

This class represents a color as a red, green, blue triple whose range for each component is 0 .. 255. Colors can also be specified using the names given on this web page (note, case and spacing in the name do not matter):

Author:
Robert C. Duvall

Constructor Summary
Palette()
           
 
Method Summary
static void addColor(String name, Color color)
           
static void addColor(String name, String rgb)
           
static Color getColor(int red, int green, int blue)
          Create a solid color with the given red, green, and blue values.
static Color getColor(int red, int green, int blue, int transparency)
          Create a semi-transparent color with the given red, green, and blue values.
static Color getColor(String name)
          Create a solid color with from the name given on this web page.
static Color getColor(String name, int transparency)
          Create a semi-transparent color with from the name given on this web page.
static Color getColorFromRGB(String rgb)
           
static Color getColorFromRGB(String rgb, int transparency)
           
static Map<String,Color> getColorMap()
           
static String getColorName(Color color)
           
static String getColorName(int r, int g, int b)
           
static String getColorName(String rgb)
           
static Color getRandomColor(Random random)
          Generate a random color.
static String getRGB(Color color)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Palette

public Palette()
Method Detail

getColor

public static Color getColor(int red,
                             int green,
                             int blue)
Create a solid color with the given red, green, and blue values.


getColor

public static Color getColor(int red,
                             int green,
                             int blue,
                             int transparency)
Create a semi-transparent color with the given red, green, and blue values.


getColor

public static Color getColor(String name)
Create a solid color with from the name given on this web page.


getColor

public static Color getColor(String name,
                             int transparency)
Create a semi-transparent color with from the name given on this web page.


getColorName

public static String getColorName(int r,
                                  int g,
                                  int b)

getColorName

public static String getColorName(String rgb)

getColorName

public static String getColorName(Color color)

getColorFromRGB

public static Color getColorFromRGB(String rgb)

getColorFromRGB

public static Color getColorFromRGB(String rgb,
                                    int transparency)

getRandomColor

public static Color getRandomColor(Random random)
Generate a random color. Uses the parameter random number generator if one is provided. If none is provided, returns null as the random color.

Parameters:
random - - a Random object used to generate random numbers; this class is ignorant of other FANG classes so it does not poke around in the current game to find the Random that is there. Callers provide the Random (Game.getRandomColor() does this under the hood).
Returns:
a randomly selected color if the parameter is non-null; null otherwise

getRGB

public static String getRGB(Color color)

getColorMap

public static Map<String,Color> getColorMap()

addColor

public static void addColor(String name,
                            Color color)

addColor

public static void addColor(String name,
                            String rgb)