# HG changeset patch # User Felix Wolfsteller # Date 1338279783 0 # Node ID 55f91fae8a7b9f65497741a769f93d4b71cd197d # Parent 7d33aec0b61dc1a5a333ccf3482a6e44ab1d8a67 Respect new theme setting when drawing line to curve. flys-artifacts/trunk@4551 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7d33aec0b61d -r 55f91fae8a7b flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue May 29 07:37:46 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue May 29 08:23:03 2012 +0000 @@ -1,3 +1,10 @@ +2012-05-29 Felix Wolfsteller + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + Consider theme setting before drawing line to curve. + 2012-05-29 Felix Wolfsteller * doc/conf/themes.xml: Donate own theme for mainvalues. diff -r 7d33aec0b61d -r 55f91fae8a7b flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue May 29 07:37:46 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue May 29 08:23:03 2012 +0000 @@ -50,6 +50,7 @@ import de.intevation.flys.jfree.StyledXYSeries; import de.intevation.flys.utils.ThemeAccess; +import de.intevation.flys.utils.ThemeUtil; import de.intevation.flys.artifacts.model.HYKFactory; @@ -768,13 +769,15 @@ /** * Add a text and a line annotation. * @param area convenience to determine positions in plot. + * @param theme (optional) theme document */ public void addStickyAnnotation( StickyAxisAnnotation annotation, XYPlot plot, Area area, ThemeAccess.LineStyle lineStyle, - ThemeAccess.TextStyle textStyle + ThemeAccess.TextStyle textStyle, + Document theme ) { // OPTIMIZE pre-calculate area-related values final float TEXT_OFF = 0.03f; @@ -823,19 +826,23 @@ lineAnnotation = createRightStickAnnotation( area2, annotation.getPos(), lineStyle); // TODO line to curve - if (!Float.isNaN(annotation.getHitPoint())) { - // TODO let line be styled and respect X/Y-ness. + if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { // New line annotation to hit curve. - XYLineAnnotation hitLineAnnotation = new XYLineAnnotation( - area2.atRight(), annotation.getPos(), - annotation.getHitPoint(), annotation.getPos()); - XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( - annotation.getHitPoint(), annotation.getPos(), - annotation.getHitPoint(), area2.atGround()); - plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, - org.jfree.ui.Layer.BACKGROUND); - plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, - org.jfree.ui.Layer.BACKGROUND); + // TODO include more style information + if (ThemeUtil.parseShowVerticalLine(theme)) { + XYLineAnnotation hitLineAnnotation = new XYLineAnnotation( + area2.atRight(), annotation.getPos(), + annotation.getHitPoint(), annotation.getPos()); + plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, + org.jfree.ui.Layer.BACKGROUND); + } + if (ThemeUtil.parseShowHorizontalLine(theme)) { + XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( + annotation.getHitPoint(), annotation.getPos(), + annotation.getHitPoint(), area2.atGround()); + plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, + org.jfree.ui.Layer.BACKGROUND); + } } } else { @@ -844,19 +851,22 @@ textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT); textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT); lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle); - // TODO line to curve - if (!Float.isNaN(annotation.getHitPoint())) { - // TODO let line be styled and respect X/Y-ness. + if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { + // TODO include more style information // New line annotation to hit curve. - XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(), - annotation.getPos(), annotation.getHitPoint(), annotation.getPos()); - XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( - annotation.getHitPoint(), annotation.getPos(), - annotation.getHitPoint(), area.atGround()); - plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, - org.jfree.ui.Layer.BACKGROUND); - plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, - org.jfree.ui.Layer.BACKGROUND); + if (ThemeUtil.parseShowHorizontalLine(theme)) { + XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(), + annotation.getPos(), annotation.getHitPoint(), annotation.getPos()); + plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, + org.jfree.ui.Layer.BACKGROUND); + } + if (ThemeUtil.parseShowVerticalLine(theme)) { + XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( + annotation.getHitPoint(), annotation.getPos(), + annotation.getHitPoint(), area.atGround()); + plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, + org.jfree.ui.Layer.BACKGROUND); + } } } } @@ -928,7 +938,8 @@ // The 'Sticky' Annotations (at axis, with line and text). for (StickyAxisAnnotation sta: fa.getAxisTextAnnotations()) { - addStickyAnnotation(sta, plot, area, lineStyle, textStyle); + addStickyAnnotation( + sta, plot, area, lineStyle, textStyle, theme); } // Other Text Annotations (e.g. labels of manual points). diff -r 7d33aec0b61d -r 55f91fae8a7b flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Tue May 29 07:37:46 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Tue May 29 08:23:03 2012 +0000 @@ -52,6 +52,12 @@ public final static String XPATH_SHOW_LINE = "/theme/field[@name='showlines']/@default"; + public final static String XPATH_SHOW_VERTICAL_LINE = + "/theme/field[@name='showverticalline']/@default"; + + public final static String XPATH_SHOW_HORIZONTAL_LINE = + "/theme/field[@name='showhorizontalline']/@default"; + public final static String XPATH_SHOW_LINE_LABEL = "/theme/field[@name='showlinelabel']/@default"; @@ -270,6 +276,24 @@ } /** + * Parses the attribute 'showverticalline', defaults to true. + * @param theme The theme. + */ + public static boolean parseShowVerticalLine(Document theme) { + String show = XMLUtils.xpathString(theme, XPATH_SHOW_VERTICAL_LINE, null); + return parseBoolean(show, true); + } + + /** + * Parses the attribute 'showhorizontalline', defaults to true. + * @param theme The theme. + */ + public static boolean parseShowHorizontalLine(Document theme) { + String show = XMLUtils.xpathString(theme, XPATH_SHOW_HORIZONTAL_LINE, null); + return parseBoolean(show, true); + } + + /** * Parses the attribute 'showlines', defaults to true. * @param theme The theme. */