annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/ReferenceGaugeState.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/states/ReferenceGaugeState.java@bd047b71ab37
children 4897a58c8746
rev   line source
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
1 package org.dive4elements.river.artifacts.states;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
4174
eaf83d4ae6b1 Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4049
diff changeset
3 import java.util.Collections;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.w3c.dom.Element;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
8 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
9 import org.dive4elements.artifacts.CallContext;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
11 import org.dive4elements.artifacts.common.utils.XMLUtils;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
13 import org.dive4elements.river.model.Gauge;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
14 import org.dive4elements.river.model.River;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
15
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
16 import org.dive4elements.river.artifacts.FLYSArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
17 import org.dive4elements.river.utils.FLYSUtils;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 /**
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 */
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 public class ReferenceGaugeState extends DefaultState {
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
2207
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
25 public static final String DATA_NAME = "reference_gauge";
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
26
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
27
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 @Override
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 protected Element[] createItems(
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 XMLUtils.ElementCreator cr,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 Artifact artifact,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 String name,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 CallContext context)
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 {
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 River river = FLYSUtils.getRiver((FLYSArtifact) artifact);
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 List<Gauge> gauges = river.getGauges();
4433
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4432
diff changeset
37 Collections.sort(gauges);
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 int num = gauges != null ? gauges.size() : 0;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 Element[] opts = new Element[num];
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 for (int i = 0; i < num; i++ ) {
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 Gauge g = gauges.get(i);
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 String gaugeName = g.getName();
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 long officialNumber = g.getOfficialNumber();
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 opts[i] = createItem(
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 cr, new String[] { gaugeName, String.valueOf(officialNumber) });
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 }
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 return opts;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 }
2207
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
55
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
56
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
57 @Override
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
58 protected String getLabelFor(
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
59 CallContext cc,
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
60 String name,
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
61 String value,
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
62 String type
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
63 ) {
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
64 if (name.equals(DATA_NAME)) {
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
65 try {
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
66 long number = Long.valueOf(value);
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
67 Gauge gauge = Gauge.getGaugeByOfficialNumber(number);
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
68
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
69 if (gauge != null) {
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
70 return gauge.getName();
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
71 }
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
72 }
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
73 catch (NumberFormatException nfe) {
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
74 // do nothing
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
75 }
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
76 }
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
77
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
78 return super.getLabelFor(cc, name, value, type);
a38f43f626f5 Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
79 }
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 }
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org