annotate artifacts/src/main/java/org/dive4elements/river/exports/process/FixDeltaWAProcessor.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 d8e753d0fdb9
children
rev   line source
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 *
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 */
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports.process;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import org.jfree.data.xy.XYSeries;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import org.dive4elements.artifacts.CallContext;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import org.dive4elements.river.artifacts.model.FacetTypes;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.dive4elements.river.artifacts.model.WKms;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import org.dive4elements.river.exports.StyledSeriesBuilder;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.exports.DiagramGenerator;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.jfree.StyledXYSeries;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.themes.ThemeDocument;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 public class FixDeltaWAProcessor
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 extends DefaultProcessor implements FacetTypes {
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7523
diff changeset
28 private final static Logger log =
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 Logger.getLogger(FixDeltaWAProcessor.class);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 public static final String I18N_AXIS_LABEL =
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 "chart.beddifference.height.yaxis.label";
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 public static final String I18N_AXIS_LABEL_DEFAULT =
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 "delta S [cm / Jahr]";
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 @Override
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 public void doOut(
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 DiagramGenerator generator,
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 ArtifactAndFacet bundle,
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 ThemeDocument theme,
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 boolean visible) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 8856
diff changeset
42 CallContext context = generator.getContext();
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 Object data = bundle.getData(context);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
9556
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9496
diff changeset
45 final String facetName = bundle.getFacetName();
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9496
diff changeset
46
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9496
diff changeset
47 XYSeries series = new StyledXYSeries(facetName,
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
48 bundle.getFacetDescription(), theme);
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 // Handle WKms data.
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 WKms wkms = (WKms) data;
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 StyledSeriesBuilder.addPoints(series, wkms);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 generator.addAxisSeries(series, axisName, visible);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 // If a "band around the curve shall be drawn, add according area.
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 double bandWidth = theme.parseBandWidth();
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 if (bandWidth > 0 ) {
9556
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9496
diff changeset
59 XYSeries seriesDown = new StyledXYSeries(facetName,
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 "band " + bundle.getFacetDescription(), false, theme);
9556
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9496
diff changeset
61 XYSeries seriesUp = new StyledXYSeries(facetName,
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 bundle.getFacetDescription()+"+/-"+bandWidth, false, theme);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 StyledSeriesBuilder.addUpperBand(seriesUp, wkms, bandWidth);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 StyledSeriesBuilder.addLowerBand(seriesDown, wkms, bandWidth);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
66 StyledAreaSeriesCollection area =
9556
9b8e8fc1f408 Use facetName in all processors as themeType for legend aggregation.
gernotbelger
parents: 9496
diff changeset
67 new StyledAreaSeriesCollection(facetName, theme);
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 area.addSeries(seriesUp);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 area.addSeries(seriesDown);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9123
diff changeset
71 generator.addAxisDataset(area, axisName, visible);
7523
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 }
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 }
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 @Override
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 public boolean canHandle(String facetType) {
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 return STATIC_DELTA_W_CMA.equals(facetType);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 }
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 @Override
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 public String getAxisLabel(DiagramGenerator generator) {
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 return generator.msg(
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 I18N_AXIS_LABEL,
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 I18N_AXIS_LABEL_DEFAULT);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 }
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 }
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org