comparison artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java @ 7595:ce1b8a59934e

issue1558: Allow fixed axis for timeseries-diagrams.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 21 Nov 2013 17:27:14 +0100
parents 557cb3a3d772
children 8b8407c71ee2
comparison
equal deleted inserted replaced
7594:eb4ca9a7eaca 7595:ce1b8a59934e
120 addValueAxisMarker(plot); 120 addValueAxisMarker(plot);
121 adaptZoom(plot); 121 adaptZoom(plot);
122 122
123 applySeriesAttributes(plot); 123 applySeriesAttributes(plot);
124 124
125 consumeAxisSettings(plot);
126
125 addAnnotationsToRenderer(plot); 127 addAnnotationsToRenderer(plot);
126 addLogo(plot); 128 addLogo(plot);
127 aggregateLegendEntries(plot); 129 aggregateLegendEntries(plot);
128 return chart; 130 return chart;
129 } 131 }
260 XYAnnotation xyannotation = 262 XYAnnotation xyannotation =
261 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor); 263 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor);
262 plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND); 264 plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND);
263 } 265 }
264 266
267 /**
268 * This method zooms the plot to the specified ranges in the attribute
269 * document or to the ranges specified by the min/max values in the
270 * datasets. <b>Note:</b> We determine the range manually if no zoom ranges
271 * are given, because JFreeCharts auto-zoom adds a margin to the left and
272 * right of the data area.
273 *
274 * Copy of implementation in XYChartGenerator.
275 *
276 * @param plot The XYPlot.
277 */
278 protected void consumeAxisSettings(XYPlot plot) {
279 logger.debug("Zoom to specified ranges.");
280
281 Bounds xrange = getDomainAxisRange();
282 Bounds yrange = getValueAxisRange();
283
284 ValueAxis xAxis = plot.getDomainAxis();
285
286 Range fixedXRange = getRangeForAxisFromSettings("X");
287 if (fixedXRange != null) {
288 xAxis.setRange(fixedXRange);
289 }
290 else {
291 zoomX(plot, xAxis, getXBounds(0), xrange);
292 }
293
294 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
295 ValueAxis yaxis = plot.getRangeAxis(i);
296
297 if (yaxis instanceof IdentifiableNumberAxis) {
298 IdentifiableNumberAxis idAxis = (IdentifiableNumberAxis) yaxis;
299
300 Range fixedRange = getRangeForAxisFromSettings(idAxis.getId());
301 if (fixedRange != null) {
302 yaxis.setRange(fixedRange);
303 continue;
304 }
305 }
306
307 if (yaxis == null) {
308 logger.debug("Zoom problem: no Y Axis for index: " + i);
309 continue;
310 }
311
312 logger.debug("Prepare zoom settings for y axis at index: " + i);
313 zoomY(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange);
314 }
315 }
316
265 317
266 @Override 318 @Override
267 protected Series getSeriesOf(XYDataset dataset, int idx) { 319 protected Series getSeriesOf(XYDataset dataset, int idx) {
268 return ((TimeSeriesCollection) dataset).getSeries(idx); 320 return ((TimeSeriesCollection) dataset).getSeries(idx);
269 } 321 }
526 } 578 }
527 } 579 }
528 580
529 581
530 /** 582 /**
531 * Adjusts the axes of a plot. This method sets the <i>labelFont</i> of the 583 * Adjusts the (look of) axes of a plot. This method sets the <i>labelFont</i> of the
532 * X axis. 584 * X axis.
533 * 585 *
534 * (Duplicate in XYChartGenerator). 586 * (Duplicate in XYChartGenerator).
535 * 587 *
536 * @param plot The XYPlot of the chart. 588 * @param plot The XYPlot of the chart.

http://dive4elements.wald.intevation.org