changeset 8444:666ac28a0256

In case to equals from, and only in this case, there should be only one class. Then we have to set an arbitrary value > 0 for step because the user is allowed to give step=0.
author "Tom Gottfried <tom@intevation.de>"
date Fri, 24 Oct 2014 11:54:30 +0200
parents df65f24af5bc
children fe43340352bc
files artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java
diffstat 1 files changed, 2 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java	Wed Oct 22 17:33:43 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java	Fri Oct 24 11:54:30 2014 +0200
@@ -660,19 +660,14 @@
             : new Color(2, 27, 42);
 
         to = to >= 0 ? to : 9999;
-        step = step != 0 ? step : to;
+        step = to != from ? step : 1;
 
-        int numClasses = (int)((to - from) / step);
+        int numClasses = (int)((to - from) / step + 1);
 
         float rd = (endColor.getRed()   - startColor.getRed())   / (float)numClasses;
         float gd = (endColor.getGreen() - startColor.getGreen()) / (float)numClasses;
         float bd = (endColor.getBlue()  - startColor.getBlue())  / (float)numClasses;
 
-        if (numClasses > 1) {
-            // Desktop Flys always added a last "and larger class"
-            numClasses += 1;
-        }
-
         for (int n = 0; n < numClasses; n++) {
             StringBuilder newColor = new StringBuilder();
             newColor.append(startColor.getRed()   + Math.round(n * rd));

http://dive4elements.wald.intevation.org