org.gwoptics.graphics.colourmap
Class EquationColourmap

java.lang.Object
  extended by org.gwoptics.graphics.colourmap.EquationColourmap
All Implemented Interfaces:
IColourmap
Direct Known Subclasses:
FlipColourmap

public class EquationColourmap
extends java.lang.Object
implements IColourmap

EquationColourmap implements the IColourmap interface to generate a colourmap from an equation, rather than nodes as in the alternative RGBColourmap. The equation that generates the map returns a Colour object as specified in IColourmapEquation.

Before any values are read from the map, the map must have been generated using generateColourmap() or a MapNeedsGeneratingException will be thrown.

Since:
0.2.4
Author:
Daniel Brown 18/6/09
See Also:
GWColour, IColourmapEquation, IColourmap, RGBColourmap, MapNeedsGeneratingException

Constructor Summary
EquationColourmap(IColourmapEquation eq)
          Requires an equation object to be passed to it, which is not nullable
EquationColourmap(int resolution, IColourmapEquation eq)
          Additional constructor that allows a custom resolution of lookup table.
 
Method Summary
 void generateColourmap()
          Use the supplied equation to generate colour values for each index in the colourmap.
 GWColour getColourAtLocation(float l)
          Returns a Colour object that relates to a normalised location on the colourmap
 int getIntAtLocation(float l)
          Returns an integer that relates to a normalised location on the colourmap.
 boolean isCentreAtZero()
          Should return true if 0 value for what the colourmap is displaying is represented by the colour at the point 0.5
 boolean isGenerated()
          Should return whether colourmap has been generated or not
 void setCentreAtZero(boolean value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EquationColourmap

public EquationColourmap(IColourmapEquation eq)
Requires an equation object to be passed to it, which is not nullable

Parameters:
eq - Equation that generates the colourmap, is not nullable.

EquationColourmap

public EquationColourmap(int resolution,
                         IColourmapEquation eq)
Additional constructor that allows a custom resolution of lookup table. Values of 50 and greater are recommended for most uses.

Parameters:
resolution - defines number of steps in colourmap lookup table.
eq - Equation that generates the colourmap, is not nullable.
Method Detail

isCentreAtZero

public boolean isCentreAtZero()
Description copied from interface: IColourmap
Should return true if 0 value for what the colourmap is displaying is represented by the colour at the point 0.5

Specified by:
isCentreAtZero in interface IColourmap

setCentreAtZero

public void setCentreAtZero(boolean value)

isGenerated

public boolean isGenerated()
Description copied from interface: IColourmap
Should return whether colourmap has been generated or not

Specified by:
isGenerated in interface IColourmap

generateColourmap

public void generateColourmap()
Use the supplied equation to generate colour values for each index in the colourmap. Must be called before map is used.

Specified by:
generateColourmap in interface IColourmap

getColourAtLocation

public GWColour getColourAtLocation(float l)
Returns a Colour object that relates to a normalised location on the colourmap

Specified by:
getColourAtLocation in interface IColourmap
Parameters:
l - Normalised location input (between 0.0f and 1.0f)
Returns:
Colour at location.

getIntAtLocation

public int getIntAtLocation(float l)
Returns an integer that relates to a normalised location on the colourmap. Integer is in a 4 byte format of ARGB.

Specified by:
getIntAtLocation in interface IColourmap
Parameters:
l - Normalised location input (between 0.0f and 1.0f)
Returns:
Integer value of colour at location.


processing library gwoptics by Daniel Brown and Andreas Freise. (c) 2009 onwards