# HG changeset patch # User Ingo Weinzierl # Date 1340022569 0 # Node ID 22def36d37b7c89b277f252f6607f0e31ddf8da0 # Parent 7e4c8590067afe42ec1de8b99b2478e1e503699d Apply point color in XYStyle. flys-artifacts/trunk@4689 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7e4c8590067a -r 22def36d37b7 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Jun 18 11:31:39 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Jun 18 12:29:29 2012 +0000 @@ -1,3 +1,16 @@ +2012-06-18 Ingo Weinzierl + + * doc/conf/themes.xml: Fixed broken color strings. + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java: Added new functions + that return colors for points. + + * src/main/java/de/intevation/flys/themes/ThemeAccess.java: Added new + function that returns the color for points. + + * src/main/java/de/intevation/flys/jfree/XYStyle.java: Added new method to + apply the color of points (independent of the specified line color). + 2012-06-18 Ingo Weinzierl * doc/conf/themes.xml: Added themes for SQ relation charts diff -r 7e4c8590067a -r 22def36d37b7 flys-artifacts/doc/conf/themes.xml --- a/flys-artifacts/doc/conf/themes.xml Mon Jun 18 11:31:39 2012 +0000 +++ b/flys-artifacts/doc/conf/themes.xml Mon Jun 18 12:29:29 2012 +0000 @@ -908,7 +908,7 @@ @@ -918,7 +918,7 @@ @@ -927,7 +927,7 @@ - + @@ -1795,12 +1795,20 @@ + + + + @@ -1808,7 +1816,7 @@ - + @@ -2092,12 +2100,20 @@ + + + + @@ -2105,7 +2121,7 @@ - + diff -r 7e4c8590067a -r 22def36d37b7 flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java Mon Jun 18 11:31:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java Mon Jun 18 12:29:29 2012 +0000 @@ -37,6 +37,7 @@ applyShowLine(r, idx); applyShowPoints(r, idx); applyPointSize(r, idx); + applyPointColor(r, idx); applyShowMinimum(r, idx); applyShowMaximum(r, idx); applyShowLineLabel(r, idx); @@ -141,6 +142,17 @@ } + protected void applyPointColor(XYLineAndShapeRenderer r, int idx) { + Color c = ThemeUtil.parsePointColor(theme); + + if (c != null) { + r.setSeriesFillPaint(idx, c); + r.setUseFillPaint(true); + r.setDrawOutlines(false); + } + } + + /** * Sets form and visibility of points. */ diff -r 7e4c8590067a -r 22def36d37b7 flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java --- a/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java Mon Jun 18 11:31:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java Mon Jun 18 12:29:29 2012 +0000 @@ -23,6 +23,7 @@ protected String textOrientation; protected Color textBackground; protected Boolean showTextBackground; + protected Color pointColor; public ThemeAccess(Document theme) { @@ -100,6 +101,19 @@ } + public Color parsePointColor() { + if (pointColor == null) { + pointColor = ThemeUtil.parsePointColor(theme); + + if (pointColor == null) { + return parseLineColorField(); + } + } + + return pointColor; + } + + public LineStyle parseLineStyle() { return new LineStyle(parseLineColorField(), Integer.valueOf(parseLineWidth())); } diff -r 7e4c8590067a -r 22def36d37b7 flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Mon Jun 18 11:31:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Mon Jun 18 12:29:29 2012 +0000 @@ -43,6 +43,9 @@ public static final String XPATH_POINT_SIZE = "/theme/field[@name='pointsize']/@default"; + public static final String XPATH_POINT_COLOR = + "/theme/field[@name='pointcolor']/@default"; + public final static String XPATH_SHOW_BORDER = "/theme/field[@name='showborder']/@default"; @@ -188,6 +191,13 @@ } + public static Color parsePointColor(Document theme) { + String color = XMLUtils.xpathString(theme, XPATH_POINT_COLOR, null); + + return parseColor(color); + } + + /** * Parses the line style, defaulting to '10'. * @param theme The theme. @@ -458,6 +468,37 @@ return parseBoolean(show, false); } + + public static Color parseColor(String colorString) { + if (colorString == null || colorString.length() == 0) { + return null; + } + else if (colorString.indexOf("#") == 0) { + return parseHexColor(colorString); + } + else if (colorString.indexOf(",") >= 0) { + return parseRGB(colorString); + } + + return null; + } + + + /** + * Parse a string like "#00CC22" and return the corresponding color. + * + * @param hex The hex color value. + * + * @return a Color or null, if hex is empty. + */ + public static Color parseHexColor(String hex) { + if (hex == null) { + return null; + } + + return Color.decode(hex); + } + /** * Parse a string like "103, 100, 0" and return a corresping color. * @param rgbtext Color as string representation, e.g. "255,0,20".