Mercurial > dive4elements > river
changeset 2648:8aaa7f4ce06a
Let theme define whether or not to display a (yet static) label for line).
flys-artifacts/trunk@4306 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 26 Apr 2012 09:51:13 +0000 |
parents | 4b7a28e81643 |
children | 6f5fc3de0d48 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java |
diffstat | 5 files changed, 58 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 <felix.wolfsteller@intevation.de> + + * 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 <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java:
--- 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 @@ <field name="showlines" type="boolean" display="Linie anzeigen" default="true"/> <field name="linesize" type="int" display="Liniendicke" default="1"/> <field name="linetype" type="Dash" display="Linienart" default="10"/> + <field name="showlinelabel" type="boolean" display="Beschriftung anzeigen" default="false" hints="h"/> </fields> </theme>
--- 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<Integer, Double> seriesMinimum; protected Map<Integer, Double> seriesMinimumX; @@ -44,6 +44,7 @@ super(lines, shapes); this.isMinimumShapeVisible = new BooleanList(); this.isMaximumShapeVisible = new BooleanList(); + this.showLineLabel = new BooleanList(); this.seriesMinimum = new HashMap<Integer, Double>(); this.seriesMaximum = new HashMap<Integer, Double>(); this.seriesMinimumX = new HashMap<Integer, Double>(); @@ -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
--- 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 <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ 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(
--- 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.