# HG changeset patch # User Felix Wolfsteller # Date 1335433873 0 # Node ID 8aaa7f4ce06a462ba194c019e6c9c1dc27b63f70 # Parent 4b7a28e81643b25304dde2a46e9c822d678cc241 Let theme define whether or not to display a (yet static) label for line). flys-artifacts/trunk@4306 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4b7a28e81643 -r 8aaa7f4ce06a flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Apr 26 08:11:48 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Apr 26 09:51:13 2012 +0000 @@ -1,3 +1,20 @@ +2012-04-26 Felix Wolfsteller + + * src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java + (showSeriesMinimunX, showLineLabel): Renamed field. + (isShowLineLabel, setShowLineLabel): Added getters and setters for + showLineLabel field. + (drawSecondaryPass): Respect showLineLabel field, draw static text + as placeholder for real label (stub). + + * doc/conf/themes.xml: Define theme prop 'showlinelabel' for Lines. + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java: Parse theme + theme prop. + + * src/main/java/de/intevation/flys/jfree/XYStyle.java: Apply showline + theme prop. + 2012-04-26 Felix Wolfsteller * src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java: diff -r 4b7a28e81643 -r 8aaa7f4ce06a flys-artifacts/doc/conf/themes.xml --- a/flys-artifacts/doc/conf/themes.xml Thu Apr 26 08:11:48 2012 +0000 +++ b/flys-artifacts/doc/conf/themes.xml Thu Apr 26 09:51:13 2012 +0000 @@ -766,6 +766,7 @@ + diff -r 4b7a28e81643 -r 8aaa7f4ce06a flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java Thu Apr 26 08:11:48 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java Thu Apr 26 09:51:13 2012 +0000 @@ -33,7 +33,7 @@ protected BooleanList isMinimumShapeVisible; protected BooleanList isMaximumShapeVisible; - protected BooleanList showSeriesMinimumX;; + protected BooleanList showLineLabel; protected Map seriesMinimum; protected Map seriesMinimumX; @@ -44,6 +44,7 @@ super(lines, shapes); this.isMinimumShapeVisible = new BooleanList(); this.isMaximumShapeVisible = new BooleanList(); + this.showLineLabel = new BooleanList(); this.seriesMinimum = new HashMap(); this.seriesMaximum = new HashMap(); this.seriesMinimumX = new HashMap(); @@ -236,7 +237,7 @@ } boolean doWaterlevelLabel = false; - if (isMinimumX (dataset, series, item)) { + if (isShowLineLabel(series) && isMinimumX (dataset, series, item)) { // TODO find name of dataset/series String waterlevelLabel = "label"; // TODO Force water of some German rivers to flow direction mountains. @@ -283,6 +284,21 @@ return isMaximumShapeVisible.getBoolean(series); } + /** Whether or not a label should be shown for series. */ + public boolean isShowLineLabel(int series) { + if (this.showLineLabel.size() <= series) { + return false; + } + + return showLineLabel.getBoolean(series); + } + + + /** Sets whether or not a label should be shown for series. */ + public void setShowLineLabel(boolean showLineLabel, int series) { + this.showLineLabel.setBoolean(series, showLineLabel); + } + /** * True if the given item of given dataset has the smallest diff -r 4b7a28e81643 -r 8aaa7f4ce06a flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java Thu Apr 26 08:11:48 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java Thu Apr 26 09:51:13 2012 +0000 @@ -13,6 +13,7 @@ /** + * Utility to apply theme-settings to a renderer. * @author Ingo Weinzierl */ public class XYStyle implements Style { @@ -38,6 +39,7 @@ applyPointSize(r, idx); applyShowMinimum(r, idx); applyShowMaximum(r, idx); + applyShowLineLabel(r, idx); return r; } @@ -50,6 +52,15 @@ } + /** Tells the renderer whether or not to add a label to a line. */ + protected void applyShowLineLabel(XYLineAndShapeRenderer r, int idx) { + if (!(r instanceof EnhancedLineAndShapeRenderer)) { + return; + } + boolean showLabelLine = ThemeUtil.parseShowLineLabel(theme); + ((EnhancedLineAndShapeRenderer)r).setShowLineLabel(showLabelLine, idx); + } + protected void applyLineSize(XYLineAndShapeRenderer r, int idx) { int size = ThemeUtil.parseLineWidth(theme); r.setSeriesStroke( diff -r 4b7a28e81643 -r 8aaa7f4ce06a flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Thu Apr 26 08:11:48 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Thu Apr 26 09:51:13 2012 +0000 @@ -52,6 +52,9 @@ public final static String XPATH_SHOW_LINE = "/theme/field[@name='showlines']/@default"; + public final static String XPATH_SHOW_LINE_LABEL = + "/theme/field[@name='showlinelabel']/@default"; + public final static String XPATH_TRANSPARENCY = "/theme/field[@name='transparent']/@default"; @@ -218,6 +221,14 @@ return parseBoolean(show, true); } + /** + * Parses the attribute 'showlinelabel', defaults to true. + * @param theme The theme. + */ + public static boolean parseShowLineLabel(Document theme) { + String show = XMLUtils.xpathString(theme, XPATH_SHOW_LINE_LABEL, null); + return parseBoolean(show, true); + } /** * Parses text color.