comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java @ 3318:dbe2f85bf160

merged flys-artifacts/2.8
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:35 +0200
parents 9c147bbffc36
children 086326be721c
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
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(double start, double end) {
16 this.start = start;
17 this.end = end;
18 }
19
20 public double getStart() {
21 return start;
22 }
23
24 public double getEnd() {
25 return end;
26 }
27
28 public boolean disjoint(Range other) {
29 return start > other.end || other.start > end;
30 }
31
32 public boolean intersects(Range other) {
33 return !disjoint(other);
34 }
35
36 public void extend(Range other) {
37 if (other.start < start) start = other.start;
38 if (other.end > end ) end = other.end;
39 }
40
41 public boolean clip(Range other) {
42 if (disjoint(other)) return false;
43
44 if (other.start > start) start = other.start;
45 if (other.end < end ) end = other.end;
46
47 return true;
48 }
49
50 public boolean inside(double x) {
51 return x > start-EPSILON && x < end+EPSILON;
52 }
53 }
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org