annotate artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.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 e1b49fc9d2b5
children cb33de3434a8
rev   line source
7102
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 *
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 */
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports.process;
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10
7808
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
11 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
12 import org.dive4elements.artifacts.CallContext;
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
13 import org.dive4elements.river.artifacts.D4EArtifact;
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
14 import org.dive4elements.river.artifacts.access.RiverAccess;
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
15 import org.dive4elements.river.artifacts.context.RiverContext;
7102
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import org.dive4elements.river.artifacts.model.FacetTypes;
7808
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
17 import org.dive4elements.river.artifacts.model.ZoomScale;
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
18 import org.dive4elements.river.artifacts.resources.Resources;
7103
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
19 import org.dive4elements.river.exports.DiagramGenerator;
7808
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
20 import org.dive4elements.river.themes.ThemeDocument;
7102
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 public class WDiffProcessor extends WOutProcessor {
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23
7103
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
24 public final static String I18N_WDIFF_YAXIS_LABEL =
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
25 "chart.w_differences.yaxis.label";
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
26
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
27 public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m";
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
28
7808
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
29 public static final String I18N_SUBTITLE_RADIUS =
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
30 "chart.subtitle.radius";
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
31
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
32 @Override
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
33 public void doOut(
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
34 DiagramGenerator generator,
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
35 ArtifactAndFacet bundle,
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
36 ThemeDocument theme,
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
37 boolean visible) {
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
38 CallContext context = generator.getCallContext();
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
39 Double start = (Double)context.getContextValue("startkm");
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
40 Double end = (Double)context.getContextValue("endkm");
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
41 if (start != null && end != null) {
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
42 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
43 RiverContext fc = (RiverContext)context.globalContext();
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
44 // Adaptive smoothing, based on zoom factor/diagram extents.
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
45 ZoomScale scales = (ZoomScale)fc.get("zoomscale");
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
46 RiverAccess access = new RiverAccess((D4EArtifact)artifact);
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
47 String river = access.getRiverName();
8074
bd0dfa57b1fe flys/issue1262: Introduce variable $RADIUS to be used in user defined chart sub titles.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7808
diff changeset
48 double radius = scales.getRadius(river, start, end);
bd0dfa57b1fe flys/issue1262: Introduce variable $RADIUS to be used in user defined chart sub titles.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7808
diff changeset
49 context.putContextValue("radius", radius);
7808
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
50
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
51 generator.addSubtitle(Resources.getMsg(
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
52 context.getMeta(),
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
53 I18N_SUBTITLE_RADIUS,
8076
e1b49fc9d2b5 Fixed sub title zoom stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8074
diff changeset
54 new Object[] { "$RADIUS" }));
7808
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
55 }
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
56 super.doOut(generator, bundle, theme, visible);
ea6b441b4872 Calculate the zoom dependent radius and add the informations to chart subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents: 7793
diff changeset
57 }
7102
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 @Override
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 public boolean canHandle(String facetType) {
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 if (facetType == null) {
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 return false;
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 }
7793
3841303a9158 Add the new facet to drawable facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7118
diff changeset
63 return facetType.equals(FacetTypes.W_DIFFERENCES) ||
3841303a9158 Add the new facet to drawable facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 7118
diff changeset
64 facetType.equals(FacetTypes.W_DIFFERENCES_FILTERED);
7102
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 }
7103
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
66
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
67
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
68 @Override
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
69 public String getAxisLabel(DiagramGenerator generator) {
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
70 return generator.msg(I18N_WDIFF_YAXIS_LABEL,
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
71 I18N_WDIFF_YAXIS_LABEL_DEFAULT);
5009b151f146 Add AxisLabel handling to WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents: 7102
diff changeset
72 }
7102
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 }
13a842224694 Add WDiffProcessor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org