[PATCH] 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

Wald Commits scm-commit at wald.intevation.org
Fri Oct 24 11:54:35 CEST 2014


# HG changeset patch
# User "Tom Gottfried <tom at intevation.de>"
# Date 1414144470 -7200
# Node ID 666ac28a0256ea553af7cea7d7c01fff3a811eec
# Parent  df65f24af5bc43c9a5c16da5bfd108385316ff9a
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.

diff -r df65f24af5bc -r 666ac28a0256 artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java
--- 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));


More information about the Dive4Elements-commits mailing list