Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Sieve.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Sieve.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.model.sq; | |
2 | |
3 import java.util.Comparator; | |
4 | |
5 public class Sieve | |
6 { | |
7 public static final double EPSILON = 1e-6; | |
8 | |
9 public static final Comparator<Double> DIAMETER_CMP = | |
10 new Comparator<Double>() { | |
11 @Override | |
12 public int compare(Double a, Double b) { | |
13 double diff = a - b; | |
14 if (diff < -EPSILON) return -1; | |
15 if (diff > EPSILON) return +1; | |
16 return 0; | |
17 } | |
18 }; | |
19 | |
20 protected double diameter; | |
21 protected double load; | |
22 | |
23 /** | |
24 * Constructs a new instance. | |
25 */ | |
26 public Sieve() { | |
27 this(Double.NaN, Double.NaN); | |
28 } | |
29 | |
30 public Sieve(double diameter, double load) { | |
31 this.diameter = diameter; | |
32 this.load = load; | |
33 } | |
34 | |
35 /** | |
36 * Gets the diameter for this instance. | |
37 * | |
38 * @return The diameter. | |
39 */ | |
40 public double getDiameter() { | |
41 return this.diameter; | |
42 } | |
43 | |
44 /** | |
45 * Sets the diameter for this instance. | |
46 * | |
47 * @param diameter The diameter. | |
48 */ | |
49 public void setDiameter(double diameter) { | |
50 this.diameter = diameter; | |
51 } | |
52 | |
53 /** | |
54 * Gets the load for this instance. | |
55 * | |
56 * @return The load. | |
57 */ | |
58 public double getLoad() { | |
59 return this.load; | |
60 } | |
61 | |
62 /** | |
63 * Sets the load for this instance. | |
64 * | |
65 * @param load The load. | |
66 */ | |
67 public void setLoad(double load) { | |
68 this.load = load; | |
69 } | |
70 | |
71 public boolean matchesDiameter(double diameter) { | |
72 return Math.abs(diameter - this.diameter) < EPSILON; | |
73 } | |
74 | |
75 public boolean hasDiameter() { | |
76 return !Double.isNaN(diameter); | |
77 } | |
78 } | |
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |