Class ColorMaps

java.lang.Object
io.deephaven.plot.colors.ColorMaps
All Implemented Interfaces:
Serializable

public class ColorMaps
extends Object
implements Serializable
Functions for mapping between values and Colors or Paints.
See Also:
Serialized Form
  • Method Details

    • heatMap

      public static Function<Double,​Color> heatMap​(double min, double max)
      Returns a heat map to map numerical values to colors.

      Values less than or equal to min return the starting color. Values greater than or equal to max return the ending color. Values in between this range are a linear combination of the RGB components of these two colors. Higher values return colors that are closer to the ending color, and lower values return colors that are closer to the starting color.

      Inputs that are null or Double.NaN return a null color.

      Parameters:
      min - minimum
      max - maximum
      Returns:
      function for mapping double values to colors. The starting color is blue (#0000FF) and the ending color is yellow (#FFFF00).
    • heatMap

      public static Function<Double,​Color> heatMap​(double min, double max, Color startColor, Color endColor)
      Returns a heat map to map numerical values to colors.

      Values less than or equal to min return the starting color. Values greater than or equal to max return the ending color. Values in between this range are a linear combination of the RGB components of these two colors. Higher values return colors that are closer to the ending color, and lower values return colors that are closer to the starting color.

      Inputs that are null or Double.NaN return a null color.

      Parameters:
      min - minimum
      max - maximum
      startColor - color at values less than or equal to min
      endColor - color at values greater than or equal to max
      Returns:
      function for mapping double values to colors
    • heatMap

      public static Function<Double,​Color> heatMap​(double min, double max, Color startColor, Color endColor, Color nullColor)
      Returns a heat map to map numerical values to colors.

      Values less than or equal to min return the starting color. Values greater than or equal to max return the ending color. Values in between this range are a linear combination of the RGB components of these two colors. Higher values return colors that are closer to the ending color, and lower values return colors that are closer to the starting color.

      Inputs that are null or Double.NaN return a null color.

      Parameters:
      min - minimum
      max - maximum
      startColor - color at values less than or equal to min
      endColor - color at values greater than or equal to max
      nullColor - color at null input values
      Returns:
      function for mapping double values to colors
    • rangeMap

      public static <COLOR extends Paint> Function<Double,​Paint> rangeMap​(Map<Range,​COLOR> map)
      Maps Ranges of values to specific colors. Values inside a given Range return the corresponding Paint.

      Values not in any of the specified Range return an out of range color. Null inputs return a null color.

      Type Parameters:
      COLOR - type of Paint in the map
      Parameters:
      map - map of Ranges to Paints.
      Returns:
      function for mapping double values to colors. Null and out of range values return null.
    • rangeMap

      public static <COLOR extends Paint> Function<Double,​Paint> rangeMap​(Map<Range,​COLOR> map, Color outOfRangeColor)
      Maps Ranges of values to specific colors. Values inside a given Range return the corresponding Paint.

      Values not in any of the specified Range return an out of range color. Null inputs return a null color.

      Type Parameters:
      COLOR - type of Paint in the map
      Parameters:
      map - map of Ranges to Paints.
      outOfRangeColor - color for values not within any of the defined ranges
      Returns:
      function for mapping double values to colors. Null values return null.
    • rangeMap

      public static <COLOR extends Paint> Function<Double,​Paint> rangeMap​(Map<Range,​COLOR> map, Paint outOfRangeColor, Paint nullColor)
      Maps Ranges of values to specific colors. Values inside a given Range return the corresponding Paint.

      Values not in any of the specified Range return an out of range color. Null inputs return a null color.

      Type Parameters:
      COLOR - type of Paint in the map
      Parameters:
      map - map of Ranges to Paints.
      outOfRangeColor - color for values not within any of the defined ranges
      nullColor - color for null values
      Returns:
      function for mapping double values to colors
    • predicateMap

      public static <COLOR extends Paint> Function<Double,​Paint> predicateMap​(Map<ColorMaps.SerializablePredicate<Double>,​COLOR> map)
      Returns a function which uses predicate functions to determine which colors is returned for an input value. For each input value, a map is iterated through until the predicate function (map key) returns true. When the predicate returns true, the associated color (map value) is returned. If no such predicate is found, an out of range color is returned.
      Type Parameters:
      COLOR - type of Paint in map
      Parameters:
      map - map from ColorMaps.SerializablePredicate to color
      Returns:
      function which returns the color mapped to the first ColorMaps.SerializablePredicate for which the input is true. Out of range, null, and NaN values return null.
    • predicateMap

      public static <COLOR extends Paint> Function<Double,​Paint> predicateMap​(Map<ColorMaps.SerializablePredicate<Double>,​COLOR> map, Color outOfRangeColor)
      Returns a function which uses predicate functions to determine which colors is returned for an input value. For each input value, a map is iterated through until the predicate function (map key) returns true. When the predicate returns true, the associated color (map value) is returned. If no such predicate is found, an out of range color is returned.
      Type Parameters:
      COLOR - type of Paint in map
      Parameters:
      map - map from ColorMaps.SerializablePredicate to color
      outOfRangeColor - color returned when the input satisfies no ColorMaps.SerializablePredicate in the map
      Returns:
      function which returns the color mapped to the first ColorMaps.SerializablePredicate for which the input is true. Null and NaN inputs return null.
    • predicateMap

      public static <COLOR extends Paint> Function<Double,​Paint> predicateMap​(Map<ColorMaps.SerializablePredicate<Double>,​COLOR> map, Paint outOfRangeColor, Paint nullColor)
      Returns a function which uses predicate functions to determine which colors is returned for an input value. For each input value, a map is iterated through until the predicate function (map key) returns true. When the predicate returns true, the associated color (map value) is returned. If no such predicate is found, an out of range color is returned.
      Type Parameters:
      COLOR - type of Paint in map
      Parameters:
      map - map from ColorMaps.SerializablePredicate to color
      outOfRangeColor - color returned when the input satisfies no ColorMaps.SerializablePredicate in the map
      nullColor - color returned when the input is null or Double.NaN
      Returns:
      function which returns the color mapped to the first ColorMaps.SerializablePredicate for which the input is true
    • closureMap

      public static <COLOR extends Paint> Function<Double,​Paint> closureMap​(Map<groovy.lang.Closure<Boolean>,​COLOR> map)
      Returns a function which uses closure functions to determine which colors is returned for an input value. For each input value, a map is iterated through until the closure function (map key) returns true. When the closure returns true, the associated color (map value) is returned. If no such closure is found, an out of range color is returned.
      Type Parameters:
      COLOR - type of Paint in map
      Parameters:
      map - map from Closure to color
      Returns:
      function which returns the color mapped to the first Closure for which the input is true. Out of range, null, and NaN inputs return null.
    • closureMap

      public static <COLOR extends Paint> Function<Double,​Paint> closureMap​(Map<groovy.lang.Closure<Boolean>,​COLOR> map, Color outOfRangeColor)
      Returns a function which uses closure functions to determine which colors is returned for an input value. For each input value, a map is iterated through until the closure function (map key) returns true. When the closure returns true, the associated color (map value) is returned. If no such closure is found, an out of range color is returned.
      Type Parameters:
      COLOR - type of Paint in map
      Parameters:
      map - map from Closure to color
      outOfRangeColor - color returned when the input satisfies no Closure in the map
      Returns:
      function which returns the color mapped to the first Closure for which the input is true. Null and NaN inputs return null.
    • closureMap

      public static <COLOR extends Paint> Function<Double,​Paint> closureMap​(Map<groovy.lang.Closure<Boolean>,​COLOR> map, Paint outOfRangeColor, Paint nullColor)
      Returns a function which uses closure functions to determine which colors is returned for an input value. For each input value, a map is iterated through until the closure function (map key) returns true. When the closure returns true, the associated color (map value) is returned. If no such closure is found, an out of range color is returned.
      Type Parameters:
      COLOR - type of Paint in map
      Parameters:
      map - map from Closure to color
      outOfRangeColor - color returned when the input satisfies no Closure in the map
      nullColor - color returned when the input is null or Double.NaN
      Returns:
      function which returns the color mapped to the first Closure for which the input is true