comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.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 73490b828a90
children 5648b5b34ae2
comparison
equal deleted inserted replaced
2205:a22e0cb6eace 2206:e2124ca11adb
62 import de.intevation.flys.jfree.StyledXYSeries; 62 import de.intevation.flys.jfree.StyledXYSeries;
63 63
64 import de.intevation.flys.utils.ThemeAccess; 64 import de.intevation.flys.utils.ThemeAccess;
65 65
66 import de.intevation.flys.artifacts.model.HYKFactory; 66 import de.intevation.flys.artifacts.model.HYKFactory;
67
68 import org.json.JSONArray;
69 import org.json.JSONException;
70
67 71
68 /** 72 /**
69 * An abstract base class for creating XY charts. 73 * An abstract base class for creating XY charts.
70 * 74 *
71 * With respect to datasets, ranges and axis, there are following requirements: 75 * With respect to datasets, ranges and axis, there are following requirements:
1632 1636
1633 return axisSections; 1637 return axisSections;
1634 } 1638 }
1635 1639
1636 1640
1641 /**
1642 * Do Points out.
1643 */
1644 protected void doPoints(
1645 Object o,
1646 String seriesName,
1647 Document theme,
1648 boolean visible,
1649 int axisIndex
1650 ) {
1651 XYSeries series = new StyledXYSeries(seriesName, theme);
1652
1653 // Add text annotations for single points.
1654 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
1655
1656 try {
1657 JSONArray points = new JSONArray((String) o);
1658 for (int i = 0; i < points.length(); i++) {
1659 JSONArray array = points.getJSONArray(i);
1660 double x = array.getDouble(0);
1661 double y = array.getDouble(1);
1662 String name = array.getString(2);
1663 boolean act = array.getBoolean(3);
1664 if (!act) {
1665 continue;
1666 }
1667 //logger.debug(" x " + x + " y " + y );
1668 series.add(x, y, false);
1669 xy.add(new CollisionFreeXYTextAnnotation(name, x, y));
1670 }
1671 }
1672 catch(JSONException e){
1673 logger.error("Could not decode json.");
1674 }
1675
1676 FLYSAnnotation annotations = new FLYSAnnotation(null, null, null, theme);
1677 annotations.setTextAnnotations(xy);
1678
1679 doAnnotations(annotations, null, theme, visible);
1680 addAxisSeries(series, axisIndex, visible);
1681 }
1682
1683
1637 /** Two Ranges that span a rectangular area. */ 1684 /** Two Ranges that span a rectangular area. */
1638 public static class Area { 1685 public static class Area {
1639 protected Range xRange; 1686 protected Range xRange;
1640 protected Range yRange; 1687 protected Range yRange;
1641 1688

http://dive4elements.wald.intevation.org