annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 7901:64930ceebac0

Fix for flys/issue1670: Introduce 100m gaps in single bed width.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 26 May 2014 12:40:19 +0200
parents b2a8a94a92f9
children 45cced06490c
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 org.apache.log4j.Logger;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 import org.jfree.data.xy.XYSeries;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
14 import java.util.List;
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
15
7145
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.FacetTypes;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.exports.DiagramGenerator;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.exports.StyledSeriesBuilder;
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
21 import org.dive4elements.river.jfree.GapInserter;
7145
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.themes.ThemeDocument;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
26 import org.dive4elements.river.model.BedHeightSingleValue;
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
27 import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData;
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
28
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
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 public class BedWidthProcessor extends DefaultProcessor {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 private final static Logger logger =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 Logger.getLogger(BedWidthProcessor.class);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 public static final String I18N_AXIS_LABEL_DEFAULT =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 "Breite [m]";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 public static final String I18N_AXIS_LABEL =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 "chart.beddifference.yaxis.label.morph";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
41 public static final double GAP_WIDTH = 100.0;
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
42
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 public void doOut(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 DiagramGenerator generator,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 ArtifactAndFacet bundle,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 ThemeDocument theme,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 boolean visible) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 CallContext context = generator.getCallContext();
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 theme);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 Object data = bundle.getData(context);
7830
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
53 String facetName = bundle.getFacetName();
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54
7830
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
55 if (facetName.equals(FacetTypes.BED_DIFFERENCE_SOUNDING_WIDTH) &&
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
56 data instanceof BedDiffYearResult) {
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 BedDiffYearResult bData = (BedDiffYearResult) data;
7834
b2a8a94a92f9 Draw lines with gaps for sounding width, and bed heights.
Raimund Renkert <rrenkert@intevation.de>
parents: 7830
diff changeset
58 StyledSeriesBuilder.addPoints(
b2a8a94a92f9 Draw lines with gaps for sounding width, and bed heights.
Raimund Renkert <rrenkert@intevation.de>
parents: 7830
diff changeset
59 series,
b2a8a94a92f9 Draw lines with gaps for sounding width, and bed heights.
Raimund Renkert <rrenkert@intevation.de>
parents: 7830
diff changeset
60 bData.getSoundingWidthData(),
b2a8a94a92f9 Draw lines with gaps for sounding width, and bed heights.
Raimund Renkert <rrenkert@intevation.de>
parents: 7830
diff changeset
61 false,
b2a8a94a92f9 Draw lines with gaps for sounding width, and bed heights.
Raimund Renkert <rrenkert@intevation.de>
parents: 7830
diff changeset
62 0.110d);
7830
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
63 } else if (facetName.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH1) &&
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
64 data instanceof BedDiffYearResult) {
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
65 BedDiffYearResult bData = (BedDiffYearResult) data;
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
66 StyledSeriesBuilder.addPoints(series, bData.getMorphWidth1Data(), true);
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
67 } else if (facetName.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH2) &&
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
68 data instanceof BedDiffYearResult) {
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
69 BedDiffYearResult bData = (BedDiffYearResult) data;
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
70 StyledSeriesBuilder.addPoints(series, bData.getMorphWidth2Data(), true);
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 } else if (data instanceof MorphologicWidth) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 MorphologicWidth bData = (MorphologicWidth) data;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 StyledSeriesBuilder.addPoints(series, bData.getAsArray(), true);
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
74 } else if (data instanceof BedHeightSingleData) {
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
75 BedHeightSingleData bData = (BedHeightSingleData)data;
7828
8faa8cfd2385 Renamed the incorrectly named morph width to sounding width.
Raimund Renkert <rrenkert@intevation.de>
parents: 7689
diff changeset
76 double[] width = bData.getSoundingWidths();
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
77 double[] stations = bData.getStations().toNativeArray();
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
78
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
79 GapInserter gi = new GapInserter(series, GAP_WIDTH);
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
80
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
81 for (int i = 0; i < width.length; i++) {
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
82 gi.add(stations[i], width[i]);
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
83 }
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
84 } else if (data instanceof List<?>) {
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
85 List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
86
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
87 for(BedHeightSingleValue bvalue: bData) {
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
88 series.add(bvalue.getStation(), bvalue.getSoundingWidth());
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
89 }
7148
cde7db30847f Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents: 7145
diff changeset
90 } else {
cde7db30847f Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents: 7145
diff changeset
91 logger.error("Unknown data for facet: " + bundle.getFacetName());
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
92 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
93
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
94 generator.addAxisSeries(series, axisName, visible);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
95 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
96
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
97 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
98 public boolean canHandle(String facettype) {
7830
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
99 return facettype.equals(FacetTypes.BED_DIFFERENCE_SOUNDING_WIDTH) ||
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
100 facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH1) ||
d9791fa3c8ad Add new facet for morph active width to bed height difference calculation.
Raimund Renkert <rrenkert@intevation.de>
parents: 7828
diff changeset
101 facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH2) ||
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
102 facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) ||
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
103 facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH);
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
104 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
105
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
106 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
107 public String getAxisLabel(DiagramGenerator generator) {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
108 return generator.msg(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
109 I18N_AXIS_LABEL,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
110 I18N_AXIS_LABEL_DEFAULT);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
111 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
112 }

http://dive4elements.wald.intevation.org