Mercurial > dive4elements > river
changeset 2076:41037d51c8b6
Added support for pointsize in chart themes.
flys-artifacts/trunk@3589 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 04 Jan 2012 16:13:10 +0000 |
parents | f42b0e624e97 |
children | 29459ddb6f30 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledXYSeries.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java |
diffstat | 4 files changed, 48 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed Jan 04 15:23:26 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Jan 04 16:13:10 2012 +0000 @@ -1,3 +1,14 @@ +2012-01-04 Ingo Weinzierl <ingo@intevation.de> + + * doc/conf/themes.xml: Added a new field 'pointsize' to the virtual theme + 'HiddenColorLines'. + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java: Added methods to + parse the new field of 'HiddenColorLines'. + + * src/main/java/de/intevation/flys/jfree/StyledXYSeries.java: Apply the + pointsize defined in themes. + 2012-01-04 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java:
--- a/flys-artifacts/doc/conf/themes.xml Wed Jan 04 15:23:26 2012 +0000 +++ b/flys-artifacts/doc/conf/themes.xml Wed Jan 04 16:13:10 2012 +0000 @@ -722,6 +722,7 @@ <field name="linesize" type="int" display="Liniendicke" default="1" hints="h"/> <field name="linetype" type="Dash" display="Linienart" default="10" hints="h"/> <field name="showpoints" type="boolean" display="Datenpunkte anzeigen" default="false" hints="h"/> + <field name="pointsize" type="int" display="Punktdicke" default="5" hints="h"/> </fields> </theme>
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledXYSeries.java Wed Jan 04 15:23:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledXYSeries.java Wed Jan 04 16:13:10 2012 +0000 @@ -53,6 +53,7 @@ applyLineType(r, idx); applyShowLine(r, idx); applyShowPoints(r, idx); + applyPointSize(r, idx); applyShowMinimum(r, idx); applyShowMaximum(r, idx); @@ -95,16 +96,20 @@ } + protected void applyPointSize(XYLineAndShapeRenderer r, int idx) { + int size = ThemeUtil.parsePointWidth(theme); + int dim = 2 * size; + + r.setSeriesShape(idx, new Ellipse2D.Double(-size, -size, dim, dim)); + } + + /** * Sets form and visibility of points. */ protected void applyShowPoints(XYLineAndShapeRenderer r, int idx) { boolean show = ThemeUtil.parseShowPoints(theme); - int size = ThemeUtil.parseLineWidth(theme); - r.setSeriesShape(idx, new Ellipse2D.Double(- size, - - size, - 2 * size, - 2 * size)); + r.setSeriesShapesVisible(idx, show); r.setDrawOutlines(true); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed Jan 04 15:23:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed Jan 04 16:13:10 2012 +0000 @@ -35,6 +35,9 @@ public static final String XPATH_LINE_STYLE = "/theme/field[@name='linetype']/@default"; + public static final String XPATH_POINT_SIZE = + "/theme/field[@name='pointsize']/@default"; + public final static String XPATH_SHOW_BORDER = "/theme/field[@name='showborder']/@default"; @@ -95,6 +98,22 @@ } + public static int parseInteger(String value, int defaultsTo) { + if (value == null || value.length() == 0) { + return defaultsTo; + } + + try { + return Integer.valueOf(value); + } + catch (NumberFormatException nfe) { + // do nothing + } + + return defaultsTo; + } + + /** * Parses line width, defaulting to 0. * @param theme the theme @@ -115,6 +134,13 @@ } + public static int parsePointWidth(Document theme) { + String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null); + + return parseInteger(width, 3); + } + + /** * Parses the line style, defaulting to '10'. * @param theme The theme.