- RGBIntensity intensity = getIntensities().get(i);
- return new Color((float)intensity.getRed(), (float)intensity.getGreen(), (float)intensity.getBlue());
+ RGBIntensity intensity = intensities.get(i);
+ if (useGradient) {
+
+ RGBIntensity upperLimitIntensity;
+ if (i + 1 != intensities.size())
+ upperLimitIntensity = intensities.get(i + 1);
+ else
+ upperLimitIntensity = intensity;
+
+ double minRed = intensity.getRed();
+ double minGreen = intensity.getGreen();
+ double minBlue = intensity.getBlue();
+
+ double maxRed = upperLimitIntensity.getRed();
+ double maxGreen = upperLimitIntensity.getGreen();
+ double maxBlue = upperLimitIntensity.getBlue();
+
+ double delta = Math.max(value - (defaultMin + singleGap * i), 0);
+
+ double d = delta / singleGap;
+
+ double redDelta = (maxRed - minRed) * d;
+ double greenDelta = (maxGreen - minGreen) * d;
+ double blueDelta = (maxBlue - minBlue) * d;
+ return new Color((float)(minRed + redDelta), (float)(minGreen + greenDelta), (float)(minBlue + blueDelta));
+ } else {
+ return new Color((float)intensity.getRed(), (float)intensity.getGreen(), (float)intensity.getBlue());
+ }