annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java @ 4484:7e82d51c5a27

Improved build script
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 13 Nov 2012 19:03:59 +0100
parents 2f6d4f92d628
children e1ba8273df07
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
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
17 /**
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
18 * Default constructor. <b>A DoubleBounds has always set lower &lt;
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
19 * upper!</b>
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
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) {
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
22 this.lower = Math.min(lower, upper);
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
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
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
51 public void applyBounds(ValueAxis axis, int percent) {
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
52 double space = (upper - lower) / 100 * percent;
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
53 axis.setRange(new Range(lower-space, upper+space));
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
54 }
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
55
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
56
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
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 :

http://dive4elements.wald.intevation.org