Class ColorMap.GradientND<T>

Type Parameters:
T - type of color object: String or MeshLambertMaterial for GWT and Color for JRE
Direct Known Subclasses:
ColorMap3D.GradientND, ColorMapCSS.GradientND
Enclosing class:
ColorMap<T>

public abstract static class ColorMap.GradientND<T> extends ColorMap.Gradient2D<T>
Color gradient for N dimensional data with one color for each dimension.
See Also:
  • Field Details

    • traits

      protected Color[] traits
      Reference to trait colors that provide the basis to generate gradient colors.
    • bg

      Color bg
      The background color. The default is black.
    • weights

      protected double[] weights
      Temporary variable to store the weights of each color component.
  • Constructor Details

    • GradientND

      public GradientND(Color[] colors)
      Construct N dimensional color gradient to represent N dimensional data values. Each dimension i spans colors ranging from black to colors[i].

      The default range for mapping data values onto the color gradient is [0.0, 1.0] in all dimensions.

      Parameters:
      colors - the colors for each dimension
      See Also:
    • GradientND

      public GradientND(Color[] colors, Color bg)
      Construct N dimensional color gradient to represent N dimensional data with a background color other than black, or, to represent N+1 dimensional data values where one data value is dependent on the other N.

      The color gradient in each dimension i ranges from bg to colors[i].

      The default range for mapping data values onto the color gradient is [0.0, 1.0] in all dimensions.

      Parameters:
      colors - the colors for the N dimensions
      bg - the color representing the background (or an N+1, dependent trait)
      See Also:
    • GradientND

      public GradientND(Color[] colors, int idx)
      Construct N dimensional color gradient to represent N+1 dimensional data values where one data value is dependent on the other two. This applies, for example, to data based on the replicator equation and dynamics that unfold on the simplex SN.

      The index of the dependent trait is idx. It is at its maximum if all other traits are at their minimum. The color gradient in each dimension i ranges from colors[idx] to colors[i] for idx≠i.

      The default range for mapping data values onto the color gradient is [0.0, 1.0] in all dimensions.

      Parameters:
      colors - the colors for the N dimensions
      idx - the index of the dependent trait
      See Also:
    • GradientND

      protected GradientND(int dim)
      For internal use only. Allocates memory and sets the default range for mapping data values onto the color gradient to [0.0, 1.0] in every dimension.
      Parameters:
      dim - the dimension of the gradient colors
      See Also:
  • Method Details

    • translate

      public boolean translate(double[] data, T[] color)
      Translate the data array of double values to colors and store the results in the color array. The type of the color array depends on the implementation.

      Note: whether data refers to a single or multiple traits is up to the implementation to decide. For example, CXPopulation stores multiple traits in a linear array.

      Implementation:

      1. Two subsequent entries, data[n] and data[n+1] are converted to the corresponding gradient colors. This applies, for example, to data from continuous games with multiple traits. The gradient colors are returned in the color array.
      2. For performance reasons no validity checks on data. In particular, all data entries must lie inside the range for mapping data values.

      Implementation:

      1. N subsequent entries, data[n] through data[n+N], are converted to gradient colors on the fly. This applies, for example, to data from continuous games with N traits. The gradient colors are returned in the color array.
      2. For performance reasons no validity checks on data. In particular, all data entries must lie inside the range for mapping data values.
      Overrides:
      translate in class ColorMap.Gradient2D<T>
      Parameters:
      data - the double[] array to convert to colors
      color - the array for the resulting colors
      Returns:
      true if translation successful
      See Also:
    • translate

      public boolean translate(double[][] data, T[] color)
      Translate the data array of double[] multi-trait values to colors and store the results in the color array. The type of the color array depends on the implementation.

      Implementation:

      1. Each entry in data represents a multi-dimensional trait value, which is converted to the corresponding gradient color and returned in the color array. An example are trait densities in PDE models.
      2. For performance reasons no validity checks on data. In particular, all data entries must lie inside the range for mapping data values.

      Implementation:

      1. Each entry in data represents a N-dimensional trait value, which is converted to gradient colors on the fly and returned in the color array. An example are trait densities in PDE models.
      2. For performance reasons no validity checks on data. In particular, all data entries must lie inside the range for mapping data values.
      Overrides:
      translate in class ColorMap.Gradient2D<T>
      Parameters:
      data - the double[][] array to convert to colors
      color - the array for the resulting colors
      Returns:
      true if translation successful
      See Also:
    • toGradient1D

      public abstract ColorMap.Gradient1D<T> toGradient1D(int nIncr)
      Convert the N-dimensional color map into a 1D gradient with a total of nIncr shades. This is useful for coloring schemes that are based on an aggregate characteristics, such as the distance, instead of the N-dimensional data.
      Parameters:
      nIncr - the total number of color increments
      Returns:
      the 1D color gradient