Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2233:958a10e2e246
Added a new ChartGenerator for timeseries charts and refactored some code in XYChartGenerator.
flys-artifacts/trunk@3877 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 02 Feb 2012 12:26:36 +0000 |
parents | 5648b5b34ae2 |
children | 46ec09c7f578 |
comparison
equal
deleted
inserted
replaced
2232:78ac5058da67 | 2233:958a10e2e246 |
---|---|
153 return this.plotAxisIndex; | 153 return this.plotAxisIndex; |
154 } | 154 } |
155 } // class AxisDataset | 155 } // class AxisDataset |
156 | 156 |
157 | 157 |
158 /** | |
159 * A mini interface that allows to walk over the YAXIS enums defined in | |
160 * subclasses. | |
161 */ | |
162 public interface YAxisWalker { | |
163 int length(); | |
164 String getId(int idx); | |
165 } | |
166 | |
167 | |
168 /** Override to make axis information available. */ | 158 /** Override to make axis information available. */ |
169 protected YAxisWalker getYAxisWalker() { | 159 protected YAxisWalker getYAxisWalker() { |
170 return new YAxisWalker() { | 160 return new YAxisWalker() { |
171 /** Get number of items. */ | 161 /** Get number of items. */ |
172 @Override | 162 @Override |
341 * Returns the default X-Axis label of a chart. | 331 * Returns the default X-Axis label of a chart. |
342 * | 332 * |
343 * @return the default X-Axis label of a chart. | 333 * @return the default X-Axis label of a chart. |
344 */ | 334 */ |
345 protected abstract String getDefaultXAxisLabel(); | 335 protected abstract String getDefaultXAxisLabel(); |
346 | |
347 | |
348 /** | |
349 * Returns the Y-Axis label of a chart at position <i>pos</i>. | |
350 * | |
351 * @return the Y-Axis label of a chart at position <i>0</i>. | |
352 */ | |
353 protected String getYAxisLabel(int pos) { | |
354 ChartSettings chartSettings = getChartSettings(); | |
355 if (chartSettings == null) { | |
356 return getDefaultYAxisLabel(pos); | |
357 } | |
358 | |
359 YAxisWalker walker = getYAxisWalker(); | |
360 AxisSection as = chartSettings.getAxisSection(walker.getId(pos)); | |
361 if (as != null) { | |
362 String label = as.getLabel(); | |
363 | |
364 if (label != null) { | |
365 return label; | |
366 } | |
367 } | |
368 | |
369 return getDefaultYAxisLabel(pos); | |
370 } | |
371 | 336 |
372 | 337 |
373 /** | 338 /** |
374 * This method is called to retrieve the default label for an Y axis at | 339 * This method is called to retrieve the default label for an Y axis at |
375 * position <i>pos</i>. | 340 * position <i>pos</i>. |
1484 addAnnotations(annotations, visible); | 1449 addAnnotations(annotations, visible); |
1485 } | 1450 } |
1486 | 1451 |
1487 | 1452 |
1488 /** | 1453 /** |
1489 * Creates a new instance of <i>IdentifiableNumberAxis</i>. | |
1490 * | |
1491 * @param idx The index of the new axis. | |
1492 * @param label The label of the new axis. | |
1493 * | |
1494 * @return an instance of IdentifiableNumberAxis. | |
1495 */ | |
1496 protected NumberAxis createNumberAxis(int idx, String label) { | |
1497 YAxisWalker walker = getYAxisWalker(); | |
1498 | |
1499 return new IdentifiableNumberAxis(walker.getId(idx), label); | |
1500 } | |
1501 | |
1502 | |
1503 /** | |
1504 * Returns an instance of <i>ChartSettings</i> with a chart specific section | 1454 * Returns an instance of <i>ChartSettings</i> with a chart specific section |
1505 * but with no axes settings. | 1455 * but with no axes settings. |
1506 * | 1456 * |
1507 * @return an instance of <i>ChartSettings</i>. | 1457 * @return an instance of <i>ChartSettings</i>. |
1508 */ | 1458 */ |