Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffBaseGenerator.java @ 6791:dd5355775ce1 longitudinal-symmetry
merge changes from default into longitudinal-symmetrie branch and make it build
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 07 Aug 2013 18:53:15 +0200 |
parents | 87b49f9f27a1 |
children |
comparison
equal
deleted
inserted
replaced
6518:1a7f5d09b9d8 | 6791:dd5355775ce1 |
---|---|
1 /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.exports.minfo; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 | |
13 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
14 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; | |
15 import org.dive4elements.river.jfree.Bounds; | |
16 import org.dive4elements.river.jfree.DoubleBounds; | |
17 import org.dive4elements.river.exports.LongitudinalSectionGenerator; | |
18 | |
19 /** Base for BedDiff*Year*Generators, to avoid duplicate code of setContextBounds. */ | |
20 public abstract class BedDiffBaseGenerator | |
21 extends LongitudinalSectionGenerator | |
22 { | |
23 /** The logger that is used in this generator. */ | |
24 private static Logger logger = Logger.getLogger(BedDiffBaseGenerator.class); | |
25 | |
26 /** Set context values for something. */ | |
27 public void setContextBounds(ArtifactAndFacet bundle) { | |
28 Bounds xBounds = getXBounds(0); | |
29 if (xBounds != null && getDomainAxisRange() != null) { | |
30 Bounds bounds = | |
31 calculateZoom(xBounds, getDomainAxisRange()); | |
32 context.putContextValue("startkm", bounds.getLower()); | |
33 context.putContextValue("endkm", bounds.getUpper()); | |
34 } | |
35 else if (xBounds != null && getDomainAxisRange() == null) { | |
36 context.putContextValue("startkm", xBounds.getLower()); | |
37 context.putContextValue("endkm", xBounds.getUpper()); | |
38 } | |
39 else if (xBounds == null && getDomainAxisRange() == null) { | |
40 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
41 if (data.getKms().size() > 0) { | |
42 context.putContextValue("startkm", data.getKms().min()); | |
43 context.putContextValue("endkm", data.getKms().max()); | |
44 } | |
45 else { | |
46 logger.warn("No data to define start and end km"); | |
47 } | |
48 } | |
49 else if (xBounds == null && getDomainAxisRange() != null){ | |
50 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
51 Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); | |
52 Bounds bounds = | |
53 calculateZoom(b, getDomainAxisRange()); | |
54 context.putContextValue("startkm", bounds.getLower()); | |
55 context.putContextValue("endkm", bounds.getUpper()); | |
56 } | |
57 } | |
58 } | |
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |