Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java @ 9123:1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
author | gernotbelger |
---|---|
date | Tue, 05 Jun 2018 19:21:16 +0200 |
parents | 5e38e2924c07 |
children |
rev | line source |
---|---|
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 * |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.exports; |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 |
7157
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
11 import org.dive4elements.river.artifacts.D4EArtifact; |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
12 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
13 import org.dive4elements.artifacts.CallContext; |
7157
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
14 import org.dive4elements.river.jfree.Bounds; |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
15 import org.dive4elements.river.themes.ThemeDocument; |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
16 import org.dive4elements.river.artifacts.model.FacetTypes; |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
17 import org.dive4elements.river.artifacts.access.RiverAccess; |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.ZoomScale; |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
19 import org.dive4elements.river.artifacts.context.RiverContext; |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
20 import org.dive4elements.river.artifacts.resources.Resources; |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
21 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
22 import org.jfree.data.Range; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
23 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
24 import java.util.List; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
25 import java.util.ArrayList; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
26 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
27 import org.apache.log4j.Logger; |
7157
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
28 |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 public class LongitudinalSectionGenerator2 extends DiagramGenerator |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 { |
8856 | 31 private static Logger log = Logger.getLogger( |
32 LongitudinalSectionGenerator2.class); | |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
33 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
34 /** Wrapper around the doOut info for postprocessing. */ |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
35 protected static class SuperBundle |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
36 { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
37 public ArtifactAndFacet bundle; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
38 public ThemeDocument theme; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
39 boolean visible; |
8856 | 40 public SuperBundle( |
41 ArtifactAndFacet bundle, | |
42 ThemeDocument theme, | |
43 boolean visible | |
44 ) { | |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
45 this.bundle = bundle; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
46 this.theme = theme; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
47 this.visible = visible; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
48 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
49 }; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
50 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
51 protected List<SuperBundle> postOutAF; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
52 |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 public static final String I18N_CHART_SHORT_SUBTITLE = |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
54 "chart.longitudinal.section.shortsubtitle"; |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
55 |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 public static final String I18N_CHART_LOCATION_SUBTITLE = |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
57 "chart.longitudinal.section.locsubtitle"; |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
58 |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
59 public static final String I18N_CHART_DISTANCE_SUBTITLE = |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
60 "chart.longitudinal.section.subtitle"; |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
61 |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
62 public static final String I18N_SUBTITLE_RADIUS = |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
63 "chart.subtitle.radius"; |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
64 |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
65 @Override |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
66 public String getDefaultChartSubtitle(final CallContext context) { |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
67 double[] dist = getRange(); |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
68 |
7807
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
69 String parts = ""; |
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
70 if (subTitleParts != null && !subTitleParts.isEmpty()) { |
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
71 for (String p : subTitleParts) { |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
72 parts += " " + p; |
7807
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
73 } |
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
74 } |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
75 if (dist == null || dist.length != 2 || |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
76 Double.isNaN(dist[0]) || Double.isNaN(dist[1])) { |
7118
4605d6ca4ee9
Removed obsolete imports. Minor code cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7107
diff
changeset
|
77 Object [] args = new Object[] {getRiverName()}; |
7807
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
78 return msg(I18N_CHART_SHORT_SUBTITLE, "", args) + parts; |
7118
4605d6ca4ee9
Removed obsolete imports. Minor code cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7107
diff
changeset
|
79 } |
4605d6ca4ee9
Removed obsolete imports. Minor code cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7107
diff
changeset
|
80 |
4605d6ca4ee9
Removed obsolete imports. Minor code cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7107
diff
changeset
|
81 if (Math.abs(dist[0] - dist[1]) < 1E-5) { |
4605d6ca4ee9
Removed obsolete imports. Minor code cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7107
diff
changeset
|
82 Object [] args = new Object[] {getRiverName(), dist[1]}; |
7807
ad4a3980092f
Concatenate the subtitle parts and add them to the default subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7168
diff
changeset
|
83 return msg(I18N_CHART_LOCATION_SUBTITLE, "", args) + parts; |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
84 } |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
85 Object [] args = new Object[] {getRiverName(), dist[0], dist[1]}; |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
86 return msg(I18N_CHART_DISTANCE_SUBTITLE, "", args) + parts; |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
87 } |
7157
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
88 |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
89 protected void calculateRadius() { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
90 // Fixed range in settings is preferred |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
91 Range candidate = getRangeForAxisFromSettings("X"); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
92 Bounds dataBounds = getXBounds(0); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
93 if (candidate == null) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
94 candidate = getDomainAxisRange(); // Diagram is zoomed |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
95 if (candidate != null && dataBounds == null) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
96 log.debug("Can't calculate the zoom without any X bounds."); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
97 candidate = null; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
98 } else if (candidate != null) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
99 // domainAxisRange is relative so we have to take |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
100 // this into account. |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
101 Bounds bounds = |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
102 calculateZoom(dataBounds, candidate); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
103 candidate = new Range(bounds.getLower().doubleValue(), |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
104 bounds.getUpper().doubleValue()); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
105 log.debug("Using X Range from zoom."); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
106 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
107 } else { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
108 log.debug("Using X Range from settings."); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
109 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
110 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
111 if (candidate == null) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
112 if (dataBounds == null) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
113 // Diagram is empty. |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
114 candidate = new Range(0d, 0d); |
8725
68827654ea7a
(issue1754) Fix check for empty data bounds
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8723
diff
changeset
|
115 log.debug("Empty diagram using fake Range"); |
68827654ea7a
(issue1754) Fix check for empty data bounds
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8723
diff
changeset
|
116 } else { |
68827654ea7a
(issue1754) Fix check for empty data bounds
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8723
diff
changeset
|
117 // Diagram is not zoomed |
68827654ea7a
(issue1754) Fix check for empty data bounds
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8723
diff
changeset
|
118 candidate = new Range(dataBounds.getLower().doubleValue(), |
68827654ea7a
(issue1754) Fix check for empty data bounds
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8723
diff
changeset
|
119 dataBounds.getUpper().doubleValue()); |
68827654ea7a
(issue1754) Fix check for empty data bounds
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8723
diff
changeset
|
120 log.debug("Using Full X Range."); |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
121 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
122 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
123 log.debug("startkm for Radius is: " + candidate.getLowerBound() + |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
124 " endkm: " + candidate.getUpperBound()); |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
125 |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
126 // This might not be neccessary if every facet uses only the |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
127 // radius and does not do its own zoomscale calculation. |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
128 final CallContext context = getContext(); |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
129 context.putContextValue("startkm", candidate.getLowerBound()); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
130 context.putContextValue("endkm", candidate.getUpperBound()); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
131 context.putContextValue("bounds_defined", true); |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
132 |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
133 RiverContext fc = (RiverContext)context.globalContext(); |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
134 ZoomScale scales = (ZoomScale)fc.get("zoomscale"); |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
135 RiverAccess access = new RiverAccess((D4EArtifact)getMaster()); |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
136 String river = access.getRiverName(); |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
137 |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
138 double radius = scales.getRadius(river, candidate.getLowerBound(), |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
139 candidate.getUpperBound()); |
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
140 context.putContextValue("radius", radius); |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
141 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
142 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
143 @Override |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
144 protected void postProcess() { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
145 if (postOutAF == null) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
146 log.debug("PostProcess without bundles to process"); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
147 return; |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
148 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
149 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
150 // fake startkm and endkm for the dry run |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
151 final CallContext context = getContext(); |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
152 context.putContextValue("startkm", 0d); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
153 context.putContextValue("endkm", 42d); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
154 for (SuperBundle superbundle: postOutAF) { |
8789
d199860fb087
Remove trailing whitespace.
Tom Gottfried <tom@intevation.de>
parents:
8737
diff
changeset
|
155 // Dry run with fake start /end |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
156 // to get the filtered facets also included |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
157 // in the x axis range. |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
158 super.doOut(superbundle.bundle, superbundle.theme, false); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
159 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
160 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
161 calculateRadius(); // This calculates the real start and end km's |
8730
cb33de3434a8
(issue1754) Proper subtitle handling for Radius
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8725
diff
changeset
|
162 |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
163 for (SuperBundle superbundle: postOutAF) { |
8856 | 164 super.doOut( |
165 superbundle.bundle, | |
166 superbundle.theme, | |
167 superbundle.visible); | |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
168 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
169 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
170 |
7157
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
171 /* We override doOut here to save the startkm and endkm in the |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
172 * context. Some facets will deliver different data because of |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
173 * that setting. It is mainly used in MINFO where it causes |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
174 * adaptive smoothing on the data if you are zoomed out do |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
175 * reduce the static in the curve. */ |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
176 @Override |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
177 public void doOut( |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
178 ArtifactAndFacet bundle, |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
179 ThemeDocument theme, |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
180 boolean visible |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
181 ) { |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
182 String facetName = bundle.getFacetName(); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
183 if (FacetTypes.IS.FILTERED(facetName)) { |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
184 // We can only process the filtered (smoothed) facets |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
185 // after we know the diagram's extend to correctly calculate |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
186 // the radius of the filter / smoothing operation. So |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
187 // we postprocess them. |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
188 |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
189 SuperBundle superbundle = new SuperBundle(bundle, theme, visible); |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
190 if (postOutAF == null) { |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
191 postOutAF = new ArrayList<>(); |
8723
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
192 } |
686d8876edf9
(issue1754) Fix Radius calculation for filtered (smoothed) facets
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8722
diff
changeset
|
193 postOutAF.add(superbundle); |
8731
bccc476e78eb
(issue1754) Remove default subtitle hack
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8730
diff
changeset
|
194 if (visible) { |
bccc476e78eb
(issue1754) Remove default subtitle hack
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8730
diff
changeset
|
195 log.debug("Adding radius subtitle."); |
bccc476e78eb
(issue1754) Remove default subtitle hack
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8730
diff
changeset
|
196 |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
197 addSubtitle(msg(I18N_SUBTITLE_RADIUS) + ": $RADIUS"); |
8731
bccc476e78eb
(issue1754) Remove default subtitle hack
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8730
diff
changeset
|
198 } |
7877
43f18dc56c5a
Fixed subtitle handling and added flowvelocity subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7807
diff
changeset
|
199 return; |
43f18dc56c5a
Fixed subtitle handling and added flowvelocity subtitle.
Raimund Renkert <rrenkert@intevation.de>
parents:
7807
diff
changeset
|
200 } |
7157
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
201 super.doOut(bundle, theme, visible); |
ab109ae2acc6
Add startkm and endkm setting to longitudinal section generator 2
Andre Heinecke <aheinecke@intevation.de>
parents:
7118
diff
changeset
|
202 } |
7105
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
203 } |
ab57b6eee71c
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
204 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |