[Dive4elements-commits] [PATCH] Use floating point calculation for floodmap colors
Wald Commits
scm-commit at wald.intevation.org
Fri Nov 30 11:32:36 CET 2012
# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1354271549 -3600
# Node ID 047c965ea5423c30e64ea3d6dd673f6948d903b6
# Parent 11545c3b9111288a768be46a769dea86bf42df7a
Use floating point calculation for floodmap colors.
diff -r 11545c3b9111 -r 047c965ea542 flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Thu Nov 29 15:34:33 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Fri Nov 30 11:32:29 2012 +0100
@@ -640,17 +640,17 @@
numClasses = 20;
}
- int rd = (endColor.getRed() - startColor.getRed()) / numClasses;
- int gd = (endColor.getGreen() - startColor.getGreen()) / numClasses;
- int bd = (endColor.getBlue() - startColor.getBlue()) / numClasses;
+ float rd = (endColor.getRed() - startColor.getRed()) / (float)numClasses;
+ float gd = (endColor.getGreen() - startColor.getGreen()) / (float)numClasses;
+ float bd = (endColor.getBlue() - startColor.getBlue()) / (float)numClasses;
for (int n = 0; n < numClasses; n++) {
StringBuilder newColor = new StringBuilder();
- newColor.append(startColor.getRed() + n * rd);
+ newColor.append(startColor.getRed() + Math.round(n * rd));
newColor.append(' ');
- newColor.append(startColor.getGreen() + n * gd);
+ newColor.append(startColor.getGreen() + Math.round(n * gd));
newColor.append(' ');
- newColor.append(startColor.getBlue() + n * bd);
+ newColor.append(startColor.getBlue() + Math.round(n * bd));
String expr = createWSPLGENExpression(n + 1, numClasses);
More information about the Dive4elements-commits
mailing list