org.biojava.bio.structure.gui.util.color
Class LinearColorInterpolator

java.lang.Object
  extended by org.biojava.bio.structure.gui.util.color.LinearColorInterpolator
All Implemented Interfaces:
ColorInterpolator

public class LinearColorInterpolator
extends Object
implements ColorInterpolator

Author:
Spencer Bliven

Nested Class Summary
static class LinearColorInterpolator.InterpolationDirection
           
 
Constructor Summary
LinearColorInterpolator()
           
LinearColorInterpolator(ColorSpace colorSpace)
           
 
Method Summary
 Color interpolate(Color a, Color b, float mixing)
          Interpolates to a color between a and b
 void setColorSpace(ColorSpace colorSpace)
           
 void setColorSpace(ColorSpace colorSpace, LinearColorInterpolator.InterpolationDirection[] dir)
          Sets the ColorSpace to use for interpolation.
 void setInterpolationDirection(int componentIndex, LinearColorInterpolator.InterpolationDirection dir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearColorInterpolator

public LinearColorInterpolator()

LinearColorInterpolator

public LinearColorInterpolator(ColorSpace colorSpace)
Method Detail

interpolate

public Color interpolate(Color a,
                         Color b,
                         float mixing)
Interpolates to a color between a and b

Specified by:
interpolate in interface ColorInterpolator
Parameters:
a - First color
b - Second color
mixing - Mixing coefficient; the fraction of a in the result.
Returns:
The color between a and b
Throws:
IllegalArgumentException - if mixing is not between 0 and 1
See Also:
ColorInterpolator.interpolate(java.awt.Color, java.awt.Color, float)

setColorSpace

public void setColorSpace(ColorSpace colorSpace,
                          LinearColorInterpolator.InterpolationDirection[] dir)
Sets the ColorSpace to use for interpolation. The most common scheme for color spaces is to use linear components between 0 and 1 (for instance red,green,blue). For such a component, a linear interpolation between two colors is used. Sometimes a component may be in cylindrical coordinates. In this case, the component can be mapped in a number of ways. These are set by InterpolationDirections.

Parameters:
colorSpace - The color space for interpolation
interpDirection - An array of size colorSpace.getNumComponents() giving the interpolation direction for each component.

setColorSpace

public void setColorSpace(ColorSpace colorSpace)

setInterpolationDirection

public void setInterpolationDirection(int componentIndex,
                                      LinearColorInterpolator.InterpolationDirection dir)