Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java @ 3138:9c147bbffc36
FixA: Move Range out of FixingsOverview
flys-artifacts/trunk@4746 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 21 Jun 2012 15:18:46 +0000 |
parents | |
children | 086326be721c |
comparison
equal
deleted
inserted
replaced
3137:3b6ab6fac843 | 3138:9c147bbffc36 |
---|---|
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 : |