comparison artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java @ 7157:ab109ae2acc6

Add startkm and endkm setting to longitudinal section generator 2
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 26 Sep 2013 09:58:06 +0200
parents 4605d6ca4ee9
children 81416a62fa57
comparison
equal deleted inserted replaced
7156:2d690611d110 7157:ab109ae2acc6
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the 5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.exports; 9 package org.dive4elements.river.exports;
10
11 import org.dive4elements.river.artifacts.D4EArtifact;
12 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
13 import org.dive4elements.river.artifacts.access.RangeAccess;
14 import org.dive4elements.river.jfree.Bounds;
15 import org.dive4elements.river.jfree.DoubleBounds;
16 import org.dive4elements.river.themes.ThemeDocument;
10 17
11 public class LongitudinalSectionGenerator2 extends DiagramGenerator 18 public class LongitudinalSectionGenerator2 extends DiagramGenerator
12 { 19 {
13 public static final String I18N_CHART_SHORT_SUBTITLE = 20 public static final String I18N_CHART_SHORT_SUBTITLE =
14 "chart.longitudinal.section.shortsubtitle"; 21 "chart.longitudinal.section.shortsubtitle";
31 return msg(I18N_CHART_LOCATION_SUBTITLE, "", args); 38 return msg(I18N_CHART_LOCATION_SUBTITLE, "", args);
32 } 39 }
33 40
34 return super.getDefaultChartSubtitle(); 41 return super.getDefaultChartSubtitle();
35 } 42 }
43
44 /* We override doOut here to save the startkm and endkm in the
45 * context. Some facets will deliver different data because of
46 * that setting. It is mainly used in MINFO where it causes
47 * adaptive smoothing on the data if you are zoomed out do
48 * reduce the static in the curve. */
49 @Override
50 public void doOut(
51 ArtifactAndFacet bundle,
52 ThemeDocument theme,
53 boolean visible
54 ) {
55 /* Aheinecke (25.09.2013): I do not understand why this has to be
56 * done so difficult and if it really must be done for every
57 * facet. At least it has to be done _before_ the super class
58 * actually does the output and accesses the facet data.
59 */
60 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
61
62 if (getXBounds(0) != null && getDomainAxisRange() != null) {
63 Bounds bounds =
64 calculateZoom(getXBounds(0), getDomainAxisRange());
65 context.putContextValue("startkm", bounds.getLower());
66 context.putContextValue("endkm", bounds.getUpper());
67 }
68 else if (getXBounds(0) != null && getDomainAxisRange() == null) {
69 context.putContextValue("startkm", getXBounds(0).getLower());
70 context.putContextValue("endkm", getXBounds(0).getUpper());
71 }
72 else if (getXBounds(0) == null && getDomainAxisRange() == null) {
73 RangeAccess access = new RangeAccess(artifact);
74 context.putContextValue("startkm", access.getFrom());
75 context.putContextValue("endkm", access.getTo());
76 }
77 else if (getXBounds(0) == null && getDomainAxisRange() != null){
78 RangeAccess access = new RangeAccess(artifact);
79 Bounds b = new DoubleBounds(access.getFrom(), access.getTo());
80 Bounds bounds =
81 calculateZoom(b, getDomainAxisRange());
82 context.putContextValue("startkm", bounds.getLower());
83 context.putContextValue("endkm", bounds.getUpper());
84 }
85 super.doOut(bundle, theme, visible);
86 }
36 } 87 }
37 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 88 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org