comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java @ 3786:4adc35aa655c

merged flys-artifacts/2.9.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:47 +0200
parents 51f76225823b
children 048b3c3acd01
comparison
equal deleted inserted replaced
3719:e82acd5c86f7 3786:4adc35aa655c
1 package de.intevation.flys.artifacts.model;
2
3 import java.io.Serializable;
4
5 public class Range implements Serializable {
6
7 public static final double EPSILON = 1e-5;
8
9 protected double start;
10 protected double end;
11
12 public Range() {
13 }
14
15 public Range(Range other) {
16 start = other.start;
17 end = other.end;
18 }
19
20 public Range(double start, double end) {
21 this.start = start;
22 this.end = end;
23 }
24
25 public double getStart() {
26 return start;
27 }
28
29 public double getEnd() {
30 return end;
31 }
32
33 public boolean disjoint(double ostart, double oend) {
34 return start > oend || ostart > end;
35 }
36
37 public boolean disjoint(Range other) {
38 return start > other.end || other.start > end;
39 }
40
41 public boolean intersects(Range other) {
42 return !disjoint(other);
43 }
44
45 public void extend(Range other) {
46 if (other.start < start) start = other.start;
47 if (other.end > end ) end = other.end;
48 }
49
50 public boolean clip(Range other) {
51 if (disjoint(other)) return false;
52
53 if (other.start > start) start = other.start;
54 if (other.end < end ) end = other.end;
55
56 return true;
57 }
58
59 public boolean inside(double x) {
60 return x > start-EPSILON && x < end+EPSILON;
61 }
62 }
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org