annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java @ 5803:948be49754c5

Removed obsolete import.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 24 Apr 2013 09:10:48 +0200
parents e1ba8273df07
children
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;
5673
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
5 import org.jfree.chart.axis.LogarithmicAxis;
2327
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 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
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 /**
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 * @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
11 */
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 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
13
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 lower;
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 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
16
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
18 /**
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
19 * 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
20 * upper!</b>
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
21 */
2327
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 public DoubleBounds(double lower, double upper) {
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
23 this.lower = Math.min(lower, upper);
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
24 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 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
30 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 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
36 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 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
42 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
3650
cbe2febe30cc Merged revisions 5391-5392 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2399
diff changeset
46 /**
cbe2febe30cc Merged revisions 5391-5392 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2399
diff changeset
47 * Set extended range to ValueAxis.
cbe2febe30cc Merged revisions 5391-5392 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2399
diff changeset
48 * @param percent how many percent to extend (in each direction,
cbe2febe30cc Merged revisions 5391-5392 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2399
diff changeset
49 * thus 10 percent on [0,100] -> [-10,110].
cbe2febe30cc Merged revisions 5391-5392 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2399
diff changeset
50 */
2327
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 @Override
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
52 public void applyBounds(ValueAxis axis, int percent) {
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
53 double space = (upper - lower) / 100 * percent;
5673
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
54 if (axis instanceof LogarithmicAxis) {
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
55 axis.setRange(new Range(Math.max(lower-space, 0.0001),
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
56 Math.max(upper+space, 0.0002)));
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
57 } else {
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
58 axis.setRange(new Range(lower-space, upper+space));
e1ba8273df07 Add saveguard not to include 0 in a scale for logarithmic axes
Andre Heinecke <aheinecke@intevation.de>
parents: 3968
diff changeset
59 }
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
60 }
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
61
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
62
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2327
diff changeset
63 @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
64 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
65 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
66 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 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
70
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 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
72 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
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 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
75 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
76 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 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
82 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
83 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org