Class ColorMapper

java.lang.Object
sc.fiji.snt.analysis.ColorMapper
Direct Known Subclasses:
AnnotationMapper, GraphColorMapper, NodeColorMapper, TreeColorMapper

public class ColorMapper extends Object
Parent class for ColorMappers.
Author:
Tiago Ferreira
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected net.imglib2.display.ColorTable
     
    protected boolean
     
    protected Map<String,URL>
     
    protected net.imagej.lut.LUTService
     
    protected double
     
    protected double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getColor(double mappedValue)
    Gets the color corresponding to the specified mapped value.
    org.scijava.util.ColorRGB
    getColorRGB(double mappedValue)
    Gets the color corresponding to the specified mapped value as ColorRGB.
    net.imglib2.display.ColorTable
    Gets the current color table used for mapping.
    double[]
    Returns the mapping bounds
    Gets the color used for NaN (Not a Number) values.
    protected void
     
    boolean
    Checks if the color mapping uses an integer scale.
    void
    map(String measurement, net.imglib2.display.ColorTable colorTable)
    Sets up the color mapping for the specified measurement using the given color table.
    void
    setMinMax(double min, double max)
    Sets the LUT mapping bounds.
    void
    setNaNColor(Color nanColor)
    Sets the color to use for NaN (Not a Number) values.
    static void
    Removes color mapping from the specified collection of paths.
    static void
    unMap(Tree tree)
    Removes color mapping from all paths in the specified tree.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lutService

      protected net.imagej.lut.LUTService lutService
    • luts

      protected Map<String,URL> luts
    • colorTable

      protected net.imglib2.display.ColorTable colorTable
    • integerScale

      protected boolean integerScale
    • min

      protected double min
    • max

      protected double max
  • Constructor Details

    • ColorMapper

      public ColorMapper()
  • Method Details

    • map

      public void map(String measurement, net.imglib2.display.ColorTable colorTable)
      Sets up the color mapping for the specified measurement using the given color table.

      This method configures the ColorMapper to use the specified measurement and color table for mapping values to colors. The actual mapping implementation is left to extending classes.

      Parameters:
      measurement - the measurement to be mapped
      colorTable - the color table to use for mapping
      Throws:
      IllegalArgumentException - if colorTable or measurement is null
    • getNaNColor

      public Color getNaNColor()
      Gets the color used for NaN (Not a Number) values.

      Returns the color that will be used when mapping NaN values, which cannot be mapped to the regular color scale.

      Returns:
      the color for NaN values
    • setNaNColor

      public void setNaNColor(Color nanColor)
      Sets the color to use for NaN (Not a Number) values.

      Specifies the color that should be used when mapping NaN values, which cannot be mapped to the regular color scale.

      Parameters:
      nanColor - the color to use for NaN values
    • getColor

      public Color getColor(double mappedValue)
      Gets the color corresponding to the specified mapped value.

      Maps the given value to a color using the current color table and mapping bounds. Returns the NaN color if the value is NaN.

      Parameters:
      mappedValue - the value to map to a color
      Returns:
      the corresponding color
    • getColorRGB

      public org.scijava.util.ColorRGB getColorRGB(double mappedValue)
      Gets the color corresponding to the specified mapped value as ColorRGB.
      Parameters:
      mappedValue - the value to map to a color
      Returns:
      the corresponding ColorRGB
      See Also:
    • setMinMax

      public void setMinMax(double min, double max)
      Sets the LUT mapping bounds.
      Parameters:
      min - the mapping lower bound (i.e., the highest measurement value for the LUT scale). It is automatically calculated (the default) when set to Double.NaN
      max - the mapping upper bound (i.e., the highest measurement value for the LUT scale).It is automatically calculated (the default) when set to Double.NaN.
    • isIntegerScale

      public boolean isIntegerScale()
      Checks if the color mapping uses an integer scale.

      Returns true if the mapping is configured to use discrete integer values rather than continuous floating-point values.

      Returns:
      true if using integer scale, false for continuous scale
    • getMinMax

      public double[] getMinMax()
      Returns the mapping bounds
      Returns:
      a two-element array with current {minimum, maximum} mapping bounds
    • getColorTable

      public net.imglib2.display.ColorTable getColorTable()
      Gets the current color table used for mapping.

      Returns the ColorTable instance that defines the color mapping from values to colors.

      Returns:
      the current color table
    • initLuts

      protected void initLuts()
    • unMap

      public static void unMap(Tree tree)
      Removes color mapping from all paths in the specified tree.

      Resets the color of all paths in the tree to their default state, effectively removing any color mapping that was previously applied.

      Parameters:
      tree - the tree whose paths should have color mapping removed
    • unMap

      public static void unMap(Collection<Path> paths)
      Removes color mapping from the specified collection of paths.

      Resets the color of all paths in the collection to their default state, effectively removing any color mapping that was previously applied. This includes both path-level and node-level color assignments.

      Parameters:
      paths - the collection of paths to have color mapping removed