comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java @ 5343:61f4d4164a30

Doc, cosmetics.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 20 Mar 2013 12:25:25 +0100
parents 05eeedc5b156
children f987d25627aa
comparison
equal deleted inserted replaced
5342:7b119fa1e29f 5343:61f4d4164a30
30 30
31 protected String name; 31 protected String name;
32 32
33 protected int gaugeId; 33 protected int gaugeId;
34 34
35 /** Certain main value. */
35 protected Map<String, Double> mainValues; 36 protected Map<String, Double> mainValues;
37
36 protected List<Sector> sectors; 38 protected List<Sector> sectors;
39
37 40
38 public GaugeRange() { 41 public GaugeRange() {
39 } 42 }
40 43
44
41 public GaugeRange(double start, double end, int gaugeId) { 45 public GaugeRange(double start, double end, int gaugeId) {
42 this(start, end, null, gaugeId); 46 this(start, end, null, gaugeId);
43 } 47 }
48
44 49
45 public GaugeRange( 50 public GaugeRange(
46 double start, 51 double start,
47 double end, 52 double end,
48 String name, 53 String name,
53 this.gaugeId = gaugeId; 58 this.gaugeId = gaugeId;
54 mainValues = new HashMap<String, Double>(); 59 mainValues = new HashMap<String, Double>();
55 sectors = new ArrayList<Sector>(3); 60 sectors = new ArrayList<Sector>(3);
56 } 61 }
57 62
63
58 public void addMainValue(String label, Double value) { 64 public void addMainValue(String label, Double value) {
59 int idx = label.indexOf('('); 65 int idx = label.indexOf('(');
60 if (idx >= 0) { 66 if (idx >= 0) {
61 label = label.substring(0, idx); 67 label = label.substring(0, idx);
62 } 68 }
63 mainValues.put(label, value); 69 mainValues.put(label, value);
64 } 70 }
71
65 72
66 protected Double getMainValue(String label) { 73 protected Double getMainValue(String label) {
67 Double v = mainValues.get(label); 74 Double v = mainValues.get(label);
68 if (v == null) { 75 if (v == null) {
69 log.warn("Missing main value '" 76 log.warn("Missing main value '"
90 sectors.add(new Sector(c, value)); 97 sectors.add(new Sector(c, value));
91 } 98 }
92 } 99 }
93 } 100 }
94 101
102
95 public double getSectorBorder(int sector) { 103 public double getSectorBorder(int sector) {
96 for (Sector s: sectors) { 104 for (Sector s: sectors) {
97 if (s.sector == sector) { 105 if (s.sector == sector) {
98 return s.value; 106 return s.value;
99 } 107 }
100 } 108 }
101 return Double.NaN; 109 return Double.NaN;
102 } 110 }
111
103 112
104 public int classify(double value) { 113 public int classify(double value) {
105 for (Sector sector: sectors) { 114 for (Sector sector: sectors) {
106 if (value < sector.value) { 115 if (value < sector.value) {
107 return sector.sector; 116 return sector.sector;
108 } 117 }
109 } 118 }
110 return sectors.size(); 119 return sectors.size();
111 } 120 }
112 121
122
113 public String getName() { 123 public String getName() {
114 return name; 124 return name;
115 } 125 }
116 126
127
117 public void setName(String name) { 128 public void setName(String name) {
118 this.name = name; 129 this.name = name;
119 } 130 }
131
120 132
121 public String toString() { 133 public String toString() {
122 StringBuilder sb = new StringBuilder("sectors: ["); 134 StringBuilder sb = new StringBuilder("sectors: [");
123 135
124 for (int i = 0, S = sectors.size(); i < S; ++i) { 136 for (int i = 0, S = sectors.size(); i < S; ++i) {

http://dive4elements.wald.intevation.org