# HG changeset patch # User Felix Wolfsteller # Date 1335971344 0 # Node ID f1dcd5f94ffa8e83d976c7a194e108aedf05f79a # Parent 60925be3c84f6f232a2ea245ca25584496a24e0c Parse more theme properties for linelabels. flys-artifacts/trunk@4327 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 60925be3c84f -r f1dcd5f94ffa flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed May 02 08:50:01 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed May 02 15:09:04 2012 +0000 @@ -1,3 +1,21 @@ +2012-05-02 Felix Wolfsteller + + Parse font for linelabels, do not use it yet. + + * doc/conf/themes.xml: Add more theme properties related to linelabels. + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java + (parseTextSize, parseLineLabelSize): New and slightly refactored. + (parseLineLabelFont): New. + (parseTextStyle, parseLineLabelStyle): New and slightly refactored. + + * src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java + (setLineLabelFont, getLineLabelFont): New, accessors to + linelabelfont field. + + * src/main/java/de/intevation/flys/jfree/XYStyle.java + (applyLineLabelFont): New. + 2012-05-02 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/charts/CrossSectionApp.java: @@ -5,7 +23,7 @@ 2012-04-27 Felix Wolfsteller - * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Doc. + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Doc. 2012-04-27 Felix Wolfsteller diff -r 60925be3c84f -r f1dcd5f94ffa flys-artifacts/doc/conf/themes.xml --- a/flys-artifacts/doc/conf/themes.xml Wed May 02 08:50:01 2012 +0000 +++ b/flys-artifacts/doc/conf/themes.xml Wed May 02 15:09:04 2012 +0000 @@ -766,7 +766,14 @@ - + + + + + + + + diff -r 60925be3c84f -r f1dcd5f94ffa flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java Wed May 02 08:50:01 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java Wed May 02 15:09:04 2012 +0000 @@ -2,6 +2,7 @@ import java.awt.Color; import java.awt.Graphics2D; +import java.awt.Font; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Rectangle2D; @@ -44,6 +45,8 @@ protected Map seriesMinimumX; protected Map seriesMaximum; + protected Map lineLabelFonts; + public EnhancedLineAndShapeRenderer(boolean lines, boolean shapes) { super(lines, shapes); @@ -53,6 +56,7 @@ this.seriesMinimum = new HashMap(); this.seriesMaximum = new HashMap(); this.seriesMinimumX = new HashMap(); + this.lineLabelFonts = new HashMap(); } @@ -306,6 +310,14 @@ this.showLineLabel.setBoolean(series, showLineLabel); } + public void setLineLabelFont(Font font, int series) { + this.lineLabelFonts.put(series, font); + } + + public Font getLineLabelFont(int series) { + return this.lineLabelFonts.get(series); + } + /** * True if the given item of given dataset has the smallest diff -r 60925be3c84f -r f1dcd5f94ffa flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java Wed May 02 08:50:01 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java Wed May 02 15:09:04 2012 +0000 @@ -40,6 +40,7 @@ applyShowMinimum(r, idx); applyShowMaximum(r, idx); applyShowLineLabel(r, idx); + applyLineLabelFont(r, idx); return r; } @@ -61,6 +62,18 @@ ((EnhancedLineAndShapeRenderer)r).setShowLineLabel(showLabelLine, idx); } + + /** Tell the renderer which font (and -size and -style) to use for + * linelabels. */ + protected void applyLineLabelFont(XYLineAndShapeRenderer r, int idx) { + if (!(r instanceof EnhancedLineAndShapeRenderer)) { + return; + } + ((EnhancedLineAndShapeRenderer)r).setLineLabelFont(ThemeUtil.parseLineLabelFont(theme), idx); + } + + + /** Set stroke of series. */ protected void applyLineSize(XYLineAndShapeRenderer r, int idx) { int size = ThemeUtil.parseLineWidth(theme); r.setSeriesStroke( @@ -69,6 +82,7 @@ } + /** Set stroke strength of series. */ protected void applyLineType(XYLineAndShapeRenderer r, int idx) { int size = ThemeUtil.parseLineWidth(theme); float[] dashes = ThemeUtil.parseLineStyle(theme); diff -r 60925be3c84f -r f1dcd5f94ffa flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed May 02 08:50:01 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed May 02 15:09:04 2012 +0000 @@ -55,6 +55,24 @@ public final static String XPATH_SHOW_LINE_LABEL = "/theme/field[@name='showlinelabel']/@default"; + public final static String XPATH_LINE_LABEL_FONT = + "/theme/field[@name='showlinelabelfont']/@default"; + + public final static String XPATH_LINE_LABEL_COLOR = + "/theme/field[@name='showlinelabelcolor']/@default"; + + public final static String XPATH_LINE_LABEL_SIZE = + "/theme/field[@name='showlinelabelsize']/@default"; + + public final static String XPATH_LINE_LABEL_STYLE = + "/theme/field[@name='showlinelabelstyle']/@default"; + + public final static String XPATH_LINE_LABEL_BGCOLOR = + "/theme/field[@name='showlinelabelbgcolor']/@default"; + + public final static String XPATH_LINE_LABEL_SHOWBG = + "/theme/field[@name='showlinelabelshowbg']/@default"; + public final static String XPATH_TRANSPARENCY = "/theme/field[@name='transparent']/@default"; @@ -187,8 +205,8 @@ * Parses text size, defaulting to 10. * @param theme The theme. */ - public static int parseTextSize(Document theme) { - String size = XMLUtils.xpathString(theme, XPATH_TEXT_SIZE, null); + public static int parseTextSize(Document theme, String path) { + String size = XMLUtils.xpathString(theme, path, null); if (size == null || size.length() == 0) { return 10; } @@ -202,6 +220,16 @@ } + public static int parseTextSize(Document theme) { + return parseTextSize(theme, XPATH_TEXT_SIZE); + } + + + public static int parseLineLabelSize(Document theme) { + return parseTextSize(theme, XPATH_LINE_LABEL_SIZE); + } + + /** * Parses the attribute 'showpoints', defaults to false. * @param theme The theme. @@ -255,13 +283,27 @@ return f; } + /** Parse font (name, size and style) for linelabels. */ + public static Font parseLineLabelFont(Document theme) { + String font = XMLUtils.xpathString(theme, XPATH_LINE_LABEL_FONT, null); + if (font == null || font.length() == 0) { + return null; + } + + int size = parseLineLabelSize(theme); + int style = parseLineLabelStyle(theme); + + Font f = new Font (font, style, size); + return f; + } + /** * Parses the text style, defaults to 'Font.PLAIN'. * @param theme The theme. */ - public static int parseTextStyle(Document theme) { - String style = XMLUtils.xpathString(theme, XPATH_TEXT_STYLE, null); + public static int parseTextStyle(Document theme, String path) { + String style = XMLUtils.xpathString(theme, path, null); if (style == null || style.length() == 0) { return Font.PLAIN; } @@ -278,6 +320,16 @@ } + public static int parseTextStyle(Document theme) { + return parseTextStyle(theme, XPATH_TEXT_STYLE); + } + + + public static int parseLineLabelStyle(Document theme) { + return parseTextStyle(theme, XPATH_LINE_LABEL_STYLE); + } + + /** * Parses the textorientation, defaults to 'vertical'. * @param theme The theme.