comparison artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java @ 7904:8b8407c71ee2

Potential fix for exception reported in flys/issue1717.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 28 May 2014 12:26:13 +0200
parents ce1b8a59934e
children e4606eae8ea5
comparison
equal deleted inserted replaced
7903:7d4bbe5ca102 7904:8b8407c71ee2
44 import org.jfree.chart.plot.Marker; 44 import org.jfree.chart.plot.Marker;
45 import org.jfree.chart.plot.XYPlot; 45 import org.jfree.chart.plot.XYPlot;
46 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; 46 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
47 import org.jfree.data.Range; 47 import org.jfree.data.Range;
48 import org.jfree.data.general.Series; 48 import org.jfree.data.general.Series;
49 import org.jfree.data.time.Day; 49 import org.jfree.data.time.FixedMillisecond;
50 import org.jfree.data.time.TimeSeries; 50 import org.jfree.data.time.TimeSeries;
51 import org.jfree.data.time.TimeSeriesCollection; 51 import org.jfree.data.time.TimeSeriesCollection;
52 import org.jfree.data.xy.XYDataset; 52 import org.jfree.data.xy.XYDataset;
53 import org.jfree.ui.Layer; 53 import org.jfree.ui.Layer;
54 import org.json.JSONArray; 54 import org.json.JSONArray;
632 String seriesName = aandf.getFacetDescription(); 632 String seriesName = aandf.getFacetDescription();
633 TimeSeries series = new StyledTimeSeries(seriesName, theme); 633 TimeSeries series = new StyledTimeSeries(seriesName, theme);
634 634
635 // Add text annotations for single points. 635 // Add text annotations for single points.
636 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); 636 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
637 HashMap<Day, String> names = new HashMap<Day, String>(); 637 HashMap<FixedMillisecond, String> names = new HashMap<FixedMillisecond, String>();
638 638
639 try { 639 try {
640 JSONArray points = new JSONArray((String) o); 640 JSONArray points = new JSONArray((String) o);
641 for (int i = 0, P = points.length(); i < P; i++) { 641 for (int i = 0, P = points.length(); i < P; i++) {
642 JSONArray array = points.getJSONArray(i); 642 JSONArray array = points.getJSONArray(i);
647 if (!act) { 647 if (!act) {
648 continue; 648 continue;
649 } 649 }
650 650
651 Date date = decodeXAxisValue(array); 651 Date date = decodeXAxisValue(array);
652 652 long ms = date.getTime();
653 Day day = new Day(date); 653
654 FixedMillisecond day = new FixedMillisecond(ms);
655 while (names.containsKey(day)) {
656 day = new FixedMillisecond(++ms);
657 }
654 series.add(day, y, false); 658 series.add(day, y, false);
655 names.put(day, name); 659 names.put(day, name);
656 } 660 }
657 } 661 }
658 catch(JSONException ex) { 662 catch(JSONException ex) {

http://dive4elements.wald.intevation.org