Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 2719:d1d35892bbdd
Adjusted fixings transitions and implemented event select state.
flys-artifacts/trunk@4450 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 21 May 2012 09:27:32 +0000 |
parents | 6ed24efc80de |
children | a441be7f1589 |
rev | line source |
---|---|
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.flys.artifacts.math.Linear; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.util.Arrays; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.io.Serializable; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 public class FixingsColumn |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 implements Serializable |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 { |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 protected double [] kms; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 protected double [] ws; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 protected QRangeTree qs; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public FixingsColumn() { |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 public FixingsColumn( |
2619
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
21 double [] kms, |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
22 double [] ws, |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
23 QRangeTree qs |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 ) { |
2619
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
25 this.kms = kms; |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
26 this.ws = ws; |
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
27 this.qs = qs; |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
30 public boolean getW(double km, double [] w) { |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
2619
6ed24efc80de
Loaded columns of fixings from database and store them into the cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
32 if (kms.length == 0 || km < kms[0] || km > kms[kms.length-1]) { |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
33 w[0] = Double.NaN; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
34 return true; |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 int idx = Arrays.binarySearch(kms, km); |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
39 if (idx >= 0) { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
40 w[0] = ws[idx]; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
41 return true; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
42 } |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 idx = -idx - 1; |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
46 w[0] = Linear.linear(km, kms[idx], kms[idx+1], ws[idx], ws[idx+1]); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2610
diff
changeset
|
47 return false; |
2610
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 public double getQ(double km) { |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 return qs.findQ(km); |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
3c907758f0ab
Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |