Class ColourPalette
- java.lang.Object
-
- uk.ac.rdg.resc.edal.graphics.utils.ColourPalette
-
public class ColourPalette extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_PALETTE_NAMEThe name of the default palette that will be used if the user doesn't request a specific palette.static StringINVERSE_SUFFIXstatic intMAX_NUM_COLOURS
-
Constructor Summary
Constructors Constructor Description ColourPalette(Color[] palette, int numColorBands)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddPaletteDirectory(File paletteDir)static ColourPalettefromString(String paletteString, int nColourBands)Gets aColourPalettefrom a string representation of itColorgetColor(float value)Gets the colour corresponding to a fractional point along the palettestatic Set<String>getPredefinedPalettes()static booleansetDefaultPalette(String paletteStr)Overrides the default palette
-
-
-
Field Detail
-
DEFAULT_PALETTE_NAME
public static final String DEFAULT_PALETTE_NAME
The name of the default palette that will be used if the user doesn't request a specific palette.- See Also:
DEFAULT_COLOURS, Constant Field Values
-
MAX_NUM_COLOURS
public static final int MAX_NUM_COLOURS
- See Also:
- Constant Field Values
-
INVERSE_SUFFIX
public static final String INVERSE_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ColourPalette
public ColourPalette(Color[] palette, int numColorBands)
-
-
Method Detail
-
setDefaultPalette
public static boolean setDefaultPalette(String paletteStr)
Overrides the default palette- Parameters:
paletteStr- The palette (pre-defined or otherwise) to use as the default- Returns:
- Whether or not the operation was successful.
-
addPaletteDirectory
public static void addPaletteDirectory(File paletteDir) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getColor
public Color getColor(float value)
Gets the colour corresponding to a fractional point along the palette- Parameters:
value- The fraction along the palette of the colour- Returns:
- The desired colour
-
fromString
public static ColourPalette fromString(String paletteString, int nColourBands)
Gets aColourPalettefrom a string representation of it- Parameters:
paletteString- Either the name of a predefined palette, or a string defining a palette. This is a comma, colon, or newline separated list of colours (seeGraphicsUtils.parseColour(String)for valid colour formats)nColourBands- The number of colour bands to use in the palette.- Returns:
- The desired
ColourPalette
-
-