Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/VegetationZoneServerClientXChange.java @ 9523:d421c2bf0195
Allow to edit colors in vegetation zones
author | gernotbelger |
---|---|
date | Mon, 01 Oct 2018 17:08:50 +0200 |
parents | 853f2dafc16e |
children |
comparison
equal
deleted
inserted
replaced
9522:23d97d60b889 | 9523:d421c2bf0195 |
---|---|
5 * | 5 * |
6 * This file is Free Software under the GNU AGPL (>=v3) | 6 * This file is Free Software under the GNU AGPL (>=v3) |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 | |
11 package org.dive4elements.river.client.shared.model; | 10 package org.dive4elements.river.client.shared.model; |
12 | 11 |
13 import java.util.ArrayList; | 12 import java.util.ArrayList; |
14 import java.util.List; | 13 import java.util.List; |
15 import java.util.TreeSet; | 14 import java.util.TreeSet; |
19 * | 18 * |
20 */ | 19 */ |
21 public class VegetationZoneServerClientXChange implements Comparable<VegetationZoneServerClientXChange> { | 20 public class VegetationZoneServerClientXChange implements Comparable<VegetationZoneServerClientXChange> { |
22 | 21 |
23 // IMMER ABGLEICHEN MIT VegetationZoneServerClientXChange.class IM SERVER | 22 // IMMER ABGLEICHEN MIT VegetationZoneServerClientXChange.class IM SERVER |
24 public static final boolean HAS_COLORS_EDITABLE = false; | |
25 | 23 |
26 private static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | 24 private static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; |
25 | |
27 private static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; | 26 private static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; |
27 | |
28 private final String zoneName; | 28 private final String zoneName; |
29 | |
29 private final int min_day_overflow; | 30 private final int min_day_overflow; |
31 | |
30 private final int max_day_overflow; | 32 private final int max_day_overflow; |
33 | |
31 private final String hexColor; | 34 private final String hexColor; |
32 | 35 |
33 public static List<VegetationZoneServerClientXChange> parse(final String zonesRaw) { | 36 public static List<VegetationZoneServerClientXChange> parse(final String zonesRaw) { |
34 final List<VegetationZoneServerClientXChange> resultList = new ArrayList<VegetationZoneServerClientXChange>(); | 37 final List<VegetationZoneServerClientXChange> resultList = new ArrayList<VegetationZoneServerClientXChange>(); |
35 | 38 |
76 return this.zoneName; | 79 return this.zoneName; |
77 } | 80 } |
78 | 81 |
79 public String getHexColor() { | 82 public String getHexColor() { |
80 try { | 83 try { |
81 final int test = Integer.decode(this.hexColor); | 84 // REMARK: only return valid colors |
85 Integer.decode(this.hexColor); | |
82 return this.hexColor; | 86 return this.hexColor; |
83 } | 87 } |
84 catch (final NumberFormatException e) { | 88 catch (final NumberFormatException e) { |
89 e.printStackTrace(); | |
85 return "#ffffff"; | 90 return "#ffffff"; |
86 } | 91 } |
87 } | 92 } |
88 | 93 |
89 public int getMin_day_overflow() { | 94 public int getMin_day_overflow() { |
90 return this.min_day_overflow; | 95 return this.min_day_overflow; |
91 } | |
92 | |
93 public static final List<VegetationZoneServerClientXChange> getStandardList() { | |
94 | |
95 final List<VegetationZoneServerClientXChange> list = new ArrayList<VegetationZoneServerClientXChange>(); | |
96 list.add(new VegetationZoneServerClientXChange("Zonaler Wald", 0, 5, "#336600")); | |
97 list.add(new VegetationZoneServerClientXChange("Hartholzaue, trocken", 6, 40, "#00cc00")); | |
98 list.add(new VegetationZoneServerClientXChange("Hartholzaue, feucht", 41, 80, "#66ff33")); | |
99 list.add(new VegetationZoneServerClientXChange("Silberweidenwald", 81, 140, "#008080")); | |
100 list.add(new VegetationZoneServerClientXChange("Weidengebüsch", 141, 200, "#33cccc")); | |
101 list.add(new VegetationZoneServerClientXChange("Uferröhricht", 201, 260, "#ffa8ff")); | |
102 list.add(new VegetationZoneServerClientXChange("Uferpioniere", 261, 320, "#ff0000")); | |
103 list.add(new VegetationZoneServerClientXChange("Vegetationslos", 321, 364, "#b2b2b2")); | |
104 list.add(new VegetationZoneServerClientXChange("Wasserfläche", 365, 365, "#0066ff")); | |
105 | |
106 return list; | |
107 } | 96 } |
108 | 97 |
109 public static final String parseListToDataString(final List<VegetationZoneServerClientXChange> list) { | 98 public static final String parseListToDataString(final List<VegetationZoneServerClientXChange> list) { |
110 | 99 |
111 java.util.Collections.sort(list); | 100 java.util.Collections.sort(list); |
176 final int otherLower = otherZone.getLowerFromTo(); | 165 final int otherLower = otherZone.getLowerFromTo(); |
177 final int otherUpper = otherZone.getUpperFromTo(); | 166 final int otherUpper = otherZone.getUpperFromTo(); |
178 | 167 |
179 final int upper = getUpperFromTo(); | 168 final int upper = getUpperFromTo(); |
180 final int lower = getLowerFromTo(); | 169 final int lower = getLowerFromTo(); |
181 // final int otherSchwerpunkt = (otherLower + otherUpper) / 2; | |
182 if ((otherUpper <= upper && otherUpper > lower)) { | 170 if ((otherUpper <= upper && otherUpper > lower)) { |
183 return true; | 171 return true; |
184 } else if (otherLower >= lower && otherLower < upper) { | 172 } else if (otherLower >= lower && otherLower < upper) { |
185 return true; | 173 return true; |
186 } else if (otherLower == lower && otherUpper == upper) { | 174 } else if (otherLower == lower && otherUpper == upper) { |
194 } | 182 } |
195 | 183 |
196 public Integer getUpperFromTo() { | 184 public Integer getUpperFromTo() { |
197 return this.min_day_overflow > this.max_day_overflow ? this.min_day_overflow : this.max_day_overflow;// Math. is forbidden :-( | 185 return this.min_day_overflow > this.max_day_overflow ? this.min_day_overflow : this.max_day_overflow;// Math. is forbidden :-( |
198 } | 186 } |
199 | |
200 } | 187 } |