Class Gradient

  • All Implemented Interfaces:

    
    public final class Gradient
    
                        

    A class to generate a color map from a given array of colors and the fractions that the colors represent by interpolating between their HSV values. This color map is to be used in the HeatmapTileProvider.

    • Constructor Detail

      • Gradient

        Gradient(IntArray colors, FloatArray startPoints, Integer colorMapSize)
        Parameters:
        colors - The colors to be used in the gradient.
        startPoints - The starting point for each color, given as a percentage of the maximum intensity.
        colorMapSize - The size of the colorMap to be generated by the Gradient.
      • Gradient

        Gradient(IntArray colors, FloatArray startPoints)
        Parameters:
        colors - The colors to be used in the gradient.
        startPoints - The starting point for each color, given as a percentage of the maximum intensity.
    • Method Detail

      • generateColorMap

        @JvmOverloads() final IntArray generateColorMap(Double opacity)

        Generates a color map array from the gradient's colors and start points. This map is a key component for rendering the heatmap, where each color corresponds to a different intensity level.

        The process involves interpolating between the specified colors in the HSV color space to create a smooth transition.

        Parameters:
        opacity - The overall opacity of the entire color map.
        Returns:

        An integer array representing the color map, where each element is a color integer.

      • generateColorMap

        @JvmOverloads() final IntArray generateColorMap()

        Generates a color map array from the gradient's colors and start points. This map is a key component for rendering the heatmap, where each color corresponds to a different intensity level.

        The process involves interpolating between the specified colors in the HSV color space to create a smooth transition.

        Returns:

        An integer array representing the color map, where each element is a color integer.

      • interpolateColor

         final static Integer interpolateColor(Integer color1, Integer color2, Float ratio)

        Helper function for creation of color map. Interpolates between two given colors using their HSV values.

        Parameters:
        color1 - First color
        color2 - Second color
        ratio - Between 0 to 1.
        Returns:

        Color associated with x2