edu.kzoo.util
Class RandColorGenerator

java.lang.Object
  |
  +--edu.kzoo.util.RandColorGenerator

public class RandColorGenerator
extends java.lang.Object

Kalamazoo College Utility Classes:
The edu.kzoo.util.RandColorGenerator class provides a static method that can be used to generate a random color.

Example of how to use RandColorGenerator:


       RandColorGenerator randColorGen = RandColorGenerator.getInstance();
       Color opaqueColor = randColorGen.nextColor();
       Color colorWithSpecifiedTransparency = randColorGen.nextColor(alpha);
       Color colorWithRandomTransparency =
                      randColorGen.nextColorWithVariableTransparency();
    

Version:
Mar 9, 2004
Author:
Alyce Brady

Method Summary
static RandColorGenerator getInstance()
          Returns a random color generator.
 java.awt.Color nextColor()
          Returns the next pseudorandom opaque Color value from this random color generator's sequence.
 java.awt.Color nextColor(int alpha)
          Returns the next pseudorandom Color value with the specified transparency level from this random color generator's sequence.
 java.awt.Color nextColorWithVariableTransparency()
          Returns the next pseudorandom Color value from this random color generator's sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static RandColorGenerator getInstance()
Returns a random color generator. Always returns the same RandColorGenerator object to provide a better sequence of random colors.


nextColor

public java.awt.Color nextColor()
Returns the next pseudorandom opaque Color value from this random color generator's sequence.

Returns:
the next pseudorandom opaque color

nextColor

public java.awt.Color nextColor(int alpha)
Returns the next pseudorandom Color value with the specified transparency level from this random color generator's sequence.

Parameters:
alpha - the transparency level to use for the next color, in the range of 0 to 255 where 255 is completely opaque
Returns:
the next pseudorandom color with the specified transparency level

nextColorWithVariableTransparency

public java.awt.Color nextColorWithVariableTransparency()
Returns the next pseudorandom Color value from this random color generator's sequence. Colors returned by this method are created with a random alpha (transparency) component, as well as random red, green, and blue components.

Returns:
the next pseudorandom color