comparison artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java @ 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 e4606eae8ea5
children c421c9530aba
comparison
equal deleted inserted replaced
8443:df65f24af5bc 8444:666ac28a0256
658 Color endColor = strEndColor != null 658 Color endColor = strEndColor != null
659 ? parseColor(strEndColor) 659 ? parseColor(strEndColor)
660 : new Color(2, 27, 42); 660 : new Color(2, 27, 42);
661 661
662 to = to >= 0 ? to : 9999; 662 to = to >= 0 ? to : 9999;
663 step = step != 0 ? step : to; 663 step = to != from ? step : 1;
664 664
665 int numClasses = (int)((to - from) / step); 665 int numClasses = (int)((to - from) / step + 1);
666 666
667 float rd = (endColor.getRed() - startColor.getRed()) / (float)numClasses; 667 float rd = (endColor.getRed() - startColor.getRed()) / (float)numClasses;
668 float gd = (endColor.getGreen() - startColor.getGreen()) / (float)numClasses; 668 float gd = (endColor.getGreen() - startColor.getGreen()) / (float)numClasses;
669 float bd = (endColor.getBlue() - startColor.getBlue()) / (float)numClasses; 669 float bd = (endColor.getBlue() - startColor.getBlue()) / (float)numClasses;
670
671 if (numClasses > 1) {
672 // Desktop Flys always added a last "and larger class"
673 numClasses += 1;
674 }
675 670
676 for (int n = 0; n < numClasses; n++) { 671 for (int n = 0; n < numClasses; n++) {
677 StringBuilder newColor = new StringBuilder(); 672 StringBuilder newColor = new StringBuilder();
678 newColor.append(startColor.getRed() + Math.round(n * rd)); 673 newColor.append(startColor.getRed() + Math.round(n * rd));
679 newColor.append(' '); 674 newColor.append(' ');

http://dive4elements.wald.intevation.org