annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
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
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8699
diff changeset
11 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8699
diff changeset
12 import org.apache.logging.log4j.LogManager;
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
13 import java.util.Map;
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
14
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import org.dive4elements.artifacts.CallContext;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 import org.dive4elements.river.artifacts.model.FacetTypes;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 import org.dive4elements.river.exports.DiagramGenerator;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.exports.StyledSeriesBuilder;
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
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8150
diff changeset
27 private final static Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8699
diff changeset
28 LogManager.getLogger(BedWidthProcessor.class);
7145
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
8695
5abbccb13e45 (issue1670) We want to see gaps larger than 100 m, not 100 km.
Tom Gottfried <tom@intevation.de>
parents: 8433
diff changeset
37 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
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);
8150
fe67edde6189 Do not put metadata on series if there are none (avoid NPE).
Tom Gottfried <tom@intevation.de>
parents: 7991
diff changeset
49 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
50 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
51 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
52 }
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 Object data = bundle.getData(context);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54
7985
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
55 if (data instanceof MorphologicWidth) {
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 MorphologicWidth bData = (MorphologicWidth) data;
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 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
58 } else if (data instanceof double[][]) {
10debf4b82be Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7981
diff changeset
59 double[][]values = (double[][]) data;
8699
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
60 StyledSeriesBuilder.addPoints(series,
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
61 values,
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
62 false,
a60a6e7ca24a (issue1670) Remove parallel implementation for gaps in line themes.
Tom Gottfried <tom@intevation.de>
parents: 8695
diff changeset
63 GAP_WIDTH);
7148
cde7db30847f Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents: 7145
diff changeset
64 } else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8150
diff changeset
65 log.error("Unknown data for facet: " + bundle.getFacetName());
7145
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
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 generator.addAxisSeries(series, axisName, visible);
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
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 public boolean canHandle(String facettype) {
8433
706668b19b04 Antiprogramming (in german: 'Softwareabwicklung')
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
73 return facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) ||
7689
4374a8d26706 (issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents: 7159
diff changeset
74 facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH);
7145
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
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 @Override
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 public String getAxisLabel(DiagramGenerator generator) {
7892
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
79 if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
e844be34a606 Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7834
diff changeset
80 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
81 }
7145
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82 return generator.msg(
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
83 I18N_AXIS_LABEL,
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84 I18N_AXIS_LABEL_DEFAULT);
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 }
432047ee5b4b Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 }

http://dive4elements.wald.intevation.org