Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/MinMaxStepNaviChartStepper.java @ 9263:abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
Allows for distinct values stepping of sinfo flood duration.
author | gernotbelger |
---|---|
date | Tue, 17 Jul 2018 19:48:18 +0200 |
parents | |
children |
rev | line source |
---|---|
9263
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
2 * Software engineering by |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
5 * |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
9 */ |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
10 package org.dive4elements.river.client.client.ui.chart; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
11 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
12 /** |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
13 * 'Old' stepping behaviour of the navi chart, as used by WINFO and Fixierungsanalyse. |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
14 * |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
15 * @author Gernot Belger |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
16 */ |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
17 public class MinMaxStepNaviChartStepper implements INaviChartStepper { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
18 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
19 private double currentKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
20 private final double minKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
21 private final double maxKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
22 private final double step; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
23 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
24 public MinMaxStepNaviChartStepper(final double minKm, final double maxKm, final double step) { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
25 this.minKm = minKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
26 this.maxKm = maxKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
27 this.step = step; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
28 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
29 this.currentKm = minKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
30 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
31 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
32 @Override |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
33 public double getCurrentKm() { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
34 return this.currentKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
35 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
36 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
37 @Override |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
38 public double stepForward() { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
39 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
40 if (this.currentKm >= this.maxKm) |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
41 this.currentKm = this.maxKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
42 else { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
43 // Why this math? |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
44 double newVal = this.currentKm * 100; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
45 newVal += this.step / 10; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
46 this.currentKm = (double) Math.round(newVal) / 100; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
47 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
48 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
49 return this.currentKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
50 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
51 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
52 @Override |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
53 public double stepBackward() { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
54 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
55 if (this.currentKm <= this.minKm) |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
56 this.currentKm = this.minKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
57 else { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
58 // Why this math? |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
59 double newVal = this.currentKm * 100; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
60 newVal -= this.step / 10; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
61 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
62 this.currentKm = ((double) Math.round(newVal) / 100); |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
63 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
64 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
65 return this.currentKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
66 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
67 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
68 @Override |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
69 public double setValidCurrentKm(final double userInput) { |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
70 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
71 if (userInput > this.maxKm) |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
72 this.currentKm = this.maxKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
73 else if (userInput < this.minKm) |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
74 this.currentKm = this.minKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
75 else |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
76 this.currentKm = userInput; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
77 |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
78 return this.currentKm; |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
79 } |
abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
gernotbelger
parents:
diff
changeset
|
80 } |