Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Mon Jan 30 13:29:07 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Mon Jan 30 13:33:18 2012 +0000 @@ -65,6 +65,10 @@ import de.intevation.flys.artifacts.model.HYKFactory; +import org.json.JSONArray; +import org.json.JSONException; + + /** * An abstract base class for creating XY charts. * @@ -1634,6 +1638,49 @@ } + /** + * Do Points out. + */ + protected void doPoints( + Object o, + String seriesName, + Document theme, + boolean visible, + int axisIndex + ) { + XYSeries series = new StyledXYSeries(seriesName, theme); + + // Add text annotations for single points. + List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); + + try { + JSONArray points = new JSONArray((String) o); + for (int i = 0; i < points.length(); i++) { + JSONArray array = points.getJSONArray(i); + double x = array.getDouble(0); + double y = array.getDouble(1); + String name = array.getString(2); + boolean act = array.getBoolean(3); + if (!act) { + continue; + } + //logger.debug(" x " + x + " y " + y ); + series.add(x, y, false); + xy.add(new CollisionFreeXYTextAnnotation(name, x, y)); + } + } + catch(JSONException e){ + logger.error("Could not decode json."); + } + + FLYSAnnotation annotations = new FLYSAnnotation(null, null, null, theme); + annotations.setTextAnnotations(xy); + + doAnnotations(annotations, null, theme, visible); + addAxisSeries(series, axisIndex, visible); + } + + /** Two Ranges that span a rectangular area. */ public static class Area { protected Range xRange;