annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java @ 6570:6435b3d7fb52

Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 15 Jul 2013 14:42:09 +0200
parents
children 7d86ed4537d9
rev   line source
6570
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 *
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 */
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports.process;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.List;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.jfree.data.xy.XYSeries;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import org.w3c.dom.Document;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import org.dive4elements.artifacts.CallContext;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.artifacts.model.FacetTypes;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.exports.StyledSeriesBuilder;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 import org.dive4elements.river.exports.XYChartGenerator;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 import org.dive4elements.river.jfree.StyledXYSeries;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 import org.dive4elements.river.model.BedHeightSingleValue;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 public class BedDiffYearProcessor implements Processor, FacetTypes {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 private final static Logger logger =
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 Logger.getLogger(BedDiffYearProcessor.class);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 @Override
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 public void doOut(
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 XYChartGenerator generator,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 ArtifactAndFacet aandf,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 Document theme,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 boolean visible,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 int axidx
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 ) {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 CallContext context = generator.getCallContext();
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 Object data = aandf.getData(context);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 if (data instanceof BedDiffYearResult) {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 String facetType = aandf.getFacetName();
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 int index =
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 (BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 || BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType))?0:1;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 doBedDifferenceHeightsOut(
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 generator,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 (BedDiffYearResult) data,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 aandf, theme, visible, index, axidx);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 return;
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 logger.error("Can't process " + data.getClass().getName() + " objects");
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 @Override
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 public boolean canHandle(String facetType) {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 return
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 || BED_DIFFERENCE_YEAR_HEIGHT2.equals(facetType)
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 || BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType)
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 || BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED.equals(facetType);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 private void doBedDifferenceHeightsOut(
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 XYChartGenerator generator,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 BedDiffYearResult data,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 ArtifactAndFacet bundle,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 Document attr,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 boolean visible,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 int idx,
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 int axidx) {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 logger.debug("doBedDifferenceHeightsOut()");
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 if (idx == 0) {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), true);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 else {
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), true);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 generator.addAxisSeries(series, axidx, visible);
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 }
6435b3d7fb52 Refactored BedDifferenceYearGenerator to use new BedDiffYearProcessor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org