comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 2206:e2124ca11adb

Add manual point handling for many different chart types. flys-artifacts/trunk@3830 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 30 Jan 2012 13:33:18 +0000
parents 7bac5afb9892
children 4cd0eb2ebb3b
comparison
equal deleted inserted replaced
2205:a22e0cb6eace 2206:e2124ca11adb
36 36
37 import org.json.JSONArray; 37 import org.json.JSONArray;
38 import org.json.JSONException; 38 import org.json.JSONException;
39 39
40 /** 40 /**
41 * An OutGenerator that generates discharge curves. 41 * An OutGenerator that generates longitudinal section curves.
42 * 42 *
43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
44 */ 44 */
45 public class LongitudinalSectionGenerator 45 public class LongitudinalSectionGenerator
46 extends XYChartGenerator 46 extends XYChartGenerator
374 artifactAndFacet.getFacetDescription(), 374 artifactAndFacet.getFacetDescription(),
375 attr, 375 attr,
376 visible); 376 visible);
377 377
378 } 378 }
379 else if (FacetTypes.MANUALPOINTS.equals(name)) { 379 else if (FacetTypes.IS.MANUALPOINTS(name)) {
380 doPoints(artifactAndFacet.getData(context), 380 doPoints(artifactAndFacet.getData(context),
381 artifactAndFacet.getFacetDescription(), 381 artifactAndFacet.getFacetDescription(),
382 attr, visible); 382 attr, visible, YAXIS.W.idx);
383 } 383 }
384 else { 384 else {
385 logger.warn("Unknown facet name: " + name); 385 logger.warn("Unknown facet name: " + name);
386 return; 386 return;
387 } 387 }
622 area.addSeries(down); 622 area.addSeries(down);
623 } 623 }
624 // Add area to the respective axis. 624 // Add area to the respective axis.
625 addAreaSeries(area, axisIdxForFacet(data.getRootFacetName()), visible); 625 addAreaSeries(area, axisIdxForFacet(data.getRootFacetName()), visible);
626 } 626 }
627
628
629 /**
630 * Do Points out.
631 */
632 protected void doPoints(
633 Object o,
634 String seriesName,
635 Document theme,
636 boolean visible
637 ) {
638 XYSeries series = new StyledXYSeries(seriesName, theme);
639
640 // Add text annotations for single points.
641 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
642
643 try {
644 JSONArray points = new JSONArray((String) o);
645 for (int i = 0; i < points.length(); i++) {
646 JSONArray array = points.getJSONArray(i);
647 double x = array.getDouble(0);
648 double y = array.getDouble(1);
649 String name = array.getString(2);
650 boolean act = array.getBoolean(3);
651 if (!act) {
652 continue;
653 }
654 //logger.debug(" x " + x + " y " + y );
655 series.add(x, y, false);
656 xy.add(new CollisionFreeXYTextAnnotation(name, x, y));
657 }
658 }
659 catch(JSONException e){
660 logger.error("Could not decode json.");
661 }
662
663 FLYSAnnotation annotations = new FLYSAnnotation(null, null, null, theme);
664 annotations.setTextAnnotations(xy);
665
666 doAnnotations(annotations, null, theme, visible);
667 addAxisSeries(series, YAXIS.W.idx, visible);
668 }
669 } 627 }
670 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 628 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org