comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChart.java @ 846:8b6ef091d38c

It is possible to draw VerticalProfileCharts with just one single data point (issue229). gnv-artifacts/trunk@962 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 21 Apr 2010 08:46:23 +0000
parents 2423cefe7d39
children ec512e7992c6
comparison
equal deleted inserted replaced
845:797a6264b89b 846:8b6ef091d38c
237 addGapsOnGrid(results, series, startPos, endPos); 237 addGapsOnGrid(results, series, startPos, endPos);
238 else 238 else
239 addGaps(results, series, startValue, endValue, startPos, endPos); 239 addGaps(results, series, startValue, endValue, startPos, endPos);
240 } 240 }
241 241
242 @Override
243 protected void prepareAxis(String seriesKey, int idx) {
244 super.prepareAxis(seriesKey, idx);
245
246 XYPlot plot = chart.getXYPlot();
247 NumberAxis domainAxis = (NumberAxis) plot.getRangeAxis();
248 NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis();
249
250 Range domainRange = domainAxis.getRange();
251 Range rangeRange = rangeAxis.getRange();
252 log.debug("Domain axis range before: " + domainRange.toString());
253 log.debug("Range axis range before: " + rangeRange.toString());
254
255 domainRange = Range.expand(domainRange, LOWER_MARGIN, UPPER_MARGIN);
256 rangeRange = Range.expand(rangeRange, LOWER_MARGIN, UPPER_MARGIN);
257
258 double lower = domainRange.getLowerBound();
259 double upper = domainRange.getUpperBound();
260
261 if (lower == upper) {
262 domainRange = new Range(
263 lower - (lower * 0.05d),
264 upper + (upper * 0.05d));
265 }
266
267 log.debug("Domain axis range after: " + domainRange.toString());
268 log.debug("Range axis range after: " + rangeRange.toString());
269 domainAxis.setRange(domainRange);
270 rangeAxis.setRange(rangeRange);
271
272 plot.setRangeAxis(domainAxis);
273 }
274
242 275
243 /** 276 /**
244 * Method to expand max range of a range axis identified by seriesKey. 277 * Method to expand max range of a range axis identified by seriesKey.
245 * <code>LOWER_MARGIN</code> and <code>UPPER_MARGIN</code> are used to 278 * <code>LOWER_MARGIN</code> and <code>UPPER_MARGIN</code> are used to
246 * expand the range. 279 * expand the range.
316 if (datasets.containsKey(key)) { 349 if (datasets.containsKey(key)) {
317 xysc = (XYSeriesCollection)datasets.get(key); 350 xysc = (XYSeriesCollection)datasets.get(key);
318 plot.setDataset(idx, xysc ); 351 plot.setDataset(idx, xysc );
319 log.debug("Added " + key + " parameter to plot."); 352 log.debug("Added " + key + " parameter to plot.");
320 prepareAxis(key, idx); 353 prepareAxis(key, idx);
321 prepareRangeAxis(key, idx);
322 adjustRenderer( 354 adjustRenderer(
323 idx++, 355 idx++,
324 xysc.getSeriesCount(), 356 xysc.getSeriesCount(),
325 linesVisible, 357 linesVisible,
326 shapesVisible 358 shapesVisible

http://dive4elements.wald.intevation.org