comparison artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java @ 9348:a3f318347707

Show wq outliers within same thems with different symbol: not ready yet
author gernotbelger
date Tue, 31 Jul 2018 11:25:38 +0200
parents 094ed9d1f2ad
children 13bbc75ed0bc
comparison
equal deleted inserted replaced
9344:c08003a68478 9348:a3f318347707
29 import org.dive4elements.river.artifacts.model.fixings.QWI; 29 import org.dive4elements.river.artifacts.model.fixings.QWI;
30 import org.dive4elements.river.artifacts.resources.Resources; 30 import org.dive4elements.river.artifacts.resources.Resources;
31 import org.dive4elements.river.exports.DiagramGenerator; 31 import org.dive4elements.river.exports.DiagramGenerator;
32 import org.dive4elements.river.exports.StyledSeriesBuilder; 32 import org.dive4elements.river.exports.StyledSeriesBuilder;
33 import org.dive4elements.river.exports.fixings.FixWQCurveGenerator; 33 import org.dive4elements.river.exports.fixings.FixWQCurveGenerator;
34 import org.dive4elements.river.java2d.ShapeUtils;
35 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; 34 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
36 import org.dive4elements.river.jfree.JFreeUtil; 35 import org.dive4elements.river.jfree.JFreeUtil;
37 import org.dive4elements.river.jfree.RiverAnnotation; 36 import org.dive4elements.river.jfree.RiverAnnotation;
38 import org.dive4elements.river.jfree.StickyAxisAnnotation; 37 import org.dive4elements.river.jfree.StickyAxisAnnotation;
39 import org.dive4elements.river.jfree.StyledXYSeries; 38 import org.dive4elements.river.jfree.StyledXYSeries;
127 126
128 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 127 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
129 dateFormat.format(qwd.getDate()), 128 dateFormat.format(qwd.getDate()),
130 qwd.getQ(), 129 qwd.getQ(),
131 qwd.getW()); 130 qwd.getW());
132 List<XYTextAnnotation> annos = new ArrayList<XYTextAnnotation>(); 131 List<XYTextAnnotation> annos = new ArrayList<>();
133 annos.add(anno); 132 annos.add(anno);
134 generator.addAxisSeries(series, axisName, visible); 133 generator.addAxisSeries(series, axisName, visible);
135 134
136 if (visible && theme != null && theme.parseShowPointLabel()) { 135 if (visible && theme != null && theme.parseShowPointLabel()) {
137 RiverAnnotation flysAnno = 136 RiverAnnotation flysAnno =
163 } 162 }
164 163
165 // prevent potential side effects 164 // prevent potential side effects
166 final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd); 165 final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
167 166
168 XYSeries series = new StyledXYSeries( 167 final XYSeries series = new StyledXYSeries( bundle.getFacetDescription(), themeInterpolated, FixWQCurveGenerator.getWQDShape(qwd));
169 bundle.getFacetDescription(),
170 themeInterpolated,
171 qwd.getInterpolated()
172 ? ShapeUtils.INTERPOLATED_SHAPE
173 : ShapeUtils.MEASURED_SHAPE);
174
175 series.add(qwd.getQ(), qwd.getW()); 168 series.add(qwd.getQ(), qwd.getW());
176 169
177 generator.addAxisSeries(series, axisName, visible); 170 generator.addAxisSeries(series, axisName, visible);
178 171
179 if (visible && themeInterpolated.parseShowPointLabel()) { 172 if (visible && themeInterpolated.parseShowPointLabel()) {
180 173
181 List<XYTextAnnotation> textAnnos = 174 final List<XYTextAnnotation> textAnnos = new ArrayList<>();
182 new ArrayList<XYTextAnnotation>();
183 175
184 DateFormat dateFormat = DateFormat.getDateInstance( 176 DateFormat dateFormat = DateFormat.getDateInstance(
185 DateFormat.SHORT); 177 DateFormat.SHORT);
186 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 178 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
187 dateFormat.format(qwd.getDate()), 179 dateFormat.format(qwd.getDate()),
188 qwd.getQ(), 180 qwd.getQ(),
189 qwd.getW()); 181 qwd.getW());
190 textAnnos.add(anno); 182 textAnnos.add(anno);
191 183
192 RiverAnnotation flysAnno = 184 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, themeInterpolated);
193 new RiverAnnotation(null, null, null, themeInterpolated);
194 flysAnno.setTextAnnotations(textAnnos); 185 flysAnno.setTextAnnotations(textAnnos);
195 generator.addAnnotations(flysAnno); 186 generator.addAnnotations(flysAnno);
196 } 187 }
197 } 188 }
198 189
211 return; 202 return;
212 } 203 }
213 204
214 final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd); 205 final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
215 206
216 XYSeries series = new StyledXYSeries( 207 final XYSeries series = new StyledXYSeries( bundle.getFacetDescription(), false, true, themeInterpolated, FixWQCurveGenerator.getWQDShape(qwd) );
217 bundle.getFacetDescription(),
218 false, true, themeInterpolated,
219 qwd.getInterpolated()
220 ? ShapeUtils.INTERPOLATED_SHAPE
221 : ShapeUtils.MEASURED_SHAPE);
222
223 series.add(qwd.getQ(), qwd.getW(), false); 208 series.add(qwd.getQ(), qwd.getW(), false);
224 209
225 if (visible && themeInterpolated.parseShowPointLabel()) { 210 if (visible && themeInterpolated.parseShowPointLabel()) {
226 DateFormat dateFormat = DateFormat.getDateInstance( 211 DateFormat dateFormat = DateFormat.getDateInstance(
227 DateFormat.SHORT); 212 DateFormat.SHORT);
229 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 214 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
230 dateFormat.format(qwd.getDate()), 215 dateFormat.format(qwd.getDate()),
231 qwd.getQ(), 216 qwd.getQ(),
232 qwd.getW()); 217 qwd.getW());
233 218
234 List<XYTextAnnotation> textAnnos = 219 List<XYTextAnnotation> textAnnos = new ArrayList<>();
235 new ArrayList<XYTextAnnotation>();
236 textAnnos.add(anno); 220 textAnnos.add(anno);
237 RiverAnnotation flysAnno = 221 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, themeInterpolated);
238 new RiverAnnotation(null, null, null, themeInterpolated);
239 flysAnno.setTextAnnotations(textAnnos); 222 flysAnno.setTextAnnotations(textAnnos);
240 generator.addAnnotations(flysAnno); 223 generator.addAnnotations(flysAnno);
241 } 224 }
242 225
243 generator.addAxisSeries(series, axisName, visible); 226 generator.addAxisSeries(series, axisName, visible);
293 false, true, 276 false, true,
294 theme); 277 theme);
295 DateFormat dateFormat = DateFormat.getDateInstance( 278 DateFormat dateFormat = DateFormat.getDateInstance(
296 DateFormat.SHORT); 279 DateFormat.SHORT);
297 280
298 List<XYTextAnnotation> annos = new ArrayList<XYTextAnnotation>(); 281 List<XYTextAnnotation> annos = new ArrayList<>();
299 282
300 for (QWI qw: qws) { 283 for (QWI qw: qws) {
301 series.add(qw.getQ(), qw.getW(), false); 284 series.add(qw.getQ(), qw.getW(), false);
302 285
303 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 286 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
398 ArtifactAndFacet bundle, 381 ArtifactAndFacet bundle,
399 ThemeDocument theme, 382 ThemeDocument theme,
400 boolean visible 383 boolean visible
401 ) { 384 ) {
402 Object data = bundle.getData(generator.getContext()); 385 Object data = bundle.getData(generator.getContext());
403 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); 386 List<StickyAxisAnnotation> xy = new ArrayList<>();
404 if (data instanceof double[][]) { 387 if (data instanceof double[][]) {
405 log.debug("Got double[][]"); 388 log.debug("Got double[][]");
406 double [][] values = (double [][]) data; 389 double [][] values = (double [][]) data;
407 for (int i = 0; i< values[0].length; i++) { 390 for (int i = 0; i< values[0].length; i++) {
408 xy.add(new StickyAxisAnnotation( 391 xy.add(new StickyAxisAnnotation(
456 XYSeries series = new StyledXYSeries( 439 XYSeries series = new StyledXYSeries(
457 bundle.getFacetDescription(), theme); 440 bundle.getFacetDescription(), theme);
458 Double ckm = (Double) generator.getContext() 441 Double ckm = (Double) generator.getContext()
459 .getContextValue(CURRENT_KM); 442 .getContextValue(CURRENT_KM);
460 443
461 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { 444 if (wqkms.getKms().length == 0 || ckm == null) {
462 log.info("addPointFromWQKms: No event data to show."); 445 log.info("addPointFromWQKms: No event data to show.");
463 return; 446 return;
464 } 447 }
465 448
466 double[] kms = wqkms.getKms(); 449 double[] kms = wqkms.getKms();
469 * Probably to avoid some rounding errors. */ 452 * Probably to avoid some rounding errors. */
470 if (Math.abs(kms[i] - ckm) <= 0.001) { 453 if (Math.abs(kms[i] - ckm) <= 0.001) {
471 series.add(wqkms.getQ(i), wqkms.getW(i), false); 454 series.add(wqkms.getQ(i), wqkms.getW(i), false);
472 generator.addAxisSeries(series, axisName, visible); 455 generator.addAxisSeries(series, axisName, visible);
473 if(visible && theme.parseShowPointLabel()) { 456 if(visible && theme.parseShowPointLabel()) {
474 List<XYTextAnnotation> textAnnos = 457 List<XYTextAnnotation> textAnnos = new ArrayList<>();
475 new ArrayList<XYTextAnnotation>();
476 XYTextAnnotation anno = 458 XYTextAnnotation anno =
477 new CollisionFreeXYTextAnnotation( 459 new CollisionFreeXYTextAnnotation(
478 bundle.getFacetDescription(), 460 bundle.getFacetDescription(),
479 wqkms.getQ(i), 461 wqkms.getQ(i),
480 wqkms.getW(i)); 462 wqkms.getW(i));

http://dive4elements.wald.intevation.org