Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 4578:8304f982984f
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 27 Nov 2012 15:59:26 +0100 |
parents | 1c6c2ddac3d6 |
children | 11545c3b9111 |
comparison
equal
deleted
inserted
replaced
4576:a46dc120afd7 | 4578:8304f982984f |
---|---|
114 public final static String XPATH_SHOW_MAXIMUM = | 114 public final static String XPATH_SHOW_MAXIMUM = |
115 "/theme/field[@name='showmaximum']/@default"; | 115 "/theme/field[@name='showmaximum']/@default"; |
116 | 116 |
117 public final static String XPATH_WSPLGEN_FIELDS = | 117 public final static String XPATH_WSPLGEN_FIELDS = |
118 "/theme[@name='WSPLGEN']/field"; | 118 "/theme[@name='WSPLGEN']/field"; |
119 | |
120 public final static String XPATH_WSPLGEN_STARTCOLOR = | |
121 "/theme/field[@name='startcolor'/@default"; | |
122 | |
123 public final static String XPATH_WSPLGEN_ENDCOLOR = | |
124 "/theme/field[@name='endcolor'/@default"; | |
125 | |
126 public final static String XPATH_WSPLGEN_NUMCLASSES = | |
127 "/theme/field[@name='numclasses'/@default"; | |
119 | 128 |
120 /** XPATH to bandwidth field. */ | 129 /** XPATH to bandwidth field. */ |
121 public final static String XPATH_BANDWIDTH = | 130 public final static String XPATH_BANDWIDTH = |
122 "/theme/field[@name='bandwidth']/@default"; | 131 "/theme/field[@name='bandwidth']/@default"; |
123 | 132 |
617 return parseBoolean(getShowMaximum(theme), false); | 626 return parseBoolean(getShowMaximum(theme), false); |
618 } | 627 } |
619 | 628 |
620 | 629 |
621 public static String createWSPLGENStyle(Document theme) { | 630 public static String createWSPLGENStyle(Document theme) { |
631 MapserverStyle ms = new MapserverStyle(); | |
632 | |
633 Color startColor = parseColor( | |
634 XMLUtils.xpathString(theme, XPATH_WSPLGEN_STARTCOLOR, null)); | |
635 Color endColor = parseColor( | |
636 XMLUtils.xpathString(theme, XPATH_WSPLGEN_ENDCOLOR, null)); | |
637 int numClasses = Integer.parseInt( | |
638 XMLUtils.xpathString(theme, XPATH_WSPLGEN_NUMCLASSES, null)); | |
639 | |
640 if (numClasses < 5) { | |
641 numClasses = 5; | |
642 } | |
643 else if (numClasses > 20) { | |
644 numClasses = 20; | |
645 } | |
646 | |
647 int rd = (startColor.getRed() - endColor.getRed()) / numClasses; | |
648 int gd = (startColor.getGreen() - endColor.getGreen()) / numClasses; | |
649 int bd = (startColor.getBlue() - endColor.getBlue()) / numClasses; | |
650 | |
651 for (int n = 0; n < numClasses; n++) { | |
652 StringBuilder newColor = new StringBuilder(); | |
653 newColor.append(startColor.getRed() + n * rd); | |
654 newColor.append(' '); | |
655 newColor.append(startColor.getGreen() + n * gd); | |
656 newColor.append(' '); | |
657 newColor.append(startColor.getBlue() + n * bd); | |
658 | |
659 Clazz c = new Clazz("Klasse " + n + " (FIXME)"); | |
660 Style s = new Style(); | |
661 s.setColor(newColor.toString()); | |
662 s.setSize(5); | |
663 | |
664 c.addItem(new Expression("Klasse " + n)); | |
665 c.addItem(s); | |
666 | |
667 ms.addClazz(c); | |
668 } | |
669 | |
622 NodeList categories = (NodeList) XMLUtils.xpath( | 670 NodeList categories = (NodeList) XMLUtils.xpath( |
623 theme, | 671 theme, |
624 XPATH_WSPLGEN_FIELDS, | 672 XPATH_WSPLGEN_FIELDS, |
625 XPathConstants.NODESET); | 673 XPathConstants.NODESET); |
626 | 674 |