# HG changeset patch # User Raimund Renkert # Date 1318856424 0 # Node ID 004b1b0838d6dfdfcbc517ebf74d53ea6e32091f # Parent 6d9184c745ddd4fe3dae99063a10e63962883686 Apply line type to styled themes. flys-artifacts/trunk@2987 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6d9184c745dd -r 004b1b0838d6 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Oct 17 11:04:53 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Oct 17 13:00:24 2011 +0000 @@ -1,3 +1,11 @@ +2011-10-17 Raimund Renkert + + * src/main/java/de/intevation/flys/exports/StyledXYSeries.java: + Added method to apply line type. + + * doc/conf/themes.xml: + Changed initial default value for line type. + 2011-10-17 Ingo Weinzierl flys/issue226 (W-INFO: Dauerlinienberechung /Abbbildung x-Achse) diff -r 6d9184c745dd -r 004b1b0838d6 flys-artifacts/doc/conf/themes.xml --- a/flys-artifacts/doc/conf/themes.xml Mon Oct 17 11:04:53 2011 +0000 +++ b/flys-artifacts/doc/conf/themes.xml Mon Oct 17 13:00:24 2011 +0000 @@ -149,7 +149,7 @@ - + @@ -169,7 +169,7 @@ - + diff -r 6d9184c745dd -r 004b1b0838d6 flys-artifacts/src/main/java/de/intevation/flys/exports/StyledXYSeries.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledXYSeries.java Mon Oct 17 11:04:53 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledXYSeries.java Mon Oct 17 13:00:24 2011 +0000 @@ -21,6 +21,8 @@ public static final String XPATH_LINE_SIZE = "/theme/field[@name='linesize']/@default"; + public static final String XPATH_LINE_TYPE = + "/theme/field[@name='linetype']/@default"; protected Document theme; @@ -38,6 +40,7 @@ public XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx){ applyLineColor(r, idx); applyLineSize(r, idx); + applyLineType(r, idx); r.setSeriesLinesVisible(idx, true); r.setSeriesShapesVisible(idx, false); @@ -87,5 +90,42 @@ logger.warn("Unable to set line size from string: '" + size + "'"); } } + + + protected void applyLineType(XYLineAndShapeRenderer r, int idx) { + String dash = XMLUtils.xpathString(theme, XPATH_LINE_TYPE, null); + String size = XMLUtils.xpathString(theme, XPATH_LINE_SIZE, null); + + if (dash == null || dash.length() == 0) { + return; + } + if (size == null || size.length() == 0) { + return; + } + + String[] pattern = dash.split(","); + if(pattern.length == 1) { + return; + } + + try { + float[] dashes = new float[pattern.length]; + for (int i = 0; i < pattern.length; i++) { + dashes[i] = Float.parseFloat(pattern[i]); + } + + r.setSeriesStroke( + idx, + new BasicStroke(Integer.valueOf(size), + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_ROUND, + 1.0f, + dashes, + 0.0f)); + } + catch(NumberFormatException nfe) { + logger.warn("Unable to set dash from string: '" + dash + "'"); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :