annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java @ 4248:fc742c039f30

Add model for MeasurementStation client side Add a client mode representing the MeasurementStation
author Björn Ricks <bjoern.ricks@intevation.de>
date Wed, 24 Oct 2012 16:57:53 +0200
parents 51f76225823b
children 048b3c3acd01
rev   line source
3138
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.io.Serializable;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 public class Range implements Serializable {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 public static final double EPSILON = 1e-5;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 protected double start;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 protected double end;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 public Range() {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
3401
086326be721c FixA: Overview: classify Q ranges by intersecting gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3138
diff changeset
15 public Range(Range other) {
086326be721c FixA: Overview: classify Q ranges by intersecting gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3138
diff changeset
16 start = other.start;
086326be721c FixA: Overview: classify Q ranges by intersecting gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3138
diff changeset
17 end = other.end;
086326be721c FixA: Overview: classify Q ranges by intersecting gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3138
diff changeset
18 }
086326be721c FixA: Overview: classify Q ranges by intersecting gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3138
diff changeset
19
3138
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public Range(double start, double end) {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 this.start = start;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 this.end = end;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 public double getStart() {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 return start;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 public double getEnd() {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 return end;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
3743
51f76225823b Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3401
diff changeset
33 public boolean disjoint(double ostart, double oend) {
51f76225823b Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3401
diff changeset
34 return start > oend || ostart > end;
51f76225823b Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3401
diff changeset
35 }
51f76225823b Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3401
diff changeset
36
3138
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 public boolean disjoint(Range other) {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 return start > other.end || other.start > end;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public boolean intersects(Range other) {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 return !disjoint(other);
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 public void extend(Range other) {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 if (other.start < start) start = other.start;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 if (other.end > end ) end = other.end;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 public boolean clip(Range other) {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 if (disjoint(other)) return false;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 if (other.start > start) start = other.start;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 if (other.end < end ) end = other.end;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 return true;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 public boolean inside(double x) {
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 return x > start-EPSILON && x < end+EPSILON;
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
9c147bbffc36 FixA: Move Range out of FixingsOverview
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org