Class ColorPaletteDef

java.lang.Object
org.esa.snap.core.datamodel.ColorPaletteDef
All Implemented Interfaces:
Cloneable

public class ColorPaletteDef extends Object implements Cloneable
The ColorPaletteDef 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$
  • Constructor Details

    • 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 Details

    • 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 index
      scaling - 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 color
      c2 - 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()
    • clone

      public final Object clone()
      Overrides:
      clone in class Object
    • createDeepCopy

      @Deprecated public ColorPaletteDef createDeepCopy()
      Deprecated.
    • loadColorPaletteDef

      @Deprecated public static ColorPaletteDef loadColorPaletteDef(File file) throws IOException
      Deprecated.
      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

      @Deprecated public static void storeColorPaletteDef(ColorPaletteDef colorPaletteDef, File file) throws IOException
      Deprecated.
      Stores this color palette definition in the given file
      Parameters:
      colorPaletteDef - thje color palette definition
      file - the file
      Throws:
      IOException - if an I/O error occurs
    • storeColorPaletteDef

      public static void storeColorPaletteDef(ColorPaletteDef colorPaletteDef, Path path) throws IOException
      Throws:
      IOException
    • storePal

      public static void storePal(ColorPaletteDef colorPaletteDef, File file) throws IOException
      Stores a 256 point generic color palette
      Parameters:
      colorPaletteDef - the color palette definition
      file - 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 definition
      file - 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()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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)