annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 7991:b57db3a231ba facet-metadata

Removed unused importsRemoved unused imports..
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 02 Jul 2014 12:34:06 +0200
parents 10debf4b82be
children fe67edde6189
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;
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
12 import java.util.Map;
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
13
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 import org.dive4elements.artifacts.CallContext;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import org.dive4elements.river.artifacts.model.FacetTypes;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 import org.dive4elements.river.exports.DiagramGenerator;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 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
19 import org.dive4elements.river.jfree.GapInserter;
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.jfree.StyledXYSeries;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.themes.ThemeDocument;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
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 public class BedWidthProcessor extends DefaultProcessor {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 private final static Logger logger =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 Logger.getLogger(BedWidthProcessor.class);
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 static final String I18N_AXIS_LABEL_DEFAULT =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 "Breite [m]";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 public static final String I18N_AXIS_LABEL =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 "chart.beddifference.yaxis.label.morph";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
35 protected String yAxisLabel;
7981
45cced06490c merged with default.
Raimund Renkert <rrenkert@intevation.de>
parents: 7892 7901
diff changeset
36
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
37 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
38
7145
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();
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
46 Map<String, String> metaData = bundle.getFacet().getMetaData();
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
47 StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 theme);
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
49 series.putMetaData(metaData, bundle.getArtifact(), context);
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
50 yAxisLabel = metaData.get("Y");
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 Object data = bundle.getData(context);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52
7985
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
53 if (data instanceof MorphologicWidth) {
7145
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);
7985
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
56 } else if (data instanceof double[][]) {
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
57 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
58
7985
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
59 double[][]values = (double[][]) data;
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
60 for (int i = 0; i < values[0].length; i++) {
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
61 gi.add(values[0][i], values[1][i]);
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
62 }
7148
cde7db30847f Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents: 7145
diff changeset
63 } else {
cde7db30847f Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents: 7145
diff changeset
64 logger.error("Unknown data for facet: " + bundle.getFacetName());
7145
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 generator.addAxisSeries(series, axisName, visible);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 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
72 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
73 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
74 facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH2) ||
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
75 facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) ||
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
76 facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH);
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
80 public String getAxisLabel(DiagramGenerator generator) {
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
81 if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
82 return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
83 }
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84 return generator.msg(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 I18N_AXIS_LABEL,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 I18N_AXIS_LABEL_DEFAULT);
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 }

http://dive4elements.wald.intevation.org