org.gicentre.utils.colour

## Class ColourRule

- java.lang.Object
- - org.gicentre.utils.colour.ColourRule

- All Implemented Interfaces:
    java.io.Serializable

      public class ColourRule
      extends java.lang.Object
      implements java.io.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:
    3.4, 5th February, 2016.
  Author:
    Jo Wood, giCentre, City University London.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CONTINUOUS` Rule represents part of a continuous colour table.
    `static int` | `DISCRETE` Rule represents part of a discrete colour table.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `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

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `java.lang.String` | `toString()` Reports the current colour rule.
    `static java.lang.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 (transparency) 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 associated 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 (transparency) 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 (transparency) 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 associated with lower index.
        `i2` - Upper index value associated with rule.
        `c2` - Combined RGBA colour associated 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 java.lang.String toString()

      Reports the current colour rule.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        String containing current colour table.

    - #### toString

          public static java.lang.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.