rainbowvis
Class Rainbow

java.lang.Object
  extended by rainbowvis.Rainbow

public class Rainbow
extends java.lang.Object

The Rainbow class by default maps the range 0 to 100 (inclusive) to the colours of the rainbow (i.e., a gradient transitioning from red to yellow to lime to blue)

Author:
Sophiah (Zing-Ming)

Constructor Summary
Rainbow()
          Constructor.
 
Method Summary
 java.lang.String colorAt(double number)
          Same as colourAt(double number)
 java.lang.String colourAt(double number)
          Returns the hex colour corresponding to the number.
 void setNumberRange(double minNumber, double maxNumber)
          Sets the number range of the Rainbow object.
 void setSpectrum(java.lang.String... spectrum)
          Sets the spectrum of the Rainbow object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rainbow

public Rainbow()
Constructor. By default, the number range is from 0 to 100, and the spectrum is a rainbow.

Method Detail

colourAt

public java.lang.String colourAt(double number)
Returns the hex colour corresponding to the number. If number is out of range, it returns the appropriate hex colour corresponding to either the minNumber or maxNumber.

Parameters:
number - The number for which you want to find the corresponding colour
Returns:
The corresponding colour represented as a HTML RGB hexidecimal String

setSpectrum

public void setSpectrum(java.lang.String... spectrum)
                 throws HomogeneousRainbowException,
                        InvalidColourException
Sets the spectrum of the Rainbow object. By default, the spectrum is a rainbow. You must have a minimum of two colours, but you can specify more than two colours. Colours can be in the form "red", "ff0000", or "#ff0000". For example, rainbow.setSpectrum("red", "yellow", "white"); makes the "Rainbow" a colour gradient from red to yellow to white.

Parameters:
spectrum - Two or more Strings representing HTML colours, or pass in a whole String array of length 2 or greater
Throws:
HomogeneousRainbowException - if there is less than two arguments
InvalidColourException - if one of the arguments is an invalid colour

setNumberRange

public void setNumberRange(double minNumber,
                           double maxNumber)
                    throws NumberRangeException
Sets the number range of the Rainbow object. By default, it is 0 to 100.

Parameters:
minNumber - The minimum number of the number range
maxNumber - The maximum number of the number range
Throws:
NumberRangeException - if minNumber is greater than maxNumber

colorAt

public java.lang.String colorAt(double number)
Same as colourAt(double number)