Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 653:67c7020f4ed3
Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
flys-artifacts/trunk@2048 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 03 Jun 2011 07:20:39 +0000 |
parents | 8fa4c5c9cd1a |
children | bbc966c81809 |
comparison
equal
deleted
inserted
replaced
652:8fa4c5c9cd1a | 653:67c7020f4ed3 |
---|---|
67 public void generate() | 67 public void generate() |
68 throws IOException | 68 throws IOException |
69 { | 69 { |
70 logger.debug("XYChartGenerator.generate"); | 70 logger.debug("XYChartGenerator.generate"); |
71 | 71 |
72 JFreeChart chart = generateChart(); | |
73 | |
74 int[] size = getSize(); | |
75 | |
76 ChartExportHelper.exportImage( | |
77 out, | |
78 chart, | |
79 "png", | |
80 size[0], size[1]); | |
81 } | |
82 | |
83 | |
84 public JFreeChart generateChart() { | |
85 logger.debug("XYChartGenerator.generateChart"); | |
86 | |
72 JFreeChart chart = ChartFactory.createXYLineChart( | 87 JFreeChart chart = ChartFactory.createXYLineChart( |
73 getChartTitle(), | 88 getChartTitle(), |
74 getXAxisLabel(), | 89 getXAxisLabel(), |
75 getYAxisLabel(), | 90 getYAxisLabel(), |
76 null, | 91 null, |
86 | 101 |
87 addDatasets(chart); | 102 addDatasets(chart); |
88 addSubtitles(chart); | 103 addSubtitles(chart); |
89 adjustPlot(plot); | 104 adjustPlot(plot); |
90 adjustAxes(plot); | 105 adjustAxes(plot); |
91 | |
92 int[] size = getSize(); | |
93 | |
94 zoom(plot); | 106 zoom(plot); |
95 | 107 |
96 ChartExportHelper.exportImage( | 108 return chart; |
97 out, | |
98 chart, | |
99 "png", | |
100 size[0], size[1]); | |
101 } | 109 } |
102 | 110 |
103 | 111 |
112 /** | |
113 * Zooms the chart to the ranges specified in the attribute document. | |
114 * | |
115 * @param plot The XYPlot. | |
116 */ | |
104 protected void zoom(XYPlot plot) { | 117 protected void zoom(XYPlot plot) { |
105 logger.debug("Zoom to specified ranges."); | 118 logger.debug("Zoom to specified ranges."); |
119 zoomX(plot); | |
120 zoomY(plot); | |
121 } | |
106 | 122 |
123 | |
124 /** | |
125 * Zooms the x axis to the range specified in the attribute document. | |
126 * | |
127 * @param plot The XYPlot. | |
128 */ | |
129 protected void zoomX(XYPlot plot) { | |
107 Range xrange = getDomainAxisRange(); | 130 Range xrange = getDomainAxisRange(); |
108 if (xrange != null) { | 131 if (xrange != null) { |
109 ValueAxis xaxis = plot.getDomainAxis(); | 132 ValueAxis xaxis = plot.getDomainAxis(); |
110 xaxis.setRange(xrange); | 133 xaxis.setRange(xrange); |
111 | 134 |
112 logger.debug("Zoom chart to X: " + xrange); | 135 logger.debug("Zoom chart to X: " + xrange); |
113 } | 136 } |
137 } | |
114 | 138 |
139 | |
140 /** | |
141 * Zooms the y axis to the range specified in the attribute document. | |
142 * | |
143 * @param plot The XYPlot. | |
144 */ | |
145 protected void zoomY(XYPlot plot) { | |
115 Range yrange = getValueAxisRange(); | 146 Range yrange = getValueAxisRange(); |
116 if (yrange != null) { | 147 if (yrange != null) { |
117 ValueAxis yaxis = plot.getRangeAxis(); | 148 ValueAxis yaxis = plot.getRangeAxis(); |
118 yaxis.setRange(yrange); | 149 yaxis.setRange(yrange); |
119 | 150 |