Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java @ 3880:e7f99e30997c
Added CSV export to bed quality calculation.
flys-artifacts/trunk@5517 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 19 Sep 2012 08:50:23 +0000 |
parents | 7b14d00bca8a |
children | 2f6d4f92d628 |
rev | line source |
---|---|
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.jfree; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import org.jfree.chart.axis.ValueAxis; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.jfree.data.Range; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 /** |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 */ |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 public class DoubleBounds implements Bounds { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 protected double lower; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 protected double upper; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
2397
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
17 /** |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
18 * Default constructor. <b>A DoubleBounds has always set lower < |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
19 * upper!</b> |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
20 */ |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public DoubleBounds(double lower, double upper) { |
2397
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
22 this.lower = Math.min(lower, upper); |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
23 this.upper = Math.max(lower, upper); |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public Number getLower() { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 return Double.valueOf(lower); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 public Number getUpper() { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 return Double.valueOf(upper); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public void applyBounds(ValueAxis axis) { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 axis.setRange(new Range(lower, upper)); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
3723
7b14d00bca8a
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2399
diff
changeset
|
45 /** |
7b14d00bca8a
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2399
diff
changeset
|
46 * Set extended range to ValueAxis. |
7b14d00bca8a
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2399
diff
changeset
|
47 * @param percent how many percent to extend (in each direction, |
7b14d00bca8a
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2399
diff
changeset
|
48 * thus 10 percent on [0,100] -> [-10,110]. |
7b14d00bca8a
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2399
diff
changeset
|
49 */ |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 @Override |
2399
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
51 public void applyBounds(ValueAxis axis, int percent) { |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
52 double space = (upper - lower) / 100 * percent; |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
53 axis.setRange(new Range(lower-space, upper+space)); |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
54 } |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
55 |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
56 |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
57 @Override |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 public Bounds combine(Bounds bounds) { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 if (bounds == null) { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 return this; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 DoubleBounds other = (DoubleBounds) bounds; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 double otherLower = other.getLower().doubleValue(); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 double otherUpper = other.getUpper().doubleValue(); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 return new DoubleBounds( |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 otherLower < lower ? otherLower : lower, |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 otherUpper > upper ? otherUpper : upper); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 public String toString() { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 return "DoubleBounds=[" + lower + " ; " + upper + "]"; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |