org.gwoptics.graphics.colourmap
Class RGBColourmap

java.lang.Object
  extended by org.gwoptics.graphics.colourmap.RGBColourmap
All Implemented Interfaces:
IColourmap
Direct Known Subclasses:
CoolColourmap, GrayScaleColourmap, HotColourmap, WarmColourmap

public class RGBColourmap
extends java.lang.Object
implements IColourmap

RGBColourmap is an object that allows various colourmaps to be generated from RGB nodes. The class accepts user given values for nodes which are used to build a lookup table for fast access of values. The lookup table ranges from 0.0f to 1.0f where the steps in between are changeable via the constructor. To lookup a colour value the user input of the location must normalise their input and select a value between 0.0 and 1.0(Values greater or less than these are capped). So for a range of 0.0 to 100.0 to get the colour of a point whose value is 69, the location input should be 0.69f.

This class implements the general IColourmap interface which allows it to work with objects that use colourmaps.

Since:
0.1.1
Author:
Daniel Brown 12/6/09
See Also:
IColourmap, ColourmapNode

Constructor Summary
RGBColourmap()
          Standard constructor that sets a default resolution of 100 steps in the lookup table.
RGBColourmap(int resolution)
          Additional constructor that allows a custom resolution of lookup table.
 
Method Summary
 void addNode(ColourmapNode n)
          This function adds an RGBNode to the colour map, which is then used to generate various gradients of colour.
 void generateColourmap()
          Generates the lookup table values using supplied nodes.
 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.
 ColourmapNode getNode(int i)
           
 int getNodeCount()
           
 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 removeNode(int i)
           
 void setCentreAtZero(boolean value)
           
 void setNode(int i, ColourmapNode node)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RGBColourmap

public RGBColourmap()
Standard constructor that sets a default resolution of 100 steps in the lookup table.


RGBColourmap

public RGBColourmap(int resolution)
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.
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

addNode

public void addNode(ColourmapNode n)
This function adds an RGBNode to the colour map, which is then used to generate various gradients of colour.


generateColourmap

public void generateColourmap()
Generates the lookup table values using supplied nodes. Once the required nodes have been added to the colourmap using addNode(), this function iterates through them all to generate the colourmap lookup table. This can later be accessed via the getColourAtLocation() and getIntAtLocation() functions. This function populates both a integer lookup table and a Colour lookup table. The integer being for faster access so no need to convert each Colour object.

Specified by:
generateColourmap in interface IColourmap
See Also:
GWColour, getColourAtLocation, getIntAtLocation, addNode()

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.

getNode

public ColourmapNode getNode(int i)

setNode

public void setNode(int i,
                    ColourmapNode node)

removeNode

public void removeNode(int i)

getNodeCount

public int getNodeCount()


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