gcspy.vis.utils
Class AdjustedColor

java.lang.Object
  extended by gcspy.vis.utils.AdjustedColor

public class AdjustedColor
extends java.lang.Object

Facilities to adjust colors for tiles

Author:
Tony Printezis

Constructor Summary
AdjustedColor(java.awt.Color to)
          A new colour
AdjustedColor(java.awt.Color from, java.awt.Color middle, java.awt.Color to, int max)
          A new colour
AdjustedColor(java.awt.Color from, java.awt.Color to, int max)
          A new colour
AdjustedColor(java.awt.Color to, int max)
          A new colour
 
Method Summary
static java.awt.Color generate(java.awt.Color from, java.awt.Color middle, java.awt.Color to, int val, int max)
          Interpolate between colours.
static java.awt.Color generate(java.awt.Color from, java.awt.Color to, int val, int max)
          INterpolate between colours
static java.awt.Color generate(java.awt.Color c, int val, int max)
          Generate a new color as a fraction of an existing one
 java.awt.Color generate(int val)
          Generate a new colour
 java.awt.Color generate(int val, int max)
          Generate a new colour
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdjustedColor

public AdjustedColor(java.awt.Color to)
A new colour

Parameters:
to - The base colour to use. This is used as a maximum for future generated colours.

AdjustedColor

public AdjustedColor(java.awt.Color to,
                     int max)
A new colour

Parameters:
to - The base colour to use. This is used as a maximum for future generated colours.
max - This value is used as a denominator in future interpolations

AdjustedColor

public AdjustedColor(java.awt.Color from,
                     java.awt.Color to,
                     int max)
A new colour

Parameters:
from - The lower end of the range of future colours interpolated from this AdjustedColour
to - The upper end of the range of future colours interpolated from this AdjustedColour
max - This value is used as a denominator in future interpolations

AdjustedColor

public AdjustedColor(java.awt.Color from,
                     java.awt.Color middle,
                     java.awt.Color to,
                     int max)
A new colour

Parameters:
from - The lower end of the range of future colours interpolated from this AdjustedColour
middle - A middle value in the range of future colours interpolated from this AdjustedColour
to - The upper end of the range of future colours interpolated from this AdjustedColour
max - This value is used as a denominator in future interpolations
Method Detail

generate

public static java.awt.Color generate(java.awt.Color c,
                                      int val,
                                      int max)
Generate a new color as a fraction of an existing one

Parameters:
c - The base colour
val - The numerator
max - The denominator
Returns:
return the colour scaled by val/code

generate

public static java.awt.Color generate(java.awt.Color from,
                                      java.awt.Color to,
                                      int val,
                                      int max)
INterpolate between colours

Parameters:
from - A colour
to - A second
val - The numerator
max - The denominator
Returns:
return a colour interpolated between from and to by val/code

generate

public static java.awt.Color generate(java.awt.Color from,
                                      java.awt.Color middle,
                                      java.awt.Color to,
                                      int val,
                                      int max)
Interpolate between colours. If val < max/2 generate a colour between from and middle else generate a colour between middle and to.

Parameters:
from - A starting colour
middle - A middle colour
to - An ending colour
val - The numerator
max - The denominator
Returns:
The interpolated colour

generate

public java.awt.Color generate(int val,
                               int max)
Generate a new colour

Parameters:
val - The numerator
max - The denominator
Returns:
the interpolated colour

generate

public java.awt.Color generate(int val)
Generate a new colour

Parameters:
val - The numerator
Returns:
an interpolated colour