code: public Color getColorFor( double value ) {
          if (value <= min) {
              return colors[0];
          } else if (value >= max) {
              return colors[colors.length - 1];
          } else {
              for( int i = 1; i < colors.length; i++ ) {
                  double v1 = values[i - 1];
                  double v2 = values[i];
                  if (value < v2) {
  
                      double v = (value - v1) / (v2 - v1);
                      Color interpolateColor = interpolateColor(colors[i - 1], colors[i], (float) v);
                      return interpolateColor;
                  }
              }
              return colors[colors.length - 1];
          }
      }
docs: Get the color of the defined table by its value.
  
  @param value the value.
  @return the interpolated color.