Class Gradient

java.lang.Object
  extended by Gradient

public class Gradient
extends java.lang.Object

There are a number of defined gradient types (look at the static fields), but you can create any gradient you like by using either of the following functions:

You can then assign an arbitrary Color[] object to the HeatMap as follows:
myHeatMap.updateGradient(Gradient.createMultiGradient(new Color[] {Color.red, Color.white, Color.blue}, 256));


Copyright: Copyright (c) 2007, 2008

HeatMap is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

HeatMap is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with HeatMap; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


Field Summary
static java.awt.Color[] GRADIENT_BLACK_TO_WHITE
          Produces a gradient from black (low) to white (high)
static java.awt.Color[] GRADIENT_BLUE_TO_RED
          Produces a gradient from blue (low) to red (high)
static java.awt.Color[] GRADIENT_GREEN_YELLOW_ORANGE_RED
          Produces a gradient through green, yellow, orange, red
static java.awt.Color[] GRADIENT_HEAT
          Produces a different gradient for hot things (black, brown, orange, white)
static java.awt.Color[] GRADIENT_HOT
          Produces a gradient for hot things (black, red, orange, yellow, white)
static java.awt.Color[] GRADIENT_MAROON_TO_GOLD
          Produces a gradient using the University of Minnesota's school colors, from maroon (low) to gold (high)
static java.awt.Color[] GRADIENT_RAINBOW
          Produces a gradient through the rainbow: violet, blue, green, yellow, orange, red
static java.awt.Color[] GRADIENT_RED_TO_GREEN
          Produces a gradient from red (low) to green (high)
static java.awt.Color[] GRADIENT_ROY
          Produces a gradient through red, orange, yellow
 
Constructor Summary
Gradient()
           
 
Method Summary
static java.awt.Color[] createGradient(java.awt.Color one, java.awt.Color two, int numSteps)
          Creates an array of Color objects for use as a gradient, using a linear interpolation between the two specified colors.
static java.awt.Color[] createMultiGradient(java.awt.Color[] colors, int numSteps)
          Creates an array of Color objects for use as a gradient, using an array of Color objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRADIENT_MAROON_TO_GOLD

public static final java.awt.Color[] GRADIENT_MAROON_TO_GOLD
Produces a gradient using the University of Minnesota's school colors, from maroon (low) to gold (high)


GRADIENT_BLUE_TO_RED

public static final java.awt.Color[] GRADIENT_BLUE_TO_RED
Produces a gradient from blue (low) to red (high)


GRADIENT_BLACK_TO_WHITE

public static final java.awt.Color[] GRADIENT_BLACK_TO_WHITE
Produces a gradient from black (low) to white (high)


GRADIENT_RED_TO_GREEN

public static final java.awt.Color[] GRADIENT_RED_TO_GREEN
Produces a gradient from red (low) to green (high)


GRADIENT_GREEN_YELLOW_ORANGE_RED

public static final java.awt.Color[] GRADIENT_GREEN_YELLOW_ORANGE_RED
Produces a gradient through green, yellow, orange, red


GRADIENT_RAINBOW

public static final java.awt.Color[] GRADIENT_RAINBOW
Produces a gradient through the rainbow: violet, blue, green, yellow, orange, red


GRADIENT_HOT

public static final java.awt.Color[] GRADIENT_HOT
Produces a gradient for hot things (black, red, orange, yellow, white)


GRADIENT_HEAT

public static final java.awt.Color[] GRADIENT_HEAT
Produces a different gradient for hot things (black, brown, orange, white)


GRADIENT_ROY

public static final java.awt.Color[] GRADIENT_ROY
Produces a gradient through red, orange, yellow

Constructor Detail

Gradient

public Gradient()
Method Detail

createGradient

public static java.awt.Color[] createGradient(java.awt.Color one,
                                              java.awt.Color two,
                                              int numSteps)
Creates an array of Color objects for use as a gradient, using a linear interpolation between the two specified colors.

Parameters:
one - Color used for the bottom of the gradient
two - Color used for the top of the gradient
numSteps - The number of steps in the gradient. 250 is a good number.

createMultiGradient

public static java.awt.Color[] createMultiGradient(java.awt.Color[] colors,
                                                   int numSteps)
Creates an array of Color objects for use as a gradient, using an array of Color objects. It uses a linear interpolation between each pair of points. The parameter numSteps defines the total number of colors in the returned array, not the number of colors per segment.

Parameters:
colors - An array of Color objects used for the gradient. The Color at index 0 will be the lowest color.
numSteps - The number of steps in the gradient. 250 is a good number.