jwo.landserf.structure
Class ColourRule

java.lang.Object
  extended byjwo.landserf.structure.ColourRule
All Implemented Interfaces:
Serializable

public class ColourRule
extends Object
implements Serializable

Colour rule class for storing a single colour rule. The colour rule consists of two indices and associated ARGB colour values. Colours are interpolated for any values that fall between the lower and upper indices.

Version:
2.2, 21st September, 2003.
Author:
Jo Wood
See Also:
Serialized Form

Field Summary
static int CONTINUOUS
          Rule represents part of a continuous colour table.
static int DISCRETE
          Rule represents part of a discrete colour table.
 
Constructor Summary
ColourRule(float i, int c)
          Creates a categorical colour rule.
ColourRule(float i1, int c1, float i2, int c2)
          Creates a continuous colour rule.
ColourRule(float i, int r, int g, int b)
          Creates a categorical colour rule.
ColourRule(float i1, int r1, int g1, int b1, float i2, int r2, int g2, int b2)
          Creates a continuous colour rule.
ColourRule(float i, int r, int g, int b, int a)
          Creates a categorical colour rule.
ColourRule(float i1, int r1, int g1, int b1, int a1, float i2, int r2, int g2, int b2, int a2)
          Creates a continuous colour rule.
 
Method Summary
 int getColour(float index)
          Interpolates the colour associated with the given index.
 int getlColour()
          Finds the colour associated with the lower index.
 float getlIndex()
          Finds the lower index associated with colour rule.
 int getType()
          Reports the type of colour rule.
 int getuColour()
          Finds the colour associated with the upper index.
 float getuIndex()
          Finds the upper index associated with colour rule.
 void setlColour(int lColour)
          Sets the colour associated with the lower index of the rule.
 void setlIndex(float lIndex)
          Sets the index associated with the lower colour.
 void setType(int type)
          Sets the rule type (either DISCRETE or CONTINUOUS).
 void setuColour(int uColour)
          Sets the colour associated with the upper index of the rule.
 void setuIndex(float uIndex)
          Sets the index associated with the upper colour.
 String toString()
          Reports the current colour rule.
static String toString(int intColour)
          Converts a given colour value from integer to R,G,B,A string for display and storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTINUOUS

public static final int CONTINUOUS
Rule represents part of a continuous colour table.

See Also:
Constant Field Values

DISCRETE

public static final int DISCRETE
Rule represents part of a discrete colour table.

See Also:
Constant Field Values
Constructor Detail

ColourRule

public ColourRule(float i,
                  int r,
                  int g,
                  int b)
Creates a categorical colour rule. RGB only (assumes opaque transparency).

Parameters:
i - Index value associated with rule.
r - Red component of colour associated with index.
g - Green component of colour associated with index.
b - Blue component of colour associated with index.

ColourRule

public ColourRule(float i,
                  int r,
                  int g,
                  int b,
                  int a)
Creates a categorical colour rule. RGBA version.

Parameters:
i - Index value associated with rule.
r - Red component of colour associated with index.
g - Green component of colour associated with index.
b - Blue component of colour associated with index.
a - Alpha (transparancy) component associated with index.

ColourRule

public ColourRule(float i,
                  int c)
Creates a categorical colour rule. Combined ARGB version.

Parameters:
i - index value associated with rule.
c - Combined ARGB colour assicated with index.

ColourRule

public ColourRule(float i1,
                  int r1,
                  int g1,
                  int b1,
                  float i2,
                  int r2,
                  int g2,
                  int b2)
Creates a continuous colour rule. RGB only (assumes opaque transparency).

Parameters:
i1 - Lower index value associated with rule.
r1 - Red component of colour associated with lower index.
g1 - Green component of colour associated with lower index.
b1 - Blue component of colour associated with lower index.
i2 - Upper index value associated with rule.
r2 - Red component of colour associated with upper index.
g2 - Green component of colour associated with upper index.
b2 - Blue component of colour associated with upper index.

ColourRule

public ColourRule(float i1,
                  int r1,
                  int g1,
                  int b1,
                  int a1,
                  float i2,
                  int r2,
                  int g2,
                  int b2,
                  int a2)
Creates a continuous colour rule. RGBA version.

Parameters:
i1 - Lower index value associated with rule.
r1 - Red component of colour associated with lower index.
g1 - Green component of colour associated with lower index.
b1 - Blue component of colour associated with lower index.
a1 - Alpha (transparancy) component associated with lower index.
i2 - Upper index value associated with rule.
r2 - Red component of colour associated with upper index.
g2 - Green component of colour associated with upper index.
b2 - Blue component of colour associated with upper index.
a2 - Alpha (transparancy) component associated with upper index.

ColourRule

public ColourRule(float i1,
                  int c1,
                  float i2,
                  int c2)
Creates a continuous colour rule. Combined ARGB version.

Parameters:
i1 - Lower index value associated with rule.
c1 - Combined RGBA colour assicated with lower index.
i2 - Upper index value associated with rule.
c2 - Combined RGBA colour assicated with upper index.
Method Detail

getColour

public int getColour(float index)
Interpolates the colour associated with the given index.

Parameters:
index - Index to associate colour with.
Returns:
Interpolated colour as a combined ARGB value.

getlIndex

public float getlIndex()
Finds the lower index associated with colour rule.

Returns:
Lower index value.

setlIndex

public void setlIndex(float lIndex)
Sets the index associated with the lower colour.

Parameters:
lIndex - New lower index for colour rule.

getuIndex

public float getuIndex()
Finds the upper index associated with colour rule.

Returns:
Upper index value.

setuIndex

public void setuIndex(float uIndex)
Sets the index associated with the upper colour.

Parameters:
uIndex - New upper index for colour rule.

getType

public int getType()
Reports the type of colour rule. Discrete rules take precedence over continuous rules.

Returns:
Type of colour rule. Either DISCRETE or CONTINUOUS.

setType

public void setType(int type)
Sets the rule type (either DISCRETE or CONTINUOUS).

Parameters:
type - Type of colour rule. Either DISCRETE or CONTINUOUS.

getlColour

public int getlColour()
Finds the colour associated with the lower index.

Returns:
Lower colour value (combined ARGB).

setlColour

public void setlColour(int lColour)
Sets the colour associated with the lower index of the rule.

Parameters:
lColour - New colour for lower index (combined ARGB).

setuColour

public void setuColour(int uColour)
Sets the colour associated with the upper index of the rule.

Parameters:
uColour - New colour for upper index (combined ARGB).

getuColour

public int getuColour()
Finds the colour associated with the upper index.

Returns:
Upper colour value (combined ARGB).

toString

public String toString()
Reports the current colour rule.

Returns:
String containing current colour table.

toString

public static String toString(int intColour)
Converts a given colour value from integer to R,G,B,A string for display and storage.

Parameters:
intColour - Colour represented as integer.
Returns:
String representation of the colour.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005