Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 2175:3f90f4d37c8d
Render manual points in longitudinal sections.
flys-artifacts/trunk@3770 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 26 Jan 2012 13:12:19 +0000 |
parents | ebfca80dae09 |
children | a79d5cd26083 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Thu Jan 26 12:56:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Thu Jan 26 13:12:19 2012 +0000 @@ -29,6 +29,8 @@ import de.intevation.flys.utils.FLYSUtils; import de.intevation.flys.utils.DataUtil; +import org.json.JSONArray; +import org.json.JSONException; /** * An OutGenerator that generates discharge curves. @@ -369,6 +371,11 @@ visible); } + else if (FacetTypes.MANUALPOINTS.equals(name)) { + doPoints(artifactAndFacet.getData(context), + artifactAndFacet.getFacetDescription(), + attr, visible); + } else { logger.warn("Unknown facet name: " + name); return; @@ -532,6 +539,7 @@ } } + /** * Do Area out. */ @@ -611,5 +619,34 @@ // Add area to the respective axis. addAreaSeries(area, axisIdxForFacet(data.getRootFacetName()), visible); } + + + /** + * Do Points out. + */ + protected void doPoints( + Object o, + String seriesName, + Document theme, + boolean visible + ) { + XYSeries series = new StyledXYSeries(seriesName, theme); + + 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); + //logger.debug(" x " + x + " y " + y ); + series.add(x, y, false); + } + } + catch(JSONException e){ + logger.error("Could not decode json."); + } + + addAxisSeries(series, YAXIS.W.idx, visible); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :