org.gicentre.utils.colour
Class ColourTable

java.lang.Object
  extended by org.gicentre.utils.colour.ColourTable
All Implemented Interfaces:
java.io.Serializable

public class ColourTable
extends java.lang.Object
implements java.io.Serializable

Colour table class for storing colour rules associated with a spatial object. A colour table can be a set of rules, a 'raw' colour table where each attribute value is a 32 bit colour code (mostly used used for image files), or an 'attribute' table where each attribute is stored in the form of a colour. Most common are colour rules where each rule consists of two indices and associated RGBA colour values. Colours are interpolated for any values that fall between the lower and upper indices. Also contains static methods for creating preset colour tables such as ColorBrewer colour schemes and Imhof relief colour schemes.

ColorBrewer specifications and designs developed by Cynthia Brewer (colorbrewer.org).

Version:
3.3, 6th April, 2013.
Author:
Jo Wood, giCentre, City University London.
See Also:
Serialized Form

Field Summary
static int ACCENT_3
          ColorBrewer qualitative categorical accented scheme with 3 elements.
static int ACCENT_4
          ColorBrewer qualitative categorical accented scheme with 4 elements.
static int ACCENT_5
          ColorBrewer qualitative categorical accented scheme with 5 elements.
static int ACCENT_6
          ColorBrewer qualitative categorical accented scheme with 6 elements.
static int ACCENT_7
          ColorBrewer qualitative categorical accented scheme with 7 elements.
static int ACCENT_8
          ColorBrewer qualitative categorical accented scheme with 8 elements.
static int ASPECT
          Indicates a (red-blue) aspect colour table.
static int BLACK
          Single black colour
static int BLUES
          ColorBrewer sequential monochrome blue scheme.
static int BR_B_G
          ColorBrewer diverging brown-blue-green scheme.
static int BU_GN
          ColorBrewer sequential blue-green scheme.
static int BU_PU
          ColorBrewer sequential blue-purple scheme.
static int CHANNEL
          Channel feature.
static int COLOUR_ATTRIB
          Uses integer coding of the object's (floating point) attribute.
static int COLOUR_RAW
          Colour table uses raster values.
static int COLOUR_RULES
          Colour table uses colour rules.
static int DARK2_3
          ColorBrewer qualitative categorical dark scheme with 3 elements.
static int DARK2_4
          ColorBrewer qualitative categorical dark scheme with 4 elements.
static int DARK2_5
          ColorBrewer qualitative categorical dark scheme with 5 elements.
static int DARK2_6
          ColorBrewer qualitative categorical dark scheme with 6 elements.
static int DARK2_7
          ColorBrewer qualitative categorical dark scheme with 7 elements.
static int DARK2_8
          ColorBrewer qualitative categorical dark scheme with 8 elements.
static int DEFAULT
          Indicates a default (green-purple-white) colour table.
static int DIVERGING_BLURED
          Diverging blue to red colour table.
static int DIVERGING_BLUYELRED
          Diverging blue through yellow to to red table.
static int DIVERGING_GRNYEL
          Diverging blue to red colour table.
static int EXP_ORRED
          Exponential orange to red colour table.
static int FEATURES
          Indicates a feature class (black, blue, green, yellow, red ) colour table.
static int GN_BU
          ColorBrewer sequential green-blue scheme.
static int GREENS
          ColorBrewer sequential monochrome green scheme.
static int GREYS
          ColorBrewer sequential monochrome grey scheme.
static int GREYSCALE
          Greyscale (black to white) colour table.
static int IMHOF_L1
          Imhof land surface colour scheme (green to beige).
static int IMHOF_L2
          Imhof land surface colour scheme (green to brown).
static int IMHOF_L3
          Imhof land surface colour scheme (green to orange).
static int IMHOF_L4
          Imhof land surface colour scheme (green to white).
static int IMHOF_S1
          Imhof sea colour scheme (blue to white).
static int IMHOF_S2
          Imhof sea colour scheme (dark blue to white).
static int IMHOF_SL
          Imhof sea and land colour scheme (dark blue to brown).
static int INV_GREYSCALE
          Inverted greyscale (white to black) colour table.
static int MSN_FEATURES
          Indicates a feature class (black, blue, green, yellow, red ) colour table.
static float NO_VALUE
          Indicates the value of the spatial model is undefined.
static int OR_RD
          ColorBrewer sequential orange-red scheme.
static int ORANGES
          ColorBrewer sequential monochrome orange scheme.
static int P_R_GN
          ColorBrewer diverging purple-red-green scheme.
static int PAIRED_10
          ColorBrewer qualitative categorical paired scheme with 10 elements.
static int PAIRED_11
          ColorBrewer qualitative categorical paired scheme with 11 elements.
static int PAIRED_12
          ColorBrewer qualitative categorical paired scheme with 12 elements.
static int PAIRED_3
          ColorBrewer qualitative categorical paired scheme with 3 elements.
static int PAIRED_4
          ColorBrewer qualitative categorical paired scheme with 4 elements.
static int PAIRED_5
          ColorBrewer qualitative categorical paired scheme with 5 elements.
static int PAIRED_6
          ColorBrewer qualitative categorical paired scheme with 6 elements.
static int PAIRED_7
          ColorBrewer qualitative categorical paired scheme with 7 elements.
static int PAIRED_8
          ColorBrewer qualitative categorical paired scheme with 8 elements.
static int PAIRED_9
          ColorBrewer qualitative categorical paired scheme with 9 elements.
static int PASS
          Pass (saddle) feature.
static int PASTEL1_3
          ColorBrewer qualitative categorical pastel scheme with 3 elements.
static int PASTEL1_4
          ColorBrewer qualitative categorical pastel scheme with 4 elements.
static int PASTEL1_5
          ColorBrewer qualitative categorical pastel scheme with 5 elements.
static int PASTEL1_6
          ColorBrewer qualitative categorical pastel scheme with 6 elements.
static int PASTEL1_7
          ColorBrewer qualitative categorical pastel scheme with 7 elements.
static int PASTEL1_8
          ColorBrewer qualitative categorical pastel scheme with 8 elements.
static int PASTEL1_9
          ColorBrewer qualitative categorical pastel scheme with 9 elements.
static int PASTEL2_3
          ColorBrewer qualitative categorical pastel scheme with 3 elements.
static int PASTEL2_4
          ColorBrewer qualitative categorical pastel scheme with 4 elements.
static int PASTEL2_5
          ColorBrewer qualitative categorical pastel scheme with 5 elements.
static int PASTEL2_6
          ColorBrewer qualitative categorical pastel scheme with 6 elements.
static int PASTEL2_7
          ColorBrewer qualitative categorical pastel scheme with 7 elements.
static int PASTEL2_8
          ColorBrewer qualitative categorical pastel scheme with 8 elements.
static int PEAK
          Peak feature.
static int PI_Y_G
          ColorBrewer diverging pink-yellow-green scheme.
static int PIT
          Pit feature.
static int PLANAR
          Planar (no) feature.
static int PU_BU
          ColorBrewer sequential purple-blue scheme.
static int PU_BU_GN
          ColorBrewer sequential purple-blue-green scheme.
static int PU_OR
          ColorBrewer diverging purple-orange scheme.
static int PU_RD
          ColorBrewer sequential purple-red scheme.
static int PURPLES
          ColorBrewer sequential monochrome purple scheme.
static int RANDOM
          Random colour scheme for nominal data.
static int RD_BU
          ColorBrewer diverging red-blue scheme.
static int RD_GY
          ColorBrewer diverging red-grey scheme.
static int RD_PU
          ColorBrewer sequential red-purple scheme.
static int RD_YL_BU
          ColorBrewer diverging red-yellow-blue scheme.
static int RD_YL_GN
          ColorBrewer diverging red-yellow-green scheme.
static int REDS
          ColorBrewer sequential monochrome red scheme.
static int RIDGE
          Ridge feature.
static int SET1_3
          ColorBrewer qualitative categorical scheme with 3 elements.
static int SET1_4
          ColorBrewer qualitative categorical scheme with 4 elements.
static int SET1_5
          ColorBrewer qualitative categorical scheme with 5 elements.
static int SET1_6
          ColorBrewer qualitative categorical scheme with 6 elements.
static int SET1_7
          ColorBrewer qualitative categorical scheme with 7 elements.
static int SET1_8
          ColorBrewer qualitative categorical scheme with 8 elements.
static int SET1_9
          ColorBrewer qualitative categorical scheme with 9 elements.
static int SET2_3
          ColorBrewer qualitative categorical scheme with 3 elements.
static int SET2_4
          ColorBrewer qualitative categorical scheme with 4 elements.
static int SET2_5
          ColorBrewer qualitative categorical scheme with 5 elements.
static int SET2_6
          ColorBrewer qualitative categorical scheme with 6 elements.
static int SET2_7
          ColorBrewer qualitative categorical scheme with 7 elements.
static int SET2_8
          ColorBrewer qualitative categorical scheme with 8 elements.
static int SET3_10
          ColorBrewer qualitative categorical scheme with 10 elements.
static int SET3_11
          ColorBrewer qualitative categorical scheme with 11 elements.
static int SET3_12
          ColorBrewer qualitative categorical scheme with 12 elements.
static int SET3_3
          ColorBrewer qualitative categorical scheme with 3 elements.
static int SET3_4
          ColorBrewer qualitative categorical scheme with 4 elements.
static int SET3_5
          ColorBrewer qualitative categorical scheme with 5 elements.
static int SET3_6
          ColorBrewer qualitative categorical scheme with 6 elements.
static int SET3_7
          ColorBrewer qualitative categorical scheme with 7 elements.
static int SET3_8
          ColorBrewer qualitative categorical scheme with 8 elements.
static int SET3_9
          ColorBrewer qualitative categorical scheme with 9 elements.
static int SLOPE
          Indicates a slope (white - yellow - black) colour table.
static int SPECTRAL
          ColorBrewer diverging spectral scheme.
static int UNDEFINED
          Undefined feature.
static int UPEAK
          'Universal peak'
static int UPIT
          'Universal pit' (e.g.
static int YL_GN
          ColorBrewer sequential yellow-green scheme.
static int YL_GN_BU
          ColorBrewer sequential yellow-green-blue scheme.
static int YL_OR_BR
          ColorBrewer sequential yellow-orange-brown scheme.
static int YL_OR_RD
          ColorBrewer sequential yellow-orange-red scheme.
 
Constructor Summary
ColourTable()
          Creates an initial (black) colour table.
ColourTable(ColourTable oldColourTable)
          Creates a colour table based on a copy of a colour table.
 
Method Summary
 void addContinuousColourRule(float index, int colour)
          Adds a continuous colour rule to the colour table.
 void addContinuousColourRule(float index, int r, int g, int b)
          Adds a continuous colour rule to the colour table.
 void addContinuousColourRule(float index, int r, int g, int b, int a)
          Adds a continuous colour rule to the colour table.
 void addDiscreteColourRule(float index, int colour)
          Adds a discrete colour rule to the colour table.
 void addDiscreteColourRule(float index, int r, int g, int b)
          Adds a discrete colour rule to the colour table.
 void addDiscreteColourRule(float index, int r, int g, int b, int a)
          Adds a discrete colour rule to the colour table.
static int argbToRgba(int argb)
          Converts an ARGB into an RGBA colour.
 int findColour(float index)
          Interpolates a given index colour from colour rules.
static int getAlpha(int colour)
          Reports the alpha value of the given colour.
 java.util.Vector<ColourRule> getColourRules()
          Returns the rules associated with the colour table
 int getColourTableType()
          Reports type of colour table (COLOUR_RULES, COLOUR_ATTRIB or COLOUR_RAW).
static java.lang.String getHexString(int colour)
          Converts a given colour into its HTML-like hex string in the form #rrggbb or rrggbbaa if the colour has a non-opaque alpha value.
static java.lang.String getHexStringABGR(int colour)
          Converts a given colour into its hex string in the form aabbggrr.
 boolean getIsDiscrete()
          Reports whether this colour table can be treated as consisting of discrete values only.
 float getMaxIndex()
          Finds the highest index value in a set of colour rules.
 float getMinIndex()
          Finds the lowest index value in a set of colour rules.
 java.lang.String getName()
          Reports the name attached to the colour table.
static ColourTable getPresetColourTable(int type)
          Creates a preset colour table scaled between default minimum and maximum values.
static ColourTable getPresetColourTable(int type, float min, float max)
          Creates a preset colour table between the given values.
 boolean modifyColourRule(float existingIndex, float newIndex, int newColour, int newType)
          Modifies the rule with the existing index to use the given index and colour.
static ColourTable readFile(java.io.InputStream inStream)
          Creates a colour table from the rules defined in the given input stream.
static ColourTable readFile(java.lang.String fileName)
          Creates a colour table from the rules defined in the file with the given name.
 boolean removeColourRule(float index)
          Removes the rule with the given lower index.
static int rgbaToArgb(int rgba)
          Converts an RGBA into an ARGB colour.
 void setColourTableType(int cTableType)
          Sets the type of colour table (COLOUR_RULES, COLOUR_ATTRIB or COLOUR_RAW).
 void setIsDiscrete(boolean isDiscrete)
          Sets whether this colour table should be treated as consisting of discrete values only or not.
 void setName(java.lang.String name)
          Sets a new name to be associated with the colour table.
 javax.swing.ListModel toListModel()
          Converts the colour rules into a ListModel suitable for display by Swing JLists or JTables.
 java.lang.String toString()
          Reports the current colour table rules.
 java.lang.String[] toStringArray()
          Reports the current colour table rules.
static boolean writeFile(ColourTable colourTable, java.io.OutputStream outStream)
          Writes the given colour table out as a file using the given output stream.
static boolean writeFile(ColourTable colourTable, java.lang.String fileName)
          Writes the given colour table out as a file using the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALUE

public static final float NO_VALUE
Indicates the value of the spatial model is undefined.

See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
Undefined feature.

See Also:
Constant Field Values

PIT

public static final int PIT
Pit feature.

See Also:
Constant Field Values

CHANNEL

public static final int CHANNEL
Channel feature.

See Also:
Constant Field Values

PASS

public static final int PASS
Pass (saddle) feature.

See Also:
Constant Field Values

RIDGE

public static final int RIDGE
Ridge feature.

See Also:
Constant Field Values

PEAK

public static final int PEAK
Peak feature.

See Also:
Constant Field Values

PLANAR

public static final int PLANAR
Planar (no) feature.

See Also:
Constant Field Values

UPIT

public static final int UPIT
'Universal pit' (e.g. sea).

See Also:
Constant Field Values

UPEAK

public static final int UPEAK
'Universal peak'

See Also:
Constant Field Values

COLOUR_RULES

public static final int COLOUR_RULES
Colour table uses colour rules.

See Also:
Constant Field Values

COLOUR_RAW

public static final int COLOUR_RAW
Colour table uses raster values.

See Also:
Constant Field Values

COLOUR_ATTRIB

public static final int COLOUR_ATTRIB
Uses integer coding of the object's (floating point) attribute. Not for display, this table allows graphical buffers to preserve attributes of any object displayed using this colour scheme.

See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
Indicates a default (green-purple-white) colour table.

See Also:
Constant Field Values

FEATURES

public static final int FEATURES
Indicates a feature class (black, blue, green, yellow, red ) colour table.

See Also:
Constant Field Values

MSN_FEATURES

public static final int MSN_FEATURES
Indicates a feature class (black, blue, green, yellow, red ) colour table.

See Also:
Constant Field Values

SLOPE

public static final int SLOPE
Indicates a slope (white - yellow - black) colour table.

See Also:
Constant Field Values

ASPECT

public static final int ASPECT
Indicates a (red-blue) aspect colour table.

See Also:
Constant Field Values

DIVERGING_BLURED

public static final int DIVERGING_BLURED
Diverging blue to red colour table. Used for ProfC surfaces.

See Also:
Constant Field Values

DIVERGING_GRNYEL

public static final int DIVERGING_GRNYEL
Diverging blue to red colour table. Used for ProfC surfaces.

See Also:
Constant Field Values

DIVERGING_BLUYELRED

public static final int DIVERGING_BLUYELRED
Diverging blue through yellow to to red table. Based on Color Brewer's 'RdYlBu' diverging colour scheme.

See Also:
Constant Field Values

GREYSCALE

public static final int GREYSCALE
Greyscale (black to white) colour table.

See Also:
Constant Field Values

INV_GREYSCALE

public static final int INV_GREYSCALE
Inverted greyscale (white to black) colour table.

See Also:
Constant Field Values

IMHOF_L1

public static final int IMHOF_L1
Imhof land surface colour scheme (green to beige).

See Also:
Constant Field Values

IMHOF_L2

public static final int IMHOF_L2
Imhof land surface colour scheme (green to brown).

See Also:
Constant Field Values

IMHOF_L3

public static final int IMHOF_L3
Imhof land surface colour scheme (green to orange).

See Also:
Constant Field Values

IMHOF_L4

public static final int IMHOF_L4
Imhof land surface colour scheme (green to white).

See Also:
Constant Field Values

IMHOF_S1

public static final int IMHOF_S1
Imhof sea colour scheme (blue to white).

See Also:
Constant Field Values

IMHOF_S2

public static final int IMHOF_S2
Imhof sea colour scheme (dark blue to white).

See Also:
Constant Field Values

IMHOF_SL

public static final int IMHOF_SL
Imhof sea and land colour scheme (dark blue to brown).

See Also:
Constant Field Values

EXP_ORRED

public static final int EXP_ORRED
Exponential orange to red colour table. Based on Color Brewer's 'OrRd' nine-sequence colour scheme.

See Also:
Constant Field Values

RANDOM

public static final int RANDOM
Random colour scheme for nominal data.

See Also:
Constant Field Values

YL_GN

public static final int YL_GN
ColorBrewer sequential yellow-green scheme.

See Also:
Constant Field Values

YL_GN_BU

public static final int YL_GN_BU
ColorBrewer sequential yellow-green-blue scheme.

See Also:
Constant Field Values

GN_BU

public static final int GN_BU
ColorBrewer sequential green-blue scheme.

See Also:
Constant Field Values

BU_GN

public static final int BU_GN
ColorBrewer sequential blue-green scheme.

See Also:
Constant Field Values

PU_BU_GN

public static final int PU_BU_GN
ColorBrewer sequential purple-blue-green scheme.

See Also:
Constant Field Values

PU_BU

public static final int PU_BU
ColorBrewer sequential purple-blue scheme.

See Also:
Constant Field Values

BU_PU

public static final int BU_PU
ColorBrewer sequential blue-purple scheme.

See Also:
Constant Field Values

RD_PU

public static final int RD_PU
ColorBrewer sequential red-purple scheme.

See Also:
Constant Field Values

PU_RD

public static final int PU_RD
ColorBrewer sequential purple-red scheme.

See Also:
Constant Field Values

OR_RD

public static final int OR_RD
ColorBrewer sequential orange-red scheme.

See Also:
Constant Field Values

YL_OR_RD

public static final int YL_OR_RD
ColorBrewer sequential yellow-orange-red scheme.

See Also:
Constant Field Values

YL_OR_BR

public static final int YL_OR_BR
ColorBrewer sequential yellow-orange-brown scheme.

See Also:
Constant Field Values

PURPLES

public static final int PURPLES
ColorBrewer sequential monochrome purple scheme.

See Also:
Constant Field Values

BLUES

public static final int BLUES
ColorBrewer sequential monochrome blue scheme.

See Also:
Constant Field Values

GREENS

public static final int GREENS
ColorBrewer sequential monochrome green scheme.

See Also:
Constant Field Values

ORANGES

public static final int ORANGES
ColorBrewer sequential monochrome orange scheme.

See Also:
Constant Field Values

REDS

public static final int REDS
ColorBrewer sequential monochrome red scheme.

See Also:
Constant Field Values

GREYS

public static final int GREYS
ColorBrewer sequential monochrome grey scheme.

See Also:
Constant Field Values

PU_OR

public static final int PU_OR
ColorBrewer diverging purple-orange scheme.

See Also:
Constant Field Values

BR_B_G

public static final int BR_B_G
ColorBrewer diverging brown-blue-green scheme.

See Also:
Constant Field Values

P_R_GN

public static final int P_R_GN
ColorBrewer diverging purple-red-green scheme.

See Also:
Constant Field Values

PI_Y_G

public static final int PI_Y_G
ColorBrewer diverging pink-yellow-green scheme.

See Also:
Constant Field Values

RD_BU

public static final int RD_BU
ColorBrewer diverging red-blue scheme.

See Also:
Constant Field Values

RD_GY

public static final int RD_GY
ColorBrewer diverging red-grey scheme.

See Also:
Constant Field Values

RD_YL_BU

public static final int RD_YL_BU
ColorBrewer diverging red-yellow-blue scheme.

See Also:
Constant Field Values

SPECTRAL

public static final int SPECTRAL
ColorBrewer diverging spectral scheme.

See Also:
Constant Field Values

RD_YL_GN

public static final int RD_YL_GN
ColorBrewer diverging red-yellow-green scheme.

See Also:
Constant Field Values

SET1_3

public static final int SET1_3
ColorBrewer qualitative categorical scheme with 3 elements.

See Also:
Constant Field Values

SET1_4

public static final int SET1_4
ColorBrewer qualitative categorical scheme with 4 elements.

See Also:
Constant Field Values

SET1_5

public static final int SET1_5
ColorBrewer qualitative categorical scheme with 5 elements.

See Also:
Constant Field Values

SET1_6

public static final int SET1_6
ColorBrewer qualitative categorical scheme with 6 elements.

See Also:
Constant Field Values

SET1_7

public static final int SET1_7
ColorBrewer qualitative categorical scheme with 7 elements.

See Also:
Constant Field Values

SET1_8

public static final int SET1_8
ColorBrewer qualitative categorical scheme with 8 elements.

See Also:
Constant Field Values

SET1_9

public static final int SET1_9
ColorBrewer qualitative categorical scheme with 9 elements.

See Also:
Constant Field Values

SET2_3

public static final int SET2_3
ColorBrewer qualitative categorical scheme with 3 elements.

See Also:
Constant Field Values

SET2_4

public static final int SET2_4
ColorBrewer qualitative categorical scheme with 4 elements.

See Also:
Constant Field Values

SET2_5

public static final int SET2_5
ColorBrewer qualitative categorical scheme with 5 elements.

See Also:
Constant Field Values

SET2_6

public static final int SET2_6
ColorBrewer qualitative categorical scheme with 6 elements.

See Also:
Constant Field Values

SET2_7

public static final int SET2_7
ColorBrewer qualitative categorical scheme with 7 elements.

See Also:
Constant Field Values

SET2_8

public static final int SET2_8
ColorBrewer qualitative categorical scheme with 8 elements.

See Also:
Constant Field Values

SET3_3

public static final int SET3_3
ColorBrewer qualitative categorical scheme with 3 elements.

See Also:
Constant Field Values

SET3_4

public static final int SET3_4
ColorBrewer qualitative categorical scheme with 4 elements.

See Also:
Constant Field Values

SET3_5

public static final int SET3_5
ColorBrewer qualitative categorical scheme with 5 elements.

See Also:
Constant Field Values

SET3_6

public static final int SET3_6
ColorBrewer qualitative categorical scheme with 6 elements.

See Also:
Constant Field Values

SET3_7

public static final int SET3_7
ColorBrewer qualitative categorical scheme with 7 elements.

See Also:
Constant Field Values

SET3_8

public static final int SET3_8
ColorBrewer qualitative categorical scheme with 8 elements.

See Also:
Constant Field Values

SET3_9

public static final int SET3_9
ColorBrewer qualitative categorical scheme with 9 elements.

See Also:
Constant Field Values

SET3_10

public static final int SET3_10
ColorBrewer qualitative categorical scheme with 10 elements.

See Also:
Constant Field Values

SET3_11

public static final int SET3_11
ColorBrewer qualitative categorical scheme with 11 elements.

See Also:
Constant Field Values

SET3_12

public static final int SET3_12
ColorBrewer qualitative categorical scheme with 12 elements.

See Also:
Constant Field Values

PASTEL1_3

public static final int PASTEL1_3
ColorBrewer qualitative categorical pastel scheme with 3 elements.

See Also:
Constant Field Values

PASTEL1_4

public static final int PASTEL1_4
ColorBrewer qualitative categorical pastel scheme with 4 elements.

See Also:
Constant Field Values

PASTEL1_5

public static final int PASTEL1_5
ColorBrewer qualitative categorical pastel scheme with 5 elements.

See Also:
Constant Field Values

PASTEL1_6

public static final int PASTEL1_6
ColorBrewer qualitative categorical pastel scheme with 6 elements.

See Also:
Constant Field Values

PASTEL1_7

public static final int PASTEL1_7
ColorBrewer qualitative categorical pastel scheme with 7 elements.

See Also:
Constant Field Values

PASTEL1_8

public static final int PASTEL1_8
ColorBrewer qualitative categorical pastel scheme with 8 elements.

See Also:
Constant Field Values

PASTEL1_9

public static final int PASTEL1_9
ColorBrewer qualitative categorical pastel scheme with 9 elements.

See Also:
Constant Field Values

PASTEL2_3

public static final int PASTEL2_3
ColorBrewer qualitative categorical pastel scheme with 3 elements.

See Also:
Constant Field Values

PASTEL2_4

public static final int PASTEL2_4
ColorBrewer qualitative categorical pastel scheme with 4 elements.

See Also:
Constant Field Values

PASTEL2_5

public static final int PASTEL2_5
ColorBrewer qualitative categorical pastel scheme with 5 elements.

See Also:
Constant Field Values

PASTEL2_6

public static final int PASTEL2_6
ColorBrewer qualitative categorical pastel scheme with 6 elements.

See Also:
Constant Field Values

PASTEL2_7

public static final int PASTEL2_7
ColorBrewer qualitative categorical pastel scheme with 7 elements.

See Also:
Constant Field Values

PASTEL2_8

public static final int PASTEL2_8
ColorBrewer qualitative categorical pastel scheme with 8 elements.

See Also:
Constant Field Values

DARK2_3

public static final int DARK2_3
ColorBrewer qualitative categorical dark scheme with 3 elements.

See Also:
Constant Field Values

DARK2_4

public static final int DARK2_4
ColorBrewer qualitative categorical dark scheme with 4 elements.

See Also:
Constant Field Values

DARK2_5

public static final int DARK2_5
ColorBrewer qualitative categorical dark scheme with 5 elements.

See Also:
Constant Field Values

DARK2_6

public static final int DARK2_6
ColorBrewer qualitative categorical dark scheme with 6 elements.

See Also:
Constant Field Values

DARK2_7

public static final int DARK2_7
ColorBrewer qualitative categorical dark scheme with 7 elements.

See Also:
Constant Field Values

DARK2_8

public static final int DARK2_8
ColorBrewer qualitative categorical dark scheme with 8 elements.

See Also:
Constant Field Values

PAIRED_3

public static final int PAIRED_3
ColorBrewer qualitative categorical paired scheme with 3 elements.

See Also:
Constant Field Values

PAIRED_4

public static final int PAIRED_4
ColorBrewer qualitative categorical paired scheme with 4 elements.

See Also:
Constant Field Values

PAIRED_5

public static final int PAIRED_5
ColorBrewer qualitative categorical paired scheme with 5 elements.

See Also:
Constant Field Values

PAIRED_6

public static final int PAIRED_6
ColorBrewer qualitative categorical paired scheme with 6 elements.

See Also:
Constant Field Values

PAIRED_7

public static final int PAIRED_7
ColorBrewer qualitative categorical paired scheme with 7 elements.

See Also:
Constant Field Values

PAIRED_8

public static final int PAIRED_8
ColorBrewer qualitative categorical paired scheme with 8 elements.

See Also:
Constant Field Values

PAIRED_9

public static final int PAIRED_9
ColorBrewer qualitative categorical paired scheme with 9 elements.

See Also:
Constant Field Values

PAIRED_10

public static final int PAIRED_10
ColorBrewer qualitative categorical paired scheme with 10 elements.

See Also:
Constant Field Values

PAIRED_11

public static final int PAIRED_11
ColorBrewer qualitative categorical paired scheme with 11 elements.

See Also:
Constant Field Values

PAIRED_12

public static final int PAIRED_12
ColorBrewer qualitative categorical paired scheme with 12 elements.

See Also:
Constant Field Values

ACCENT_3

public static final int ACCENT_3
ColorBrewer qualitative categorical accented scheme with 3 elements.

See Also:
Constant Field Values

ACCENT_4

public static final int ACCENT_4
ColorBrewer qualitative categorical accented scheme with 4 elements.

See Also:
Constant Field Values

ACCENT_5

public static final int ACCENT_5
ColorBrewer qualitative categorical accented scheme with 5 elements.

See Also:
Constant Field Values

ACCENT_6

public static final int ACCENT_6
ColorBrewer qualitative categorical accented scheme with 6 elements.

See Also:
Constant Field Values

ACCENT_7

public static final int ACCENT_7
ColorBrewer qualitative categorical accented scheme with 7 elements.

See Also:
Constant Field Values

ACCENT_8

public static final int ACCENT_8
ColorBrewer qualitative categorical accented scheme with 8 elements.

See Also:
Constant Field Values

BLACK

public static final int BLACK
Single black colour

See Also:
Constant Field Values
Constructor Detail

ColourTable

public ColourTable()
Creates an initial (black) colour table.


ColourTable

public ColourTable(ColourTable oldColourTable)
Creates a colour table based on a copy of a colour table.

Parameters:
oldColourTable - Old colour table to copy.
Method Detail

addDiscreteColourRule

public void addDiscreteColourRule(float index,
                                  int r,
                                  int g,
                                  int b)
Adds a discrete colour rule to the colour table.

Parameters:
index - Index value associated with rule.
r - Red colour component (scaled between 0-255) associated with index.
g - Green colour component (scaled between 0-255) associated with index.
b - Blue colour component (scaled between 0-255) associated with index.

addDiscreteColourRule

public void addDiscreteColourRule(float index,
                                  int r,
                                  int g,
                                  int b,
                                  int a)
Adds a discrete colour rule to the colour table.

Parameters:
index - Index value associated with rule.
r - Red colour component (scaled between 0-255) associated with index.
g - Green colour component (scaled between 0-255) associated with index.
b - Blue colour component (scaled between 0-255) associated with index.
a - Alpha (opacity) component (scaled between 0-255) associated with index.

addDiscreteColourRule

public void addDiscreteColourRule(float index,
                                  int colour)
Adds a discrete colour rule to the colour table. Combined RGBA version.

Parameters:
index - Index value associated with rule.
colour - Colour value associated with index.

addContinuousColourRule

public void addContinuousColourRule(float index,
                                    int r,
                                    int g,
                                    int b)
Adds a continuous colour rule to the colour table.

Parameters:
index - Index value associated with rule.
r - Red colour component (scaled between 0-255) associated with index.
g - Green colour component (scaled between 0-255) associated with index.
b - Blue colour component (scaled between 0-255) associated with index.

addContinuousColourRule

public void addContinuousColourRule(float index,
                                    int r,
                                    int g,
                                    int b,
                                    int a)
Adds a continuous colour rule to the colour table.

Parameters:
index - Index value associated with rule.
r - Red colour component (scaled between 0-255) associated with index.
g - Green colour component (scaled between 0-255) associated with index.
b - Blue colour component (scaled between 0-255) associated with index.
a - Alpha (opacity) component (scaled between 0-255) associated with index.

addContinuousColourRule

public void addContinuousColourRule(float index,
                                    int colour)
Adds a continuous colour rule to the colour table. Combined RGBA version.

Parameters:
index - Index value associated with rule.
colour - Colour value associated with index.

removeColourRule

public boolean removeColourRule(float index)
Removes the rule with the given lower index.

Parameters:
index - Lower index identifying rule to remove.
Returns:
True if rule with given lower index found and removed.

modifyColourRule

public boolean modifyColourRule(float existingIndex,
                                float newIndex,
                                int newColour,
                                int newType)
Modifies the rule with the existing index to use the given index and colour.

Parameters:
existingIndex - Index value associated with rule.
newIndex - New index value associated with rule.
newColour - Colour value associated with index.
newType - New type of rule (either DISCRETE or CONTINUOUS).
Returns:
True if rule with given index found.

findColour

public int findColour(float index)
Interpolates a given index colour from colour rules.

Parameters:
index - Index to associated interpolated colour with.
Returns:
Interpolated colour.

getMinIndex

public float getMinIndex()
Finds the lowest index value in a set of colour rules.

Returns:
Minimum index value.

getMaxIndex

public float getMaxIndex()
Finds the highest index value in a set of colour rules.

Returns:
Maximum index value.

getIsDiscrete

public boolean getIsDiscrete()
Reports whether this colour table can be treated as consisting of discrete values only. Note that for user defined colour tables, this value needs to be set manually. Preset colour tables will set the correct value, but it can be overridden with setIsDiscrete(). The default value for all non-preset colour tables is false.

Returns:
True if colour table can be considered discrete.

setIsDiscrete

public void setIsDiscrete(boolean isDiscrete)
Sets whether this colour table should be treated as consisting of discrete values only or not.

Parameters:
isDiscrete - Determines whether or not this colour table should be considered discrete.

getName

public java.lang.String getName()
Reports the name attached to the colour table. By default this is 'User' for all colour tables created by adding rules, although it can be changed by calling setName(). All preset colour tables should provide a name that uniquely identifies the colour scheme.

Returns:
Name of the colour table.

setName

public void setName(java.lang.String name)
Sets a new name to be associated with the colour table.

Parameters:
name - Name to give to the colour table.

toString

public java.lang.String toString()
Reports the current colour table rules.

Overrides:
toString in class java.lang.Object
Returns:
String containing current colour table.

toStringArray

public java.lang.String[] toStringArray()
Reports the current colour table rules.

Returns:
String containing current colour table.

toListModel

public javax.swing.ListModel toListModel()
Converts the colour rules into a ListModel suitable for display by Swing JLists or JTables. If the colour table is not empty, each element is a ColourRule and so can perform detailed query of its colours and indices. If it is empty, the list model will contain a single string indicating table is empty.

Returns:
ListModel representation of the colour rules.

getColourTableType

public int getColourTableType()
Reports type of colour table (COLOUR_RULES, COLOUR_ATTRIB or COLOUR_RAW).

Returns:
Type of colour table.

setColourTableType

public void setColourTableType(int cTableType)
Sets the type of colour table (COLOUR_RULES, COLOUR_ATTRIB or COLOUR_RAW).

Parameters:
cTableType - Type of colour table.

getColourRules

public java.util.Vector<ColourRule> getColourRules()
Returns the rules associated with the colour table

Returns:
Ordered list of colour table rules.

rgbaToArgb

public static int rgbaToArgb(int rgba)
Converts an RGBA into an ARGB colour.

Parameters:
rgba - RGBA format colour.
Returns:
ARGB format colour.

argbToRgba

public static int argbToRgba(int argb)
Converts an ARGB into an RGBA colour.

Parameters:
argb - ARGB format colour.
Returns:
RGBA format colour.

getHexString

public static java.lang.String getHexString(int colour)
Converts a given colour into its HTML-like hex string in the form #rrggbb or rrggbbaa if the colour has a non-opaque alpha value.

Parameters:
colour - Colour to convert.
Returns:
HTML hex string representing colour.

getHexStringABGR

public static java.lang.String getHexStringABGR(int colour)
Converts a given colour into its hex string in the form aabbggrr.

Parameters:
colour - Colour to convert.
Returns:
Hex string representing colour.

getAlpha

public static int getAlpha(int colour)
Reports the alpha value of the given colour.

Parameters:
colour - Colour to query.
Returns:
Alpha value of the colour (scaled from 0 (transparent) to 255 (opaque).

getPresetColourTable

public static ColourTable getPresetColourTable(int type)
Creates a preset colour table scaled between default minimum and maximum values. Defaults are generally between 0 and 1 for continuous sequential schemes, -1 and 1 for diverging schemes and 1 to n for categorical schemes. Categorical schemes with a fixed number of categories can be identified by a _ suffix indicating the number of categories to be assigned colours.

Parameters:
type - Type of colour table to create (DEFAULT, GREYSCALE, YL_OR_BR etc.).
Returns:
New colour table.

getPresetColourTable

public static ColourTable getPresetColourTable(int type,
                                               float min,
                                               float max)
Creates a preset colour table between the given values. Note that the max value is ignored for ColorBrewer categorical schemes that specify the number of classes since this is pre-determined relative to the min value using integer steps. For example, calling getPresetColourTable(DARK_4,10,100) would define categorical colours to the values 10, 11, 12 and 13 since only 4 colours are defined in that scheme. Categorical schemes with a fixed number of categories can be identified by a _ suffix indicating the number of categories to be assigned colours.

Parameters:
type - Type of colour scheme to create (DEFAULT, GREYSCALE, YL_OR_BR etc.).
min - Minimum value. If Float.NaN, the scheme's default minimum is used.
max - Maximum value (ignored for ColorBrewer categorical schemes). If Float.NaN, the scheme's default maximum is used.
Returns:
Colour table scaled between given min and max values.

readFile

public static ColourTable readFile(java.lang.String fileName)
Creates a colour table from the rules defined in the file with the given name. The file should be a landSerf colour table file containing XML defining a set of colour rules. This can be created using the writeFile() method.

Parameters:
fileName - Name of file containing rules.
Returns:
Colour table created or null if problems creating table from file.

readFile

public static ColourTable readFile(java.io.InputStream inStream)
Creates a colour table from the rules defined in the given input stream. The file should be a landSerf colour table file containing XML defining a set of colour rules. This can be created using the writeFile() method.

Parameters:
inStream - Name of file containing rules.
Returns:
Colour table created or null if problems creating table from file.

writeFile

public static boolean writeFile(ColourTable colourTable,
                                java.lang.String fileName)
Writes the given colour table out as a file using the given name. The file can be read back in using one of the readFile() methods.

Parameters:
colourTable - Colour table to be written.
fileName - Name of file to contain rules.
Returns:
True if file written successfully.

writeFile

public static boolean writeFile(ColourTable colourTable,
                                java.io.OutputStream outStream)
Writes the given colour table out as a file using the given output stream. The file can be read back in using one of the readFile() methods.

Parameters:
colourTable - Colour table to be written.
outStream - Output stream of the file to contain rules.
Returns:
True if file written successfully.


giCentre Utilities V.3.3, API documentation generated 6th April, 2013