annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 7145:432047ee5b4b

Add BedWidthProcessor to handle width facets This can probably be combined with the BedHeightSoundingProcessor but currently they should also both write to differently labled axes.
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 25 Sep 2013 15:07:41 +0200
parents
children cde7db30847f
rev   line source
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 *
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 */
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports.process;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 import java.util.List;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 import org.jfree.data.xy.XYSeries;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 import org.dive4elements.artifacts.CallContext;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.artifacts.model.FacetTypes;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.exports.DiagramGenerator;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.exports.StyledSeriesBuilder;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.jfree.StyledXYSeries;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 import org.dive4elements.river.model.BedHeightSingleValue;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 import org.dive4elements.river.themes.ThemeDocument;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 public class BedWidthProcessor extends DefaultProcessor {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 private final static Logger logger =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 Logger.getLogger(BedWidthProcessor.class);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 public static final String I18N_AXIS_LABEL_DEFAULT =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 "Breite [m]";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 public static final String I18N_AXIS_LABEL =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 "chart.beddifference.yaxis.label.morph";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 public void doOut(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 DiagramGenerator generator,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 ArtifactAndFacet bundle,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 ThemeDocument theme,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 boolean visible) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 CallContext context = generator.getCallContext();
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 theme);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 Object data = bundle.getData(context);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 if (data instanceof BedDiffYearResult) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 BedDiffYearResult bData = (BedDiffYearResult) data;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 StyledSeriesBuilder.addPoints(series, bData.getMorphWidthData(), true);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 } else if (data instanceof MorphologicWidth) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 MorphologicWidth bData = (MorphologicWidth) data;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 StyledSeriesBuilder.addPoints(series, bData.getAsArray(), true);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 generator.addAxisSeries(series, axisName, visible);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 public boolean canHandle(String facettype) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63 return facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH) ||
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
66
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 public String getAxisLabel(DiagramGenerator generator) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69 return generator.msg(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 I18N_AXIS_LABEL,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 I18N_AXIS_LABEL_DEFAULT);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 }

http://dive4elements.wald.intevation.org