Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Tue Nov 27 14:30:08 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Tue Nov 27 15:59:26 2012 +0100 @@ -117,6 +117,15 @@ public final static String XPATH_WSPLGEN_FIELDS = "/theme[@name='WSPLGEN']/field"; + public final static String XPATH_WSPLGEN_STARTCOLOR = + "/theme/field[@name='startcolor'/@default"; + + public final static String XPATH_WSPLGEN_ENDCOLOR = + "/theme/field[@name='endcolor'/@default"; + + public final static String XPATH_WSPLGEN_NUMCLASSES = + "/theme/field[@name='numclasses'/@default"; + /** XPATH to bandwidth field. */ public final static String XPATH_BANDWIDTH = "/theme/field[@name='bandwidth']/@default"; @@ -619,6 +628,45 @@ public static String createWSPLGENStyle(Document theme) { + MapserverStyle ms = new MapserverStyle(); + + Color startColor = parseColor( + XMLUtils.xpathString(theme, XPATH_WSPLGEN_STARTCOLOR, null)); + Color endColor = parseColor( + XMLUtils.xpathString(theme, XPATH_WSPLGEN_ENDCOLOR, null)); + int numClasses = Integer.parseInt( + XMLUtils.xpathString(theme, XPATH_WSPLGEN_NUMCLASSES, null)); + + if (numClasses < 5) { + numClasses = 5; + } + else if (numClasses > 20) { + numClasses = 20; + } + + int rd = (startColor.getRed() - endColor.getRed()) / numClasses; + int gd = (startColor.getGreen() - endColor.getGreen()) / numClasses; + int bd = (startColor.getBlue() - endColor.getBlue()) / numClasses; + + for (int n = 0; n < numClasses; n++) { + StringBuilder newColor = new StringBuilder(); + newColor.append(startColor.getRed() + n * rd); + newColor.append(' '); + newColor.append(startColor.getGreen() + n * gd); + newColor.append(' '); + newColor.append(startColor.getBlue() + n * bd); + + Clazz c = new Clazz("Klasse " + n + " (FIXME)"); + Style s = new Style(); + s.setColor(newColor.toString()); + s.setSize(5); + + c.addItem(new Expression("Klasse " + n)); + c.addItem(s); + + ms.addClazz(c); + } + NodeList categories = (NodeList) XMLUtils.xpath( theme, XPATH_WSPLGEN_FIELDS,