comparison flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java @ 1695:0c9f7cc2cc11

In WDifferenceCurveGenerator use slightly modified doWOut-implementation of LongitudinalSectionGenerator. flys-artifacts/trunk@2922 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 10 Oct 2011 10:27:45 +0000
parents bdb05dc9b763
children 13a9ee6cebef
comparison
equal deleted inserted replaced
1694:2b9f0ca1449b 1695:0c9f7cc2cc11
17 import de.intevation.flys.artifacts.FLYSArtifact; 17 import de.intevation.flys.artifacts.FLYSArtifact;
18 import de.intevation.flys.artifacts.model.FacetTypes; 18 import de.intevation.flys.artifacts.model.FacetTypes;
19 import de.intevation.flys.artifacts.model.WKms; 19 import de.intevation.flys.artifacts.model.WKms;
20 20
21 import de.intevation.flys.utils.DataUtil; 21 import de.intevation.flys.utils.DataUtil;
22 import de.intevation.flys.model.River;
23
24 import de.intevation.flys.artifacts.WINFOArtifact;
25 22
26 import de.intevation.flys.artifacts.model.WQKms; 23 import de.intevation.flys.artifacts.model.WQKms;
27 import de.intevation.flys.utils.FLYSUtils;
28 24
29 25
30 26
31 /** 27 /**
32 * An OutGenerator that generates w differences curves. 28 * An OutGenerator that generates w differences curves.
43 "chart.w_differences.title"; 39 "chart.w_differences.title";
44 40
45 public static final String I18N_CHART_SUBTITLE = 41 public static final String I18N_CHART_SUBTITLE =
46 "chart.w_differences.subtitle"; 42 "chart.w_differences.subtitle";
47 43
44 public static final String I18N_YAXIS_LABEL =
45 "chart.w_differences.yaxis.label";
46
48 public static final String I18N_2YAXIS_LABEL = 47 public static final String I18N_2YAXIS_LABEL =
49 "chart.w_differences.yaxis.second.label"; 48 "chart.w_differences.yaxis.second.label";
50 49
51 // TODO proper i18n. 50 // TODO proper i18n.
52 public static final String I18N_CHART_TITLE_DEFAULT = "W-Differenzen"; 51 public static final String I18N_CHART_TITLE_DEFAULT = "W-Differenzen";
98 f.getDescription(), 97 f.getDescription(),
99 attr, 98 attr,
100 visible); 99 visible);
101 } 100 }
102 else if (name.equals(LONGITUDINAL_W)) { 101 else if (name.equals(LONGITUDINAL_W)) {
103 WINFOArtifact flysArtifact = (WINFOArtifact) artifact; 102 doWOut((WQKms) f.getData(artifact, context), attr, visible);
104 facet = flysArtifact.getNativeFacet(facet); 103 }
105 104 else {
106 doWaterlevelOut(
107 (WQKms) facet.getData(artifact, context),
108 f.getDescription(),
109 attr,
110 flysArtifact,
111 visible);
112
113 }
114 else {
115 logger.warn("Unknown facet name: " + name); 105 logger.warn("Unknown facet name: " + name);
116 return; 106 return;
117 } 107 }
118 } 108 }
119 109
120 110
121 /** 111 /**
122 * Add the waterlevel-curves (the "absolutes" from which 112 * Add the waterlevel-curves (the "absolutes" from which
123 * differences were calculated). 113 * differences were calculated).
114 *
124 * @param wqkms The wqkms to add to the diagram. 115 * @param wqkms The wqkms to add to the diagram.
125 */ 116 * @param theme The theme that contains styling information.
126 public void doWaterlevelOut(WQKms wqkms, 117 */
127 String description, 118 @Override
128 Document theme, 119 protected void doWOut(WQKms wqkms, Document theme, boolean visible) {
129 WINFOArtifact flysArtifact, 120 logger.debug("WDifferencesCurveGenerator.doWOut");
130 boolean visible 121
131 ) { 122 XYSeries series = new StyledXYSeries(getSeriesName(wqkms, "W"), theme);
132 String wqkmsName = wqkms.getName(); 123
133 124 int size = wqkms.size();
134 River river = FLYSUtils.getRiver(flysArtifact);
135
136 if (river == null) {
137 logger.warn("no river found");
138 return;
139 }
140
141 logger.debug("WDifferencesCurveGenerator.doWaterlevelOut, gauge: " +
142 wqkmsName);
143 /*
144 Gauge gauge = river.determineGaugeByName(wqkmsName);
145
146 if (gauge == null) {
147 logger.warn("no gauge found");
148 return;
149 }
150 */
151
152
153 double [][] values = new double [][] {
154 wqkms.getKms(), wqkms.getWs() };
155
156 int size = values != null ? values[0].length : 0;
157
158 String seriesName = wqkmsName;
159 //getSeriesName(gauge);
160
161 XYSeries series = new StyledXYSeries(seriesName, theme);
162 125
163 for (int i = 0; i < size; i++) { 126 for (int i = 0; i < size; i++) {
164 series.add(values[0][i], values[1][i]); 127 series.add(wqkms.getKm(i), wqkms.getW(i));
165 } 128 }
166 129
130 // Note: the only difference in the super-implementation
131 // (in LongitudinalSectionGenerator) is here (adds with
132 // addFirstAxisSeries() .
167 addSecondAxisSeries(series, visible); 133 addSecondAxisSeries(series, visible);
168 } 134
135 if (needInvertAxis(wqkms)) {
136 setInverted(true);
137 }
138 }
139
169 140
170 /** 141 /**
171 * Add items to dataseries which describes the differences. 142 * Add items to dataseries which describes the differences.
172 */ 143 */
173 protected void doWDifferencesOut( 144 protected void doWDifferencesOut(

http://dive4elements.wald.intevation.org