net.refractions.udig.ui.palette
Class ColourScheme

java.lang.Object
  extended by net.refractions.udig.ui.palette.ColourScheme

public class ColourScheme
extends java.lang.Object

A colour scheme remaps the colours in a palette.

Author:
ptozer, chorner

Constructor Summary
ColourScheme(BrewerPalette palette, java.util.HashMap<java.lang.Integer,java.lang.Integer> colourMap, java.util.HashMap<java.lang.String,java.lang.Integer> idMap, int itemSize, int paletteSize)
           
ColourScheme(BrewerPalette palette, int itemSize)
           
ColourScheme(BrewerPalette palette, int itemSize, int paletteSize)
           
 
Method Summary
 java.awt.Color addItem()
           
 void addItem(java.awt.Color color)
          Add an item to the scheme, and modify the palette to contain this colour.
 java.awt.Color addItem(java.lang.String id)
           
 boolean alignScheme(java.util.List<java.awt.Color> colours)
           
 boolean equals(java.lang.Object other)
           
 java.awt.Color[] getAllColours()
           
 boolean getAutoSizing()
           
 java.awt.Color getColour(int index)
           
 java.util.HashMap<java.lang.Integer,java.lang.Integer> getColourMap()
           
 BrewerPalette getColourPalette()
           
static ColourScheme getDefault(BrewerPalette palette)
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getIdMap()
           
 int getMinColours()
           
 java.awt.Color getNextAvailableColour(java.util.List<java.awt.Color> colours)
          Returns the next available colour.
 int getSizePalette()
          Gets the number of colours currently available in the palette.
 int getSizeScheme()
          Gets the number of classes utilizing this scheme.
 int hashCode()
           
 int indexOf(java.lang.String id)
           
 boolean removeItem(int index)
           
 boolean removeItem(java.lang.String id)
           
 boolean removeItem(java.lang.String id, java.awt.Color colour)
           
 void setAutoSizing(boolean auto)
          Sets the behaviour of the colour scheme as items are added.
 void setColourMap(java.util.HashMap<java.lang.Integer,java.lang.Integer> colourMap)
           
 void setColourPalette(BrewerPalette palette)
           
 void setSizePalette(int numColours)
          Sets the number of colours to use from the current palette.
 void setSizeScheme(int numItems)
          Set the number of items this scheme is used by.
 void swapColours(int firstIndex, int secondIndex)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColourScheme

public ColourScheme(BrewerPalette palette,
                    int itemSize)

ColourScheme

public ColourScheme(BrewerPalette palette,
                    int itemSize,
                    int paletteSize)

ColourScheme

public ColourScheme(BrewerPalette palette,
                    java.util.HashMap<java.lang.Integer,java.lang.Integer> colourMap,
                    java.util.HashMap<java.lang.String,java.lang.Integer> idMap,
                    int itemSize,
                    int paletteSize)
Method Detail

getDefault

public static ColourScheme getDefault(BrewerPalette palette)

setColourPalette

public void setColourPalette(BrewerPalette palette)

getAutoSizing

public boolean getAutoSizing()

setAutoSizing

public void setAutoSizing(boolean auto)
Sets the behaviour of the colour scheme as items are added. If true, the palette will morph in size as items are added or removed. If false, the palette will remain static and scheme colours will be repeated even if some are unused.

Parameters:
auto - boolean

setSizeScheme

public void setSizeScheme(int numItems)
Set the number of items this scheme is used by. The size of the palette is automatically adjusted to fit.

Parameters:
numItems - the number of items obtaining colours from this scheme

setSizePalette

public void setSizePalette(int numColours)
Sets the number of colours to use from the current palette. This method checks to ensure the number of colours does not exceed the size of the palette.

Parameters:
numColours -

getMinColours

public int getMinColours()

getSizePalette

public int getSizePalette()
Gets the number of colours currently available in the palette.

Returns:

getSizeScheme

public int getSizeScheme()
Gets the number of classes utilizing this scheme.

Returns:

alignScheme

public boolean alignScheme(java.util.List<java.awt.Color> colours)

getNextAvailableColour

public java.awt.Color getNextAvailableColour(java.util.List<java.awt.Color> colours)
Returns the next available colour. Good for comparing reality to what we think we have.

Parameters:
colours -
Returns:

getColour

public java.awt.Color getColour(int index)

getAllColours

public java.awt.Color[] getAllColours()
Returns:
Returns all the available colours, without duplicates.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getColourPalette

public BrewerPalette getColourPalette()

getColourMap

public java.util.HashMap<java.lang.Integer,java.lang.Integer> getColourMap()

getIdMap

public java.util.HashMap<java.lang.String,java.lang.Integer> getIdMap()

setColourMap

public void setColourMap(java.util.HashMap<java.lang.Integer,java.lang.Integer> colourMap)

swapColours

public void swapColours(int firstIndex,
                        int secondIndex)

addItem

public java.awt.Color addItem()

addItem

public java.awt.Color addItem(java.lang.String id)

addItem

public void addItem(java.awt.Color color)
Add an item to the scheme, and modify the palette to contain this colour.

Parameters:
color -

indexOf

public int indexOf(java.lang.String id)

removeItem

public boolean removeItem(java.lang.String id)

removeItem

public boolean removeItem(java.lang.String id,
                          java.awt.Color colour)

removeItem

public boolean removeItem(int index)