annotate artifacts/src/main/java/org/dive4elements/river/exports/process/FixDeltaWProcessor.java @ 8472:3f505fba522f

(issue1772) Use 0.001km tolarance instead of 0.1 to find matching km. There is no sense to use a define here. I will not write static final double NULLPOINTNULLNULLONE=0.001 if i just want to use that value and not any other value which may make sense in some other place. Using hardcoded values can have its merits and makes the code easier to read.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 18 Nov 2014 15:24:40 +0100
parents e4606eae8ea5
children 5e38e2924c07
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.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
17 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
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 FixDeltaWProcessor
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(FixDeltaWProcessor.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.yaxis.label.diff";
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]";
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) {
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 CallContext context = generator.getCallContext();
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
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), 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
46
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 // 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
48 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
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 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
51 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
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 // 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
54 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
55 if (bandWidth > 0 ) {
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 XYSeries seriesDown = new 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
57 "band " + bundle.getFacetDescription(), 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
58 XYSeries seriesUp = new 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
59 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
60 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
61 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
62
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 StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(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
64 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
65 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
66 area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 generator.addAreaSeries(area, 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
68 }
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 }
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
ce90d2f4ee46 issue1664: Add new Processors to old axis and map them in longitudinal-diagram-defaults.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 @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
72 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
73 return STATIC_DELTA_W.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
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
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 @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
77 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
78 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
79 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
80 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
81 }
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 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org