Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 8366:061e85212d25
s/logger/log/ or removed unused logger.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 02 Oct 2014 11:04:14 +0200 |
parents | e4606eae8ea5 |
children | 706668b19b04 |
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 |
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 = |
7145
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 | 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); |
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[][]) { |
7901
64930ceebac0
Fix for flys/issue1670: Introduce 100m gaps in single bed width.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7834
diff
changeset
|
59 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
|
60 |
7985
10debf4b82be
Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents:
7981
diff
changeset
|
61 double[][]values = (double[][]) data; |
10debf4b82be
Split bed differences facet into data specific facets.
Raimund Renkert <rrenkert@intevation.de>
parents:
7981
diff
changeset
|
62 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
|
63 gi.add(values[0][i], values[1][i]); |
7689
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
64 } |
7148
cde7db30847f
Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents:
7145
diff
changeset
|
65 } else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8150
diff
changeset
|
66 log.error("Unknown data for facet: " + bundle.getFacetName()); |
7145
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 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
69 generator.addAxisSeries(series, axisName, visible); |
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 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
72 @Override |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH2) || |
7689
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
77 facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) || |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
78 facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH); |
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
79 } |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
80 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
81 @Override |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
82 public String getAxisLabel(DiagramGenerator generator) { |
7892
e844be34a606
Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents:
7834
diff
changeset
|
83 if (yAxisLabel != null && !yAxisLabel.isEmpty()) { |
e844be34a606
Add metadata to chart series and datasets.
Raimund Renkert <rrenkert@intevation.de>
parents:
7834
diff
changeset
|
84 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
|
85 } |
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
86 return generator.msg( |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
87 I18N_AXIS_LABEL, |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
88 I18N_AXIS_LABEL_DEFAULT); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
89 } |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
90 } |