annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 9556:9b8e8fc1f408

Use facetName in all processors as themeType for legend aggregation.
author gernotbelger
date Tue, 23 Oct 2018 16:26:58 +0200
parents 1cc7653ca84f
children
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;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.jfree.StyledXYSeries;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.themes.ThemeDocument;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
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 public class BedWidthProcessor extends DefaultProcessor {
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8150
diff changeset
26 private final static Logger log =
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 Logger.getLogger(BedWidthProcessor.class);
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 static final String I18N_AXIS_LABEL_DEFAULT =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 "Breite [m]";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 public static final String I18N_AXIS_LABEL =
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 "chart.beddifference.yaxis.label.morph";
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
34 protected String yAxisLabel;
7981
45cced06490c merged with default.
Raimund Renkert <rrenkert@intevation.de>
parents: 7892 7901
diff changeset
35
8695
5abbccb13e45 (issue1670) We want to see gaps larger than 100 m, not 100 km.
Tom Gottfried <tom@intevation.de>
parents: 8433
diff changeset
36 public static final double GAP_WIDTH = 0.101;
7901
64930ceebac0 Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7834
diff changeset
37
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 public void doOut(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 DiagramGenerator generator,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 ArtifactAndFacet bundle,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 ThemeDocument theme,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 boolean visible) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 8699
diff changeset
44 CallContext context = generator.getContext();
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
45 Map<String, String> metaData = bundle.getFacet().getMetaData();
9556
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9123
diff changeset
46 StyledXYSeries series = new StyledXYSeries(bundle.getFacetName(), bundle.getFacetDescription(),
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 theme);
8150
fe67edde6189 Do not put metadata on series if there are none (avoid NPE).
Tom Gottfried <tom@intevation.de>
parents: 7991
diff changeset
48 if (!metaData.isEmpty()) {
fe67edde6189 Do not put metadata on series if there are none (avoid NPE).
Tom Gottfried <tom@intevation.de>
parents: 7991
diff changeset
49 series.putMetaData(metaData, bundle.getArtifact(), context);
fe67edde6189 Do not put metadata on series if there are none (avoid NPE).
Tom Gottfried <tom@intevation.de>
parents: 7991
diff changeset
50 yAxisLabel = metaData.get("Y");
fe67edde6189 Do not put metadata on series if there are none (avoid NPE).
Tom Gottfried <tom@intevation.de>
parents: 7991
diff changeset
51 }
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 Object data = bundle.getData(context);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53
7985
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
54 if (data instanceof MorphologicWidth) {
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 MorphologicWidth bData = (MorphologicWidth) data;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 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
57 } else if (data instanceof double[][]) {
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
58 double[][]values = (double[][]) data;
8699
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
59 StyledSeriesBuilder.addPoints(series,
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
60 values,
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
61 false,
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
62 GAP_WIDTH);
7148
cde7db30847f Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents: 7145
diff changeset
63 } else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8150
diff changeset
64 log.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) {
8433
706668b19b04 Antiprogramming (in german: 'Softwareabwicklung')
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
72 return facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) ||
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
73 facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH);
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
75
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 public String getAxisLabel(DiagramGenerator generator) {
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
78 if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
79 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
80 }
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
81 return generator.msg(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82 I18N_AXIS_LABEL,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
83 I18N_AXIS_LABEL_DEFAULT);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 }

http://dive4elements.wald.intevation.org