comparison flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 4593:047c965ea542

Use floating point calculation for floodmap colors.
author Christian Lins <christian.lins@intevation.de>
date Fri, 30 Nov 2012 11:32:29 +0100
parents 11545c3b9111
children fc52ee878412
comparison
equal deleted inserted replaced
4592:11545c3b9111 4593:047c965ea542
638 } 638 }
639 else if (numClasses > 20) { 639 else if (numClasses > 20) {
640 numClasses = 20; 640 numClasses = 20;
641 } 641 }
642 642
643 int rd = (endColor.getRed() - startColor.getRed()) / numClasses; 643 float rd = (endColor.getRed() - startColor.getRed()) / (float)numClasses;
644 int gd = (endColor.getGreen() - startColor.getGreen()) / numClasses; 644 float gd = (endColor.getGreen() - startColor.getGreen()) / (float)numClasses;
645 int bd = (endColor.getBlue() - startColor.getBlue()) / numClasses; 645 float bd = (endColor.getBlue() - startColor.getBlue()) / (float)numClasses;
646 646
647 for (int n = 0; n < numClasses; n++) { 647 for (int n = 0; n < numClasses; n++) {
648 StringBuilder newColor = new StringBuilder(); 648 StringBuilder newColor = new StringBuilder();
649 newColor.append(startColor.getRed() + n * rd); 649 newColor.append(startColor.getRed() + Math.round(n * rd));
650 newColor.append(' '); 650 newColor.append(' ');
651 newColor.append(startColor.getGreen() + n * gd); 651 newColor.append(startColor.getGreen() + Math.round(n * gd));
652 newColor.append(' '); 652 newColor.append(' ');
653 newColor.append(startColor.getBlue() + n * bd); 653 newColor.append(startColor.getBlue() + Math.round(n * bd));
654 654
655 String expr = createWSPLGENExpression(n + 1, numClasses); 655 String expr = createWSPLGENExpression(n + 1, numClasses);
656 656
657 Clazz c = new Clazz(expr); 657 Clazz c = new Clazz(expr);
658 Style s = new Style(); 658 Style s = new Style();

http://dive4elements.wald.intevation.org