Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 7097:c64c04d0796e generator-refactoring
Move manual point handling into a Processor
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 23 Sep 2013 12:21:08 +0200 |
parents | 5c059c05b100 |
children | 24f153ad1f40 |
comparison
equal
deleted
inserted
replaced
7096:5c059c05b100 | 7097:c64c04d0796e |
---|---|
34 import org.jfree.data.Range; | 34 import org.jfree.data.Range; |
35 import org.jfree.data.general.Series; | 35 import org.jfree.data.general.Series; |
36 import org.jfree.data.xy.XYDataset; | 36 import org.jfree.data.xy.XYDataset; |
37 import org.jfree.data.xy.XYSeries; | 37 import org.jfree.data.xy.XYSeries; |
38 import org.jfree.data.xy.XYSeriesCollection; | 38 import org.jfree.data.xy.XYSeriesCollection; |
39 import org.json.JSONArray; | |
40 import org.json.JSONException; | |
41 | 39 |
42 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | 40 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
43 import org.dive4elements.artifactdatabase.state.Facet; | 41 import org.dive4elements.artifactdatabase.state.Facet; |
44 import org.dive4elements.river.artifacts.D4EArtifact; | 42 import org.dive4elements.river.artifacts.D4EArtifact; |
45 import org.dive4elements.river.exports.process.Processor; | 43 import org.dive4elements.river.exports.process.Processor; |
901 * @param rangeAxis The domain axis that needs localization. | 899 * @param rangeAxis The domain axis that needs localization. |
902 */ | 900 */ |
903 protected void localizeRangeAxis(ValueAxis rangeAxis) { | 901 protected void localizeRangeAxis(ValueAxis rangeAxis) { |
904 NumberFormat nf = NumberFormat.getInstance(getLocale()); | 902 NumberFormat nf = NumberFormat.getInstance(getLocale()); |
905 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf); | 903 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf); |
906 } | |
907 | |
908 | |
909 /** | |
910 * Do Points out. | |
911 */ | |
912 protected void doPoints( | |
913 Object o, | |
914 ArtifactAndFacet aandf, | |
915 ThemeDocument theme, | |
916 boolean visible, | |
917 int axisIndex | |
918 ) { | |
919 String seriesName = aandf.getFacetDescription(); | |
920 XYSeries series = new StyledXYSeries(seriesName, theme); | |
921 | |
922 // Add text annotations for single points. | |
923 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); | |
924 | |
925 try { | |
926 JSONArray points = new JSONArray((String) o); | |
927 for (int i = 0, P = points.length(); i < P; i++) { | |
928 JSONArray array = points.getJSONArray(i); | |
929 double x = array.getDouble(0); | |
930 double y = array.getDouble(1); | |
931 String name = array.getString(2); | |
932 boolean act = array.getBoolean(3); | |
933 if (!act) { | |
934 continue; | |
935 } | |
936 //logger.debug(" x " + x + " y " + y ); | |
937 series.add(x, y, false); | |
938 xy.add(new CollisionFreeXYTextAnnotation(name, x, y)); | |
939 } | |
940 } | |
941 catch(JSONException e){ | |
942 logger.error("Could not decode json."); | |
943 } | |
944 | |
945 RiverAnnotation annotation = new RiverAnnotation(null, null, null, theme); | |
946 annotation.setTextAnnotations(xy); | |
947 | |
948 // Do not generate second legend entry. (null was passed for the aand before). | |
949 if (visible) { | |
950 annotations.add(annotation); | |
951 } | |
952 // doAnnotations(annotations, null, theme, visible); | |
953 addAxisSeries(series, axisIndex, visible); | |
954 } | 904 } |
955 | 905 |
956 | 906 |
957 /** | 907 /** |
958 * Create a hash from a legenditem. | 908 * Create a hash from a legenditem. |