annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 7834:b2a8a94a92f9 minfo-opt

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

http://dive4elements.wald.intevation.org