# HG changeset patch # User Felix Wolfsteller # Date 1336593946 0 # Node ID 2be59d5b342c33f782a7f845c9c6f1c9778cd860 # Parent 0143b44631ccce883e5f991d32b1009ef8c325a5 Added and respect theme prop whether or not to display (not yet calculated) middle height. flys-artifacts/trunk@4368 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0143b44631cc -r 2be59d5b342c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed May 09 19:03:54 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed May 09 20:05:46 2012 +0000 @@ -1,3 +1,18 @@ +2012-05-08 Felix Wolfsteller + + Display mittlere hoehe (which is not yet calculated). + + * doc/conf/themes.xml: Added theme prop to display middlere hoehe or not. + + * src/main/java/de/intevation/flys/utils/ThemeUtil.java: + (parseShowMiddleHeight): New, parse the new theme prop. + + * src/main/java/de/intevation/flys/artifacts/geom/Lines.java: + (fillWater, ListWithArea): Return new type wich also contains area. + + * src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java: + Respect new theme prop and adjust label if set. + 2012-05-08 Felix Wolfsteller Beginning of calculation of Mittlere Hoehe: area calculation. diff -r 0143b44631cc -r 2be59d5b342c flys-artifacts/doc/conf/themes.xml --- a/flys-artifacts/doc/conf/themes.xml Wed May 09 19:03:54 2012 +0000 +++ b/flys-artifacts/doc/conf/themes.xml Wed May 09 20:05:46 2012 +0000 @@ -587,6 +587,7 @@ + diff -r 0143b44631cc -r 2be59d5b342c flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java Wed May 09 19:03:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java Wed May 09 20:05:46 2012 +0000 @@ -58,7 +58,19 @@ return sum; } - public static List fillWater(List points, double waterLevel) { + + /** List of lines and a double-precision area. */ + private static class ListWithArea { + public List lines; + public double area; + public ListWithArea(List lines, double area) { + this.lines = lines; + this.area = area; + } + } + + + public static ListWithArea fillWater(List points, double waterLevel) { boolean debug = log.isDebugEnabled(); @@ -72,7 +84,7 @@ int N = points.size(); if (N == 0) { - return result; + return new ListWithArea(result, 0d); } if (N == 1) { @@ -83,7 +95,7 @@ p.getX(), waterLevel, p.getX(), waterLevel)); } - return result; + return new ListWithArea(result, 0d); } double minX = Double.MAX_VALUE; @@ -103,13 +115,13 @@ if (minY > waterLevel) { // profile completely over water level log.debug("complete over water"); - return result; + return new ListWithArea(result, 0d); } if (waterLevel > maxY) { // water floods profile log.debug("complete under water"); result.add(new Line2D.Double(minX, waterLevel, maxX, waterLevel)); - return result; + return new ListWithArea(result, 0d); } // Water is sometimes above, sometimes under profile. @@ -292,7 +304,7 @@ maxX, waterLevel)); } - return result; + return new ListWithArea(result, area); } @@ -315,7 +327,8 @@ List points, double waterlevel ) { - List lines = fillWater(points, waterlevel); + ListWithArea listAndArea = fillWater(points, waterlevel); + List lines = listAndArea.lines; TDoubleArrayList lxs = new TDoubleArrayList(); TDoubleArrayList lys = new TDoubleArrayList(); @@ -343,7 +356,7 @@ return new LineData( new double [][] { lxs.toNativeArray(), lys.toNativeArray() }, - linesLength, 0d + linesLength, listAndArea.area ); } } diff -r 0143b44631cc -r 2be59d5b342c flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java Wed May 09 19:03:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java Wed May 09 20:05:46 2012 +0000 @@ -232,9 +232,14 @@ // Do not modify. //series.setLabel(series.getLabel()); } - if (ThemeUtil.parseShowLevel(theme) && lines.points.length >0 && lines.points[1].length > 0) { + if (ThemeUtil.parseShowLevel(theme) && lines.points.length >0 + && lines.points[1].length > 0) { series.setLabel(series.getLabel() + ", W=" + lines.points[1][0] + "NN+m"); } + if (ThemeUtil.parseShowMiddleHeight(theme) && lines.points.length >0 + && lines.points[1].length > 0) { + series.setLabel(series.getLabel() + ",H=" + lines.area / lines.points[1][0] + "m"); + } // TODO Missing: "mittlere hoehe" (and area but this geos to // the area theme). diff -r 0143b44631cc -r 2be59d5b342c 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 09 19:03:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed May 09 20:05:46 2012 +0000 @@ -85,6 +85,9 @@ public final static String XPATH_SHOW_AREA = "/theme/field[@name='showarea']/@default"; + public final static String XPATH_SHOW_MIDDLE_HEIGHT = + "/theme/field[@name='showmiddleheight']/@default"; + public final static String XPATH_TEXT_COLOR = "/theme/field[@name='textcolor']/@default"; @@ -249,6 +252,15 @@ } /** + * Parses the attribute 'showmiddleheight', defaults to false. + * @param theme The theme. + */ + public static boolean parseShowMiddleHeight(Document theme) { + String show = XMLUtils.xpathString(theme, XPATH_SHOW_MIDDLE_HEIGHT, null); + return parseBoolean(show, false); + } + + /** * Parses the attribute 'showarea', defaults to false. * @param theme The theme. */