comparison artifacts/src/main/java/org/dive4elements/river/exports/XYChartGenerator.java @ 9123:1cc7653ca84f

Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
author gernotbelger
date Tue, 05 Jun 2018 19:21:16 +0200
parents 07d51fd4864c
children 7c7f73e5e01e
comparison
equal deleted inserted replaced
9122:b8e7f6becf78 9123:1cc7653ca84f
38 import org.jfree.data.xy.XYSeriesCollection; 38 import org.jfree.data.xy.XYSeriesCollection;
39 import org.json.JSONArray; 39 import org.json.JSONArray;
40 import org.json.JSONException; 40 import org.json.JSONException;
41 41
42 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; 42 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
43 import org.dive4elements.artifacts.CallContext;
43 import org.dive4elements.river.jfree.Bounds; 44 import org.dive4elements.river.jfree.Bounds;
44 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; 45 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
45 import org.dive4elements.river.jfree.DoubleBounds; 46 import org.dive4elements.river.jfree.DoubleBounds;
46 import org.dive4elements.river.jfree.RiverAnnotation; 47 import org.dive4elements.river.jfree.RiverAnnotation;
47 import org.dive4elements.river.jfree.StyledAreaSeriesCollection; 48 import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
48 import org.dive4elements.river.jfree.StyledXYSeries; 49 import org.dive4elements.river.jfree.StyledXYSeries;
49 import org.dive4elements.river.jfree.AxisDataset; 50 import org.dive4elements.river.jfree.AxisDataset;
50 import org.dive4elements.river.jfree.AnnotationHelper;
51 import org.dive4elements.river.themes.ThemeDocument; 51 import org.dive4elements.river.themes.ThemeDocument;
52 52
53 53
54 /** 54 /**
55 * An abstract base class for creating XY charts. 55 * An abstract base class for creating XY charts.
100 100
101 /** 101 /**
102 * Generate the chart anew (including localized axis and all). 102 * Generate the chart anew (including localized axis and all).
103 */ 103 */
104 @Override 104 @Override
105 public JFreeChart generateChart() { 105 protected JFreeChart generateChart(CallContext context) {
106 log.debug("XYChartGenerator.generateChart"); 106 log.debug("XYChartGenerator.generateChart");
107 107
108 JFreeChart chart = ChartFactory.createXYLineChart( 108 JFreeChart chart = ChartFactory.createXYLineChart(
109 getChartTitle(), 109 getChartTitle(context),
110 getXAxisLabel(), 110 getXAxisLabel(),
111 getYAxisLabel(0), 111 getYAxisLabel(0),
112 null, 112 null,
113 PlotOrientation.VERTICAL, 113 PlotOrientation.VERTICAL,
114 isLegendVisible(), 114 isLegendVisible(),
119 ValueAxis axis = createXAxis(getXAxisLabel()); 119 ValueAxis axis = createXAxis(getXAxisLabel());
120 plot.setDomainAxis(axis); 120 plot.setDomainAxis(axis);
121 121
122 chart.setBackgroundPaint(Color.WHITE); 122 chart.setBackgroundPaint(Color.WHITE);
123 plot.setBackgroundPaint(Color.WHITE); 123 plot.setBackgroundPaint(Color.WHITE);
124 addSubtitles(chart); 124 addSubtitles(context, chart);
125 addMetadataSubtitle(chart); 125 addMetadataSubtitle(context, chart);
126 adjustPlot(plot); 126 adjustPlot(plot);
127 127
128 //debugAxis(plot); 128 //debugAxis(plot);
129 129
130 addDatasets(plot); 130 addDatasets(plot);
992 992
993 /** Set to true if x axis has been inverted. */ 993 /** Set to true if x axis has been inverted. */
994 public void setInverted(boolean inverted) { 994 public void setInverted(boolean inverted) {
995 this.inverted = inverted; 995 this.inverted = inverted;
996 } 996 }
997
998 protected void addAnnotationsToRenderer(XYPlot plot) {
999 AnnotationHelper.addAnnotationsToRenderer(annotations, plot,
1000 getChartSettings(), datasets);
1001 }
1002 } 997 }
1003 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 998 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org