Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java @ 2240:e9173de1026c
The HistoricalDischargeCurveGenerator now creates new AxisDataset objects and new TimeSeriesCollections for each Facet.
flys-artifacts/trunk@3887 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 02 Feb 2012 16:39:50 +0000 |
parents | 60615235e951 |
children | 2b232871ba28 |
rev | line source |
---|---|
2237
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.jfree.data.Range; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import org.jfree.data.xy.XYDataset; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 /** |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 */ |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 public class ChartHelper { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 /** |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 * This method returns the ranges of the XYDataset <i>dataset</i> as array |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 * with [xrange, yrange]. |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 * @param dataset The dataset which should be evaluated. |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 * |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 * @return an array with x and y ranges. |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 */ |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 public static Range[] getRanges(XYDataset dataset) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 if (dataset == null) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 return null; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 double minX = Double.MAX_VALUE; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 double maxX = -Double.MAX_VALUE; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 double minY = Double.MAX_VALUE; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 double maxY = -Double.MAX_VALUE; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 for (int i = 0, m = dataset.getSeriesCount(); i < m; i++) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 for (int j = 0, n = dataset.getItemCount(i); j < n; j++) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 double x = dataset.getXValue(i, j); |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 double y = dataset.getYValue(i, j); |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 if (x < minX) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 minX = x; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 if (x > maxX) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 maxX = x; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 if (y < minY) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 minY = y; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 if (y > maxY) { |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 maxY = y; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 return new Range[] { new Range(minX, maxX), new Range(minY, maxY) }; |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
60615235e951
Added a ChartHelper class that currently contains a method to compute the xy ranges of an XYDataset.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |