comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java @ 3651:06a65baae494

merged flys-artifacts/2.9
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:43 +0200
parents 086326be721c
children 51f76225823b
comparison
equal deleted inserted replaced
3549:6a8f83c538e3 3651:06a65baae494
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(Range other) {
34 return start > other.end || other.start > end;
35 }
36
37 public boolean intersects(Range other) {
38 return !disjoint(other);
39 }
40
41 public void extend(Range other) {
42 if (other.start < start) start = other.start;
43 if (other.end > end ) end = other.end;
44 }
45
46 public boolean clip(Range other) {
47 if (disjoint(other)) return false;
48
49 if (other.start > start) start = other.start;
50 if (other.end < end ) end = other.end;
51
52 return true;
53 }
54
55 public boolean inside(double x) {
56 return x > start-EPSILON && x < end+EPSILON;
57 }
58 }
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org