Package org.esa.snap.core.datamodel
Class ColorPaletteDef
- java.lang.Object
-
- org.esa.snap.core.datamodel.ColorPaletteDef
-
- All Implemented Interfaces:
Cloneable
public class ColorPaletteDef extends Object implements Cloneable
TheColorPaletteDef
class represents a curve that is used to transform the sample values of a geo-physical band into color palette indexes.This special implementation of a gradation curve also provides separate color values for each of the tie points contained in the curve. This allows a better image interpretation because certain colors correspond to certain sample values even if the curve points are used to create color gradient palettes.
- Version:
- $Revision$ $Date$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColorPaletteDef.Point
-
Constructor Summary
Constructors Constructor Description ColorPaletteDef(double minSample, double maxSample)
ColorPaletteDef(double minSample, double centerSample, double maxSample)
ColorPaletteDef(ColorPaletteDef.Point[] points)
ColorPaletteDef(ColorPaletteDef.Point[] points, int numColors)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPoint(ColorPaletteDef.Point point)
Object
clone()
ColorPaletteDef
createDeepCopy()
boolean
createPointAfter(int index, Scaling scaling)
creates a new point between the point at the given indexvoid
dispose()
Releases all of the resources used by this color palette definition and all of its owned children.boolean
equals(Object o)
static Color
getCenterColor(Color c1, Color c2)
Creates the center color between the given two colors.Color[]
getColors()
ColorPaletteDef.Point
getFirstPoint()
Iterator
getIterator()
ColorPaletteDef.Point
getLastPoint()
double
getMaxDisplaySample()
double
getMinDisplaySample()
int
getNumColors()
int
getNumPoints()
ColorPaletteDef.Point
getPointAt(int index)
ColorPaletteDef.Point[]
getPoints()
double
getSourceFileMax()
double
getSourceFileMin()
int
hashCode()
void
insertPointAfter(int index, ColorPaletteDef.Point point)
boolean
isAutoDistribute()
boolean
isDiscrete()
boolean
isFullyOpaque()
boolean
isLogScaled()
static ColorPaletteDef
loadColorPaletteDef(File file)
Loads a color palette definition from the given filestatic ColorPaletteDef
loadColorPaletteDef(Path path)
Loads a color palette definition from the given file pathstatic ColorPaletteDef
loadCpt(File file)
Loads a color palette definition from the given cpt format filestatic ArrayList<String>
readFileIntoArrayList(File file)
void
removePointAt(int index)
void
setAutoDistribute(boolean autoDistribute)
void
setDiscrete(boolean discrete)
void
setLogScaled(boolean logScaled)
void
setNumColors(int numColors)
void
setNumPoints(int numPoints)
void
setPoints(ColorPaletteDef.Point[] points)
void
setSourceFileMax(double sourceFileMax)
void
setSourceFileMin(double sourceFileMin)
static void
storeColorPaletteDef(ColorPaletteDef colorPaletteDef, File file)
Stores this color palette definition in the given filestatic void
storeCpt(ColorPaletteDef colorPaletteDef, File file)
Stores color palette in cpt formatstatic void
storePal(ColorPaletteDef colorPaletteDef, File file)
Stores a 256 point generic color palettestatic Color
string2Color(String redString, String greenString, String blueString)
-
-
-
Constructor Detail
-
ColorPaletteDef
public ColorPaletteDef(double minSample, double maxSample)
-
ColorPaletteDef
public ColorPaletteDef(double minSample, double centerSample, double maxSample)
-
ColorPaletteDef
public ColorPaletteDef(ColorPaletteDef.Point[] points)
-
ColorPaletteDef
public ColorPaletteDef(ColorPaletteDef.Point[] points, int numColors)
-
-
Method Detail
-
isDiscrete
public boolean isDiscrete()
-
setDiscrete
public void setDiscrete(boolean discrete)
-
getNumColors
public int getNumColors()
-
setNumColors
public void setNumColors(int numColors)
-
getNumPoints
public int getNumPoints()
-
setNumPoints
public void setNumPoints(int numPoints)
-
isFullyOpaque
public boolean isFullyOpaque()
- Returns:
- true, if all the colors in the palette definitions are fully opaque.
- Since:
- SNAP 0.5
-
isAutoDistribute
public boolean isAutoDistribute()
-
setAutoDistribute
public void setAutoDistribute(boolean autoDistribute)
-
getPointAt
public ColorPaletteDef.Point getPointAt(int index)
-
getFirstPoint
public ColorPaletteDef.Point getFirstPoint()
-
getLastPoint
public ColorPaletteDef.Point getLastPoint()
-
getMinDisplaySample
public double getMinDisplaySample()
-
getMaxDisplaySample
public double getMaxDisplaySample()
-
insertPointAfter
public void insertPointAfter(int index, ColorPaletteDef.Point point)
-
createPointAfter
public boolean createPointAfter(int index, Scaling scaling)
creates a new point between the point at the given index- Parameters:
index
- the indexscaling
- the scaling- Returns:
- true, if a point has been inserted
-
getCenterColor
public static Color getCenterColor(Color c1, Color c2)
Creates the center color between the given two colors.- Parameters:
c1
- 1st colorc2
- 2nd color- Returns:
- the center color
-
removePointAt
public void removePointAt(int index)
-
addPoint
public void addPoint(ColorPaletteDef.Point point)
-
getPoints
public ColorPaletteDef.Point[] getPoints()
-
setPoints
public void setPoints(ColorPaletteDef.Point[] points)
-
getIterator
public Iterator getIterator()
-
createDeepCopy
public ColorPaletteDef createDeepCopy()
-
loadColorPaletteDef
public static ColorPaletteDef loadColorPaletteDef(File file) throws IOException
Loads a color palette definition from the given file- Parameters:
file
- the file- Returns:
- the color palette definition, never null
- Throws:
IOException
- if an I/O error occurs
-
loadColorPaletteDef
public static ColorPaletteDef loadColorPaletteDef(Path path) throws IOException
Loads a color palette definition from the given file path- Parameters:
path
- the file path- Returns:
- the color palette definition, never null
- Throws:
IOException
- if an I/O error occurs
-
loadCpt
public static ColorPaletteDef loadCpt(File file) throws IOException
Loads a color palette definition from the given cpt format file- Parameters:
file
- cpt format file- Returns:
- the color palette definition, never null
- Throws:
IOException
- if an I/O error occurs
-
string2Color
public static Color string2Color(String redString, String greenString, String blueString)
-
readFileIntoArrayList
public static ArrayList<String> readFileIntoArrayList(File file) throws IOException
- Throws:
IOException
-
storeColorPaletteDef
public static void storeColorPaletteDef(ColorPaletteDef colorPaletteDef, File file) throws IOException
Stores this color palette definition in the given file- Parameters:
colorPaletteDef
- thje color palette definitionfile
- the file- Throws:
IOException
- if an I/O error occurs
-
storePal
public static void storePal(ColorPaletteDef colorPaletteDef, File file) throws IOException
Stores a 256 point generic color palette- Parameters:
colorPaletteDef
- thje color palette definitionfile
- the file- Throws:
IOException
- if an I/O error occurs
-
storeCpt
public static void storeCpt(ColorPaletteDef colorPaletteDef, File file) throws IOException
Stores color palette in cpt format- Parameters:
colorPaletteDef
- the color palette definitionfile
- the file- Throws:
IOException
- if an I/O error occurs
-
dispose
public void dispose()
Releases all of the resources used by this color palette definition and all of its owned children. Its primary use is to allow the garbage collector to perform a vanilla job.This method should be called only if it is for sure that this object instance will never be used again. The results of referencing an instance of this class after a call to
dispose()
are undefined.Overrides of this method should always call
super.dispose();
after disposing this instance.
-
getColors
public Color[] getColors()
-
isLogScaled
public boolean isLogScaled()
-
setLogScaled
public void setLogScaled(boolean logScaled)
-
getSourceFileMin
public double getSourceFileMin()
-
setSourceFileMin
public void setSourceFileMin(double sourceFileMin)
-
getSourceFileMax
public double getSourceFileMax()
-
setSourceFileMax
public void setSourceFileMax(double sourceFileMax)
-
-