# HG changeset patch # User Andre Heinecke # Date 1380182286 -7200 # Node ID ab109ae2acc61f079d3b21062163c044a0b329b2 # Parent 2d690611d11091fc368ca49929b282d5485f7bc6 Add startkm and endkm setting to longitudinal section generator 2 diff -r 2d690611d110 -r ab109ae2acc6 artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java Wed Sep 25 18:04:49 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java Thu Sep 26 09:58:06 2013 +0200 @@ -8,6 +8,13 @@ package org.dive4elements.river.exports; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.river.artifacts.access.RangeAccess; +import org.dive4elements.river.jfree.Bounds; +import org.dive4elements.river.jfree.DoubleBounds; +import org.dive4elements.river.themes.ThemeDocument; + public class LongitudinalSectionGenerator2 extends DiagramGenerator { public static final String I18N_CHART_SHORT_SUBTITLE = @@ -33,5 +40,49 @@ return super.getDefaultChartSubtitle(); } + + /* We override doOut here to save the startkm and endkm in the + * context. Some facets will deliver different data because of + * that setting. It is mainly used in MINFO where it causes + * adaptive smoothing on the data if you are zoomed out do + * reduce the static in the curve. */ + @Override + public void doOut( + ArtifactAndFacet bundle, + ThemeDocument theme, + boolean visible + ) { + /* Aheinecke (25.09.2013): I do not understand why this has to be + * done so difficult and if it really must be done for every + * facet. At least it has to be done _before_ the super class + * actually does the output and accesses the facet data. + */ + D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); + + if (getXBounds(0) != null && getDomainAxisRange() != null) { + Bounds bounds = + calculateZoom(getXBounds(0), getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } + else if (getXBounds(0) != null && getDomainAxisRange() == null) { + context.putContextValue("startkm", getXBounds(0).getLower()); + context.putContextValue("endkm", getXBounds(0).getUpper()); + } + else if (getXBounds(0) == null && getDomainAxisRange() == null) { + RangeAccess access = new RangeAccess(artifact); + context.putContextValue("startkm", access.getFrom()); + context.putContextValue("endkm", access.getTo()); + } + else if (getXBounds(0) == null && getDomainAxisRange() != null){ + RangeAccess access = new RangeAccess(artifact); + Bounds b = new DoubleBounds(access.getFrom(), access.getTo()); + Bounds bounds = + calculateZoom(b, getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } + super.doOut(bundle, theme, visible); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :