source: osm/applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java@ 27155

Last change on this file since 27155 was 27155, checked in by malcolmh, 13 years ago

save

File size: 63.2 KB
Line 
1package oseam.seamarks;
2
3import java.awt.*;
4import javax.swing.*;
5import java.util.*;
6
7import org.openstreetmap.josm.Main;
8import org.openstreetmap.josm.data.osm.Node;
9import org.openstreetmap.josm.command.ChangePropertyCommand;
10
11import oseam.Messages;
12import oseam.dialogs.OSeaMAction;
13
14public class SeaMark {
15
16 public OSeaMAction dlg = null;
17
18 public SeaMark(OSeaMAction dia) {
19 dlg = dia;
20 }
21
22 public enum Reg {
23 A, B, C, R, X
24 }
25
26 public static final EnumMap<Reg, String> RegSTR = new EnumMap<Reg, String>(Reg.class);
27 static {
28 RegSTR.put(Reg.A, "iala-a");
29 RegSTR.put(Reg.B, "iala-b");
30 RegSTR.put(Reg.C, "cevni");
31 RegSTR.put(Reg.R, "riwr");
32 RegSTR.put(Reg.X, "other");
33 }
34
35 private Reg region = Reg.A;
36
37 public Reg getRegion() {
38 return region;
39 }
40
41 public void setRegion(Reg reg) {
42 region = reg;
43 }
44
45 private String name = "";
46
47 public String getName() {
48 return name;
49 }
50
51 public void setName(String str) {
52 name = str.trim();
53 }
54
55 public enum Obj {
56 UNKNOWN, BCNCAR, BCNISD, BCNLAT, BCNSAW, BCNSPP,
57 BOYCAR, BOYISD, BOYLAT, BOYSAW, BOYSPP,
58 FLTCAR, FLTISD, FLTLAT, FLTSAW, FLTSPP,
59 LITMAJ, LITMIN, LITFLT, LITVES, LITHSE, LNDMRK,
60 MORFAC, SISTAW, SISTAT
61 }
62
63 public static final EnumMap<Obj, String> ObjSTR = new EnumMap<Obj, String>(Obj.class);
64 static {
65 ObjSTR.put(Obj.BCNCAR, "beacon_cardinal");
66 ObjSTR.put(Obj.BCNISD, "beacon_isolated_danger");
67 ObjSTR.put(Obj.BCNLAT, "beacon_lateral");
68 ObjSTR.put(Obj.BCNSAW, "beacon_safe_water");
69 ObjSTR.put(Obj.BCNSPP, "beacon_special_purpose");
70 ObjSTR.put(Obj.BOYCAR, "buoy_cardinal");
71 ObjSTR.put(Obj.BOYISD, "buoy_isolated_danger");
72 ObjSTR.put(Obj.BOYLAT, "buoy_lateral");
73 ObjSTR.put(Obj.BOYSAW, "buoy_safe_water");
74 ObjSTR.put(Obj.BOYSPP, "buoy_special_purpose");
75 ObjSTR.put(Obj.FLTCAR, "light_float");
76 ObjSTR.put(Obj.FLTLAT, "light_float");
77 ObjSTR.put(Obj.FLTSAW, "light_float");
78 ObjSTR.put(Obj.FLTISD, "light_float");
79 ObjSTR.put(Obj.FLTSPP, "light_float");
80 ObjSTR.put(Obj.LITMAJ, "light_major");
81 ObjSTR.put(Obj.LITMIN, "light_minor");
82 ObjSTR.put(Obj.LITFLT, "light_float");
83 ObjSTR.put(Obj.LITVES, "light_vessel");
84 ObjSTR.put(Obj.LNDMRK, "landmark");
85 ObjSTR.put(Obj.LITHSE, "landmark");
86 ObjSTR.put(Obj.MORFAC, "mooring");
87 ObjSTR.put(Obj.SISTAW, "signal_station_warning");
88 ObjSTR.put(Obj.SISTAT, "signal_station_traffic");
89 }
90
91 private Obj object = Obj.UNKNOWN;
92
93 public Obj getObject() {
94 return object;
95 }
96
97 public void setObject(Obj obj) {
98 object = obj;
99 }
100
101 public enum Ent {
102 BODY, BUOY, BEACON, FLOAT, TOPMARK, LIGHT, MOORING, STATION
103 }
104
105 public static final EnumMap<Obj, Ent> EntMAP = new EnumMap<Obj, Ent>(Obj.class);
106 static {
107 EntMAP.put(Obj.BCNCAR, Ent.BEACON);
108 EntMAP.put(Obj.BCNISD, Ent.BEACON);
109 EntMAP.put(Obj.BCNLAT, Ent.BEACON);
110 EntMAP.put(Obj.BCNSAW, Ent.BEACON);
111 EntMAP.put(Obj.BCNSPP, Ent.BEACON);
112 EntMAP.put(Obj.BOYCAR, Ent.BUOY);
113 EntMAP.put(Obj.BOYISD, Ent.BUOY);
114 EntMAP.put(Obj.BOYLAT, Ent.BUOY);
115 EntMAP.put(Obj.BOYSAW, Ent.BUOY);
116 EntMAP.put(Obj.BOYSPP, Ent.BUOY);
117 EntMAP.put(Obj.LITMAJ, Ent.LIGHT);
118 EntMAP.put(Obj.LITMIN, Ent.LIGHT);
119 EntMAP.put(Obj.LITFLT, Ent.FLOAT);
120 EntMAP.put(Obj.FLTCAR, Ent.FLOAT);
121 EntMAP.put(Obj.FLTLAT, Ent.FLOAT);
122 EntMAP.put(Obj.FLTSAW, Ent.FLOAT);
123 EntMAP.put(Obj.FLTISD, Ent.FLOAT);
124 EntMAP.put(Obj.FLTSPP, Ent.FLOAT);
125 EntMAP.put(Obj.LITVES, Ent.FLOAT);
126 EntMAP.put(Obj.LITHSE, Ent.LIGHT);
127 EntMAP.put(Obj.LNDMRK, Ent.LIGHT);
128 EntMAP.put(Obj.MORFAC, Ent.MOORING);
129 EntMAP.put(Obj.SISTAW, Ent.STATION);
130 EntMAP.put(Obj.SISTAT, Ent.STATION);
131 }
132
133 public enum Grp {
134 NUL, LAT, CAR, SAW, ISD, SPP, LIT, SIS
135 }
136
137 public static final EnumMap<Obj, Grp> GrpMAP = new EnumMap<Obj, Grp>(Obj.class);
138 static {
139 GrpMAP.put(Obj.UNKNOWN, Grp.NUL);
140 GrpMAP.put(Obj.BCNCAR, Grp.CAR);
141 GrpMAP.put(Obj.BCNISD, Grp.ISD);
142 GrpMAP.put(Obj.BCNLAT, Grp.LAT);
143 GrpMAP.put(Obj.BCNSAW, Grp.SAW);
144 GrpMAP.put(Obj.BCNSPP, Grp.SPP);
145 GrpMAP.put(Obj.BOYCAR, Grp.CAR);
146 GrpMAP.put(Obj.BOYISD, Grp.ISD);
147 GrpMAP.put(Obj.BOYLAT, Grp.LAT);
148 GrpMAP.put(Obj.BOYSAW, Grp.SAW);
149 GrpMAP.put(Obj.BOYSPP, Grp.SPP);
150 GrpMAP.put(Obj.FLTCAR, Grp.CAR);
151 GrpMAP.put(Obj.FLTLAT, Grp.LAT);
152 GrpMAP.put(Obj.FLTSAW, Grp.SAW);
153 GrpMAP.put(Obj.FLTISD, Grp.ISD);
154 GrpMAP.put(Obj.FLTSPP, Grp.SPP);
155 GrpMAP.put(Obj.LITFLT, Grp.LIT);
156 GrpMAP.put(Obj.LITMAJ, Grp.LIT);
157 GrpMAP.put(Obj.LITMIN, Grp.LIT);
158 GrpMAP.put(Obj.LITVES, Grp.LIT);
159 GrpMAP.put(Obj.LITHSE, Grp.LIT);
160 GrpMAP.put(Obj.LNDMRK, Grp.LIT);
161 GrpMAP.put(Obj.MORFAC, Grp.SPP);
162 GrpMAP.put(Obj.SISTAW, Grp.SIS);
163 GrpMAP.put(Obj.SISTAT, Grp.SIS);
164 }
165
166 public enum Cat {
167 NONE, LAM_PORT, LAM_STBD, LAM_PPORT, LAM_PSTBD, CAM_NORTH, CAM_EAST, CAM_SOUTH, CAM_WEST,
168 ACH_URST, ACH_DEEP, ACH_TANK, ACH_EXPL, ACH_QUAR, ACH_SPLN, ACH_SCAN, ACH_SCMO, ACH_T24H, ACH_TLIM,
169 SPM_UNKN, SPM_WARN, SPM_CHBF, SPM_YCHT, SPM_CABL, SPM_OFAL, SPM_ODAS, SPM_RECN, SPM_MOOR, SPM_LNBY,
170 SPM_LDNG, SPM_NOTC, SPM_TSS, SPM_FOUL, SPM_DIVE, SPM_FRRY, SPM_ANCH,
171 MOR_DLPN, MOR_DDPN, MOR_BLRD, MOR_WALL, MOR_POST, MOR_CHWR, MOR_BUOY,
172 SIS_PTCL, SIS_PTED, SIS_IPT, SIS_BRTH, SIS_DOCK, SIS_LOCK, SIS_FBAR, SIS_BRDG, SIS_DRDG, SIS_TRFC,
173 SIS_DNGR, SIS_OBST, SIS_CABL, SIS_MILY, SIS_DSTR, SIS_WTHR, SIS_STRM, SIS_ICE, SIS_TIME, SIS_TIDE,
174 SIS_TSTM, SIS_TGAG, SIS_TSCL, SIS_DIVE, SIS_LGAG, LIT_DIRF, LIT_LEDG,
175 LMK_CHMY, LMK_CARN, LMK_DSHA, LMK_FLGS, LMK_FLRS, LMK_MNMT, LMK_RADM, LMK_TOWR, LMK_WNDM, LMK_WTRT,
176 LMK_MAST, LMK_WNDS, LMK_CLMN, LMK_OBLK, LMK_STAT, LMK_CROS, LMK_DOME, LMK_SCNR, LMK_WNDL, LMK_SPIR
177 }
178
179 public static final EnumMap<Cat, String> CatSTR = new EnumMap<Cat, String>(Cat.class);
180 static {
181 CatSTR.put(Cat.LAM_PORT, "port");
182 CatSTR.put(Cat.LAM_STBD, "starboard");
183 CatSTR.put(Cat.LAM_PPORT, "preferred_channel_port");
184 CatSTR.put(Cat.LAM_PSTBD, "preferred_channel_starboard");
185 CatSTR.put(Cat.CAM_NORTH, "north");
186 CatSTR.put(Cat.CAM_EAST, "east");
187 CatSTR.put(Cat.CAM_SOUTH, "south");
188 CatSTR.put(Cat.CAM_WEST, "west");
189 CatSTR.put(Cat.SPM_UNKN, "unknown_purpose");
190 CatSTR.put(Cat.SPM_WARN, "warning");
191 CatSTR.put(Cat.SPM_CHBF, "channel_separation");
192 CatSTR.put(Cat.SPM_YCHT, "yachting");
193 CatSTR.put(Cat.SPM_CABL, "cable");
194 CatSTR.put(Cat.SPM_OFAL, "outfall");
195 CatSTR.put(Cat.SPM_ODAS, "odas");
196 CatSTR.put(Cat.SPM_RECN, "recreational");
197 CatSTR.put(Cat.SPM_MOOR, "mooring");
198 CatSTR.put(Cat.SPM_LNBY, "lanby");
199 CatSTR.put(Cat.SPM_LDNG, "leading");
200 CatSTR.put(Cat.SPM_NOTC, "notice");
201 CatSTR.put(Cat.SPM_TSS, "tss");
202 CatSTR.put(Cat.SPM_FOUL, "foul");
203 CatSTR.put(Cat.SPM_DIVE, "diving");
204 CatSTR.put(Cat.SPM_FRRY, "ferry");
205 CatSTR.put(Cat.SPM_ANCH, "anchorage");
206 CatSTR.put(Cat.MOR_DLPN, "dolphin");
207 CatSTR.put(Cat.MOR_DDPN, "deviation_dolphin");
208 CatSTR.put(Cat.MOR_BLRD, "bollard");
209 CatSTR.put(Cat.MOR_WALL, "wall");
210 CatSTR.put(Cat.MOR_POST, "post");
211 CatSTR.put(Cat.MOR_CHWR, "chain");
212 CatSTR.put(Cat.MOR_BUOY, "buoy");
213 CatSTR.put(Cat.SIS_PTCL, "control");
214 CatSTR.put(Cat.SIS_PTED, "entry");
215 CatSTR.put(Cat.SIS_IPT, "IPT");
216 CatSTR.put(Cat.SIS_BRTH, "berthing");
217 CatSTR.put(Cat.SIS_DOCK, "dock");
218 CatSTR.put(Cat.SIS_LOCK, "lock");
219 CatSTR.put(Cat.SIS_FBAR, "barrage");
220 CatSTR.put(Cat.SIS_BRDG, "bridge");
221 CatSTR.put(Cat.SIS_DRDG, "dredging");
222 CatSTR.put(Cat.SIS_TRFC, "traffic");
223 CatSTR.put(Cat.SIS_DNGR, "danger");
224 CatSTR.put(Cat.SIS_OBST, "obstruction");
225 CatSTR.put(Cat.SIS_CABL, "cable");
226 CatSTR.put(Cat.SIS_MILY, "military");
227 CatSTR.put(Cat.SIS_DSTR, "distress");
228 CatSTR.put(Cat.SIS_WTHR, "weather");
229 CatSTR.put(Cat.SIS_STRM, "storm");
230 CatSTR.put(Cat.SIS_ICE, "ice");
231 CatSTR.put(Cat.SIS_TIME, "time");
232 CatSTR.put(Cat.SIS_TIDE, "tide");
233 CatSTR.put(Cat.SIS_TSTM, "stream");
234 CatSTR.put(Cat.SIS_TGAG, "gauge");
235 CatSTR.put(Cat.SIS_TSCL, "scale");
236 CatSTR.put(Cat.SIS_DIVE, "diving");
237 CatSTR.put(Cat.SIS_LGAG, "level");
238 CatSTR.put(Cat.LMK_CHMY, "chimney");
239 CatSTR.put(Cat.LMK_CARN, "cairn");
240 CatSTR.put(Cat.LMK_DSHA, "dish_aerial");
241 CatSTR.put(Cat.LMK_FLGS, "flagstaff");
242 CatSTR.put(Cat.LMK_FLRS, "flare_stack");
243 CatSTR.put(Cat.LMK_MNMT, "monument");
244 CatSTR.put(Cat.LMK_RADM, "radio_mast");
245 CatSTR.put(Cat.LMK_TOWR, "tower");
246 CatSTR.put(Cat.LMK_WNDM, "windmotor");
247 CatSTR.put(Cat.LMK_WTRT, "water_tower");
248 CatSTR.put(Cat.LMK_MAST, "mast");
249 CatSTR.put(Cat.LMK_WNDS, "wind_sock");
250 CatSTR.put(Cat.LMK_CLMN, "column");
251 CatSTR.put(Cat.LMK_OBLK, "obelisk");
252 CatSTR.put(Cat.LMK_STAT, "statue");
253 CatSTR.put(Cat.LMK_CROS, "cross");
254 CatSTR.put(Cat.LMK_DOME, "dome");
255 CatSTR.put(Cat.LMK_SCNR, "radar");
256 CatSTR.put(Cat.LMK_WNDL, "windmill");
257 CatSTR.put(Cat.LMK_SPIR, "spire");
258 }
259
260 private Cat category = Cat.NONE;
261
262 public Cat getCategory() {
263 return category;
264 }
265
266 public void setCategory(Cat cat) {
267 category = cat;
268 }
269
270 public enum Shp {
271 UNKNOWN, PILLAR, SPAR, CAN, CONE, SPHERE, BARREL, FLOAT, SUPER, BUOYANT, CAIRN, PILE, LATTICE, TOWER, STAKE, POLE, POST, PERCH, BUOY, BEACON
272 }
273
274 public static final EnumMap<Shp, String> ShpSTR = new EnumMap<Shp, String>(Shp.class);
275 static {
276 ShpSTR.put(Shp.PILLAR, "pillar");
277 ShpSTR.put(Shp.SPAR, "spar");
278 ShpSTR.put(Shp.CAN, "can");
279 ShpSTR.put(Shp.CONE, "conical");
280 ShpSTR.put(Shp.SPHERE, "spherical");
281 ShpSTR.put(Shp.BARREL, "barrel");
282 ShpSTR.put(Shp.FLOAT, "float");
283 ShpSTR.put(Shp.SUPER, "super-buoy");
284 ShpSTR.put(Shp.BUOYANT, "buoyant");
285 ShpSTR.put(Shp.CAIRN, "cairn");
286 ShpSTR.put(Shp.PILE, "pile");
287 ShpSTR.put(Shp.LATTICE, "lattice");
288 ShpSTR.put(Shp.TOWER, "tower");
289 ShpSTR.put(Shp.STAKE, "stake");
290 ShpSTR.put(Shp.PERCH, "perch");
291 }
292
293 private Shp shape = Shp.UNKNOWN;
294
295 public Shp getShape() {
296 return shape;
297 }
298
299 public void setShape(Shp shp) {
300 shape = shp;
301 }
302
303 public enum Col {
304 UNKNOWN, BLANK, WHITE, RED, ORANGE, AMBER, YELLOW, GREEN, BLUE, VIOLET, BLACK, GREY, BROWN, MAGENTA, PINK
305 }
306
307 public static final EnumMap<Col, Color> ColMAP = new EnumMap<Col, Color>(Col.class);
308 static {
309 ColMAP.put(Col.UNKNOWN, new Color(0xc0c0c0));
310 ColMAP.put(Col.WHITE, Color.WHITE);
311 ColMAP.put(Col.RED, Color.RED);
312 ColMAP.put(Col.ORANGE, Color.ORANGE);
313 ColMAP.put(Col.AMBER, new Color(0xfbf00f));
314 ColMAP.put(Col.YELLOW, Color.YELLOW);
315 ColMAP.put(Col.GREEN, Color.GREEN);
316 ColMAP.put(Col.BLUE, Color.BLUE);
317 ColMAP.put(Col.VIOLET, new Color(0x8f00ff));
318 ColMAP.put(Col.BLACK, Color.BLACK);
319 ColMAP.put(Col.GREY, Color.GRAY);
320 ColMAP.put(Col.BROWN, new Color(0xa45a58));
321 ColMAP.put(Col.MAGENTA, Color.MAGENTA);
322 ColMAP.put(Col.PINK, Color.PINK);
323 }
324
325 public static final EnumMap<Col, String> ColSTR = new EnumMap<Col, String>(Col.class);
326 static {
327 ColSTR.put(Col.WHITE, "white");
328 ColSTR.put(Col.RED, "red");
329 ColSTR.put(Col.ORANGE, "orange");
330 ColSTR.put(Col.AMBER, "amber");
331 ColSTR.put(Col.YELLOW, "yellow");
332 ColSTR.put(Col.GREEN, "green");
333 ColSTR.put(Col.BLUE, "blue");
334 ColSTR.put(Col.VIOLET, "violet");
335 ColSTR.put(Col.BLACK, "black");
336 ColSTR.put(Col.GREY, "grey");
337 ColSTR.put(Col.BROWN, "brown");
338 ColSTR.put(Col.MAGENTA, "magenta");
339 ColSTR.put(Col.PINK, "pink");
340 }
341
342 public Col getColour(Ent ent, int idx) {
343 if (ent == Ent.BODY)
344 return getObjColour(idx);
345 else
346 return getTopColour(idx);
347 }
348
349 public void setColour(Ent ent, Col col) {
350 if (ent == Ent.BODY)
351 setObjColour(col);
352 else
353 setTopColour(col);
354 }
355
356 public void setColour(Ent ent, int idx, Col col) {
357 if (ent == Ent.BODY)
358 setObjColour(idx, col);
359 else
360 setTopColour(idx, col);
361 }
362
363 public void addColour(Ent ent, int idx, Col col) {
364 if (ent == Ent.BODY)
365 addObjColour(idx, col);
366 else
367 addTopColour(idx, col);
368 }
369
370 public void subColour(Ent ent, int idx) {
371 if (ent == Ent.BODY)
372 subObjColour(idx);
373 else
374 subTopColour(idx);
375 }
376
377 private ArrayList<Col> bodyColour = new ArrayList<Col>();
378
379 public Col getObjColour(int i) {
380 if (i < bodyColour.size())
381 return bodyColour.get(i);
382 else
383 return Col.UNKNOWN;
384 }
385
386 public void setObjColour(Col col) {
387 bodyColour.clear();
388 bodyColour.add(col);
389 }
390
391 public void setObjColour(int i, Col col) {
392 if (bodyColour.size() > i)
393 bodyColour.set(i, col);
394 }
395
396 public void addObjColour(int i, Col col) {
397 if (bodyColour.size() >= i)
398 bodyColour.add(i, col);
399 }
400
401 public void addObjColour(Col col) {
402 bodyColour.add(col);
403 }
404
405 public void subObjColour(int i) {
406 if (bodyColour.size() > i)
407 bodyColour.remove(i);
408 }
409
410 private ArrayList<Col> topmarkColour = new ArrayList<Col>();
411
412 public Col getTopColour(int i) {
413 if (i < topmarkColour.size())
414 return topmarkColour.get(i);
415 else
416 return Col.UNKNOWN;
417 }
418
419 public void setTopColour(Col col) {
420 topmarkColour.clear();
421 topmarkColour.add(col);
422 }
423
424 public void setTopColour(int i, Col col) {
425 if (topmarkColour.size() > i)
426 topmarkColour.set(i, col);
427 }
428
429 public void addTopColour(int i, Col col) {
430 if (topmarkColour.size() >= i)
431 topmarkColour.add(i, col);
432 }
433
434 public void addTopColour(Col col) {
435 topmarkColour.add(col);
436 }
437
438 public void subTopColour(int i) {
439 if (topmarkColour.size() > i)
440 topmarkColour.remove(i);
441 }
442
443 public enum Chr {
444 UNKNOWN, FIXED, FLASH, LFLASH, QUICK, VQUICK, UQUICK, ISOPHASED, OCCULTING, MORSE, ALTERNATING, IQUICK, IVQUICK, IUQUICK
445 }
446
447 public static final Map<EnumSet<Chr>, String> ChrMAP = new HashMap<EnumSet<Chr>, String>();
448 static {
449 ChrMAP.put(EnumSet.of(Chr.UNKNOWN), "");
450 ChrMAP.put(EnumSet.of(Chr.FIXED), "F");
451 ChrMAP.put(EnumSet.of(Chr.FLASH), "Fl");
452 ChrMAP.put(EnumSet.of(Chr.LFLASH), "LFl");
453 ChrMAP.put(EnumSet.of(Chr.QUICK), "Q");
454 ChrMAP.put(EnumSet.of(Chr.VQUICK), "VQ");
455 ChrMAP.put(EnumSet.of(Chr.UQUICK), "UQ");
456 ChrMAP.put(EnumSet.of(Chr.ISOPHASED), "Iso");
457 ChrMAP.put(EnumSet.of(Chr.OCCULTING), "Oc");
458 ChrMAP.put(EnumSet.of(Chr.IQUICK), "IQ");
459 ChrMAP.put(EnumSet.of(Chr.IVQUICK), "IVQ");
460 ChrMAP.put(EnumSet.of(Chr.IUQUICK), "IUQ");
461 ChrMAP.put(EnumSet.of(Chr.MORSE), "Mo");
462 ChrMAP.put(EnumSet.of(Chr.FIXED, Chr.FLASH), "FFl");
463 ChrMAP.put(EnumSet.of(Chr.FLASH, Chr.LFLASH), "FlLFl");
464 ChrMAP.put(EnumSet.of(Chr.OCCULTING, Chr.FLASH), "OcFl");
465 ChrMAP.put(EnumSet.of(Chr.FIXED, Chr.LFLASH), "FLFl");
466 ChrMAP.put(EnumSet.of(Chr.QUICK, Chr.LFLASH), "Q+LFl");
467 ChrMAP.put(EnumSet.of(Chr.VQUICK, Chr.LFLASH), "VQ+LFl");
468 ChrMAP.put(EnumSet.of(Chr.UQUICK, Chr.LFLASH), "UQ+LFl");
469 ChrMAP.put(EnumSet.of(Chr.ALTERNATING), "Al");
470 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.OCCULTING), "Al.Oc");
471 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.LFLASH), "Al.LFl");
472 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.FLASH), "Al.Fl");
473 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.FIXED), "Al.F");
474 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.FIXED, Chr.FLASH), "Al.FFl");
475 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.ISOPHASED), "Al.Iso");
476 }
477
478 public enum Vis {
479 UNKNOWN, HIGH, LOW, FAINT, INTEN, UNINTEN, REST, OBS, PARTOBS
480 }
481
482 public static final EnumMap<Vis, String> VisSTR = new EnumMap<Vis, String>(Vis.class);
483 static {
484 VisSTR.put(Vis.UNKNOWN, "");
485 VisSTR.put(Vis.HIGH, "high");
486 VisSTR.put(Vis.LOW, "low");
487 VisSTR.put(Vis.FAINT, "faint");
488 VisSTR.put(Vis.INTEN, "intensified");
489 VisSTR.put(Vis.UNINTEN, "unintensified");
490 VisSTR.put(Vis.REST, "restricted");
491 VisSTR.put(Vis.OBS, "obscured");
492 VisSTR.put(Vis.PARTOBS, "part_obscured");
493 }
494
495 public enum Lit {
496 UNKNOWN, VERT, HORIZ, DIR, UPPER, LOWER, LEAD, REAR, FRONT, AERO, AIROBS, FOGDET, FLOOD, STRIP, SUBS, SPOT, MOIRE, EMERG, BEAR
497 }
498
499 public static final EnumMap<Lit, String> LitSTR = new EnumMap<Lit, String>(Lit.class);
500 static {
501 LitSTR.put(Lit.UNKNOWN, "");
502 LitSTR.put(Lit.VERT, "vertical");
503 LitSTR.put(Lit.HORIZ, "horizontal");
504 LitSTR.put(Lit.DIR, "directional");
505 LitSTR.put(Lit.UPPER, "upper");
506 LitSTR.put(Lit.LOWER, "lower");
507 LitSTR.put(Lit.LEAD, "leading");
508 LitSTR.put(Lit.REAR, "rear");
509 LitSTR.put(Lit.FRONT, "front");
510 LitSTR.put(Lit.AERO, "aero");
511 LitSTR.put(Lit.AIROBS, "air_obstruction");
512 LitSTR.put(Lit.FOGDET, "fog_detector");
513 LitSTR.put(Lit.FLOOD, "floodlight");
514 LitSTR.put(Lit.STRIP, "striplight");
515 LitSTR.put(Lit.SUBS, "subsidairy");
516 LitSTR.put(Lit.SPOT, "spotlight");
517 LitSTR.put(Lit.MOIRE, "moire");
518 LitSTR.put(Lit.EMERG, "emergency");
519 LitSTR.put(Lit.BEAR, "bearing");
520 }
521
522 public enum Exh {
523 UNKNOWN, H24, DAY, NIGHT, FOG, WARN, STORM
524 }
525
526 public static final EnumMap<Exh, String> ExhSTR = new EnumMap<Exh, String>(Exh.class);
527 static {
528 ExhSTR.put(Exh.UNKNOWN, "");
529 ExhSTR.put(Exh.H24, "24h");
530 ExhSTR.put(Exh.DAY, "day");
531 ExhSTR.put(Exh.NIGHT, "night");
532 ExhSTR.put(Exh.FOG, "fog");
533 ExhSTR.put(Exh.WARN, "warning");
534 ExhSTR.put(Exh.STORM, "storm");
535 }
536
537 public enum Att {
538 COL, CHR, GRP, SEQ, PER, LIT, BEG, END, RAD, HGT, RNG, VIS, EXH, ORT, MLT
539 }
540
541 public Object[] sector = { Col.UNKNOWN, "", "", "", "", Lit.UNKNOWN, "", "",
542 "", "", "", Vis.UNKNOWN, Exh.UNKNOWN, "", "" };
543
544 private ArrayList<Object[]> sectors = new ArrayList<Object[]>();
545
546 public int getSectorCount() {
547 return sectors.size();
548 }
549
550 public Object getLightAtt(Att att, int i) {
551 return getLightAtt(att.ordinal(), i);
552 }
553
554 public Object getLightAtt(int att, int i) {
555 if (i < sectors.size())
556 return sectors.get(i)[att];
557 else
558 return null;
559 }
560
561 public void setLightAtt(Att att, int i, Object obj) {
562 setLightAtt(att.ordinal(), i, obj);
563 }
564
565 public void setLightAtt(int att, int i, Object obj) {
566 if (sectors.size() == i)
567 addLight(i);
568 if (sectors.size() > i)
569 switch (att) {
570 case 4:
571 case 8:
572 case 9:
573 case 10:
574 case 14:
575 sectors.get(i)[att] = validDecimal((String)obj);
576 break;
577 case 6:
578 case 7:
579 case 13:
580 sectors.get(i)[att] = validDecimal((String)obj, 360);
581 break;
582 default:
583 sectors.get(i)[att] = obj;
584 }
585 }
586
587 public void addLight(int i) {
588 if (sectors.size() >= i) {
589 if (sectors.size() == 0)
590 sectors.add(sector.clone());
591 else
592 sectors.add(i, sectors.get(0).clone());
593 }
594 }
595
596 public void addLight() {
597 if (sectors.size() == 0)
598 sectors.add(sector.clone());
599 else
600 sectors.add(sectors.get(0).clone());
601 }
602
603 public void delLight(int i) {
604 if (sectors.size() > i)
605 sectors.remove(i);
606 }
607
608 public void clrLight() {
609 delLight(0);
610 addLight();
611 }
612
613 public enum Pat {
614 NONE, HORIZ, VERT, DIAG, SQUARE, BORDER
615 }
616
617 public static final EnumMap<Pat, String> PatSTR = new EnumMap<Pat, String>(Pat.class);
618 static {
619 PatSTR.put(Pat.HORIZ, "horizontal");
620 PatSTR.put(Pat.VERT, "vertical");
621 PatSTR.put(Pat.DIAG, "diagonal");
622 PatSTR.put(Pat.SQUARE, "squared");
623 PatSTR.put(Pat.BORDER, "border");
624 }
625
626 public Pat getPattern(Ent ent) {
627 if (ent == Ent.BODY)
628 return getObjPattern();
629 else
630 return getTopPattern();
631 }
632
633 public void setPattern(Ent ent, Pat pat) {
634 if (ent == Ent.BODY)
635 setObjPattern(pat);
636 else
637 setTopPattern(pat);
638 }
639
640 private Pat bodyPattern = Pat.NONE;
641
642 public Pat getObjPattern() {
643 return bodyPattern;
644 }
645
646 public void setObjPattern(Pat pat) {
647 bodyPattern = pat;
648 }
649
650 private Pat topPattern = Pat.NONE;
651
652 public Pat getTopPattern() {
653 return topPattern;
654 }
655
656 public void setTopPattern(Pat pat) {
657 topPattern = pat;
658 }
659
660 public enum Top {
661 NONE, CAN, CONE, SPHERE, X_SHAPE, NORTH, SOUTH, EAST, WEST, SPHERES2, BOARD, DIAMOND, CIRCLE, TRIANGLE, TRIANGLE_INV, SQUARE
662 }
663
664 public static final EnumMap<Top, String> TopSTR = new EnumMap<Top, String>(Top.class);
665 static {
666 TopSTR.put(Top.CAN, "cylinder");
667 TopSTR.put(Top.CONE, "cone, point up");
668 TopSTR.put(Top.SPHERE, "sphere");
669 TopSTR.put(Top.X_SHAPE, "x-shape");
670 TopSTR.put(Top.NORTH, "2 cones up");
671 TopSTR.put(Top.SOUTH, "2 cones down");
672 TopSTR.put(Top.EAST, "2 cones base together");
673 TopSTR.put(Top.WEST, "2 cones point together");
674 TopSTR.put(Top.SPHERES2, "2 spheres");
675 TopSTR.put(Top.BOARD, "board");
676 TopSTR.put(Top.DIAMOND, "diamond");
677 TopSTR.put(Top.CIRCLE, "circle");
678 TopSTR.put(Top.TRIANGLE, "triangle, point up");
679 TopSTR.put(Top.TRIANGLE_INV, "triangle, point down");
680 TopSTR.put(Top.SQUARE, "square");
681 }
682
683 private Top topShape = Top.NONE;
684
685 public Top getTopmark() {
686 return topShape;
687 }
688
689 public void setTopmark(Top top) {
690 topShape = top;
691 }
692
693 public enum Rtb {
694 NONE, REFLECTOR, RACON, RAMARK, LEADING
695 }
696
697 public static final EnumMap<Rtb, String> RtbSTR = new EnumMap<Rtb, String>(Rtb.class);
698 static {
699 RtbSTR.put(Rtb.RACON, "racon");
700 RtbSTR.put(Rtb.RAMARK, "ramark");
701 RtbSTR.put(Rtb.LEADING, "leading");
702 }
703
704 private Rtb RaType = Rtb.NONE;
705
706 public Rtb getRadar() {
707 return RaType;
708 }
709
710 public void setRadar(Rtb type) {
711 RaType = type;
712 }
713
714 private String raconGroup = "";
715
716 public String getRaconGroup() {
717 return raconGroup;
718 }
719
720 public void setRaconGroup(String grp) {
721 raconGroup = grp;
722 }
723
724 private String raconSequence = "";
725
726 public String getRaconSequence() {
727 return raconSequence;
728 }
729
730 public void setRaconSequence(String seq) {
731 raconSequence = seq;
732 }
733
734 private String raconPeriod = "";
735
736 public String getRaconPeriod() {
737 return raconPeriod;
738 }
739
740 public void setRaconPeriod(String per) {
741 raconPeriod = validDecimal(per);
742 }
743
744 private String raconRange = "";
745
746 public String getRaconRange() {
747 return raconRange;
748 }
749
750 public void setRaconRange(String rng) {
751 raconRange = validDecimal(rng);
752 }
753
754 private String raconSector1 = "";
755
756 public String getRaconSector1() {
757 return raconSector1;
758 }
759
760 public void setRaconSector1(String sec) {
761 raconSector1 = validDecimal(sec);
762 }
763
764 private String raconSector2 = "";
765
766 public String getRaconSector2() {
767 return raconSector2;
768 }
769
770 public void setRaconSector2(String sec) {
771 raconSector2 = validDecimal(sec);
772 }
773
774 public enum Fog {
775 NONE, UNKNOWN, HORN, SIREN, DIA, BELL, WHIS, GONG, EXPLOS
776 }
777
778 public static final EnumMap<Fog, String> FogSTR = new EnumMap<Fog, String>(Fog.class);
779 static {
780 FogSTR.put(Fog.UNKNOWN, "yes");
781 FogSTR.put(Fog.HORN, "horn");
782 FogSTR.put(Fog.SIREN, "siren");
783 FogSTR.put(Fog.DIA, "diaphone");
784 FogSTR.put(Fog.BELL, "bell");
785 FogSTR.put(Fog.WHIS, "whistle");
786 FogSTR.put(Fog.GONG, "gong");
787 FogSTR.put(Fog.EXPLOS, "explosion");
788 }
789
790 private Fog fogSound = Fog.NONE;
791
792 public Fog getFogSound() {
793 return fogSound;
794 }
795
796 public void setFogSound(Fog sound) {
797 fogSound = sound;
798 }
799
800 private String fogGroup = "";
801
802 public String getFogGroup() {
803 return fogGroup;
804 }
805
806 public void setFogGroup(String grp) {
807 fogGroup = grp;
808 }
809
810 private String fogSequence = "";
811
812 public String getFogSequence() {
813 return fogSequence;
814 }
815
816 public void setFogSequence(String seq) {
817 fogSequence = seq;
818 }
819
820 private String fogRange = "";
821
822 public String getFogRange() {
823 return fogRange;
824 }
825
826 public void setFogRange(String rng) {
827 fogRange = validDecimal(rng);
828 }
829
830 private String fogPeriod = "";
831
832 public String getFogPeriod() {
833 return fogPeriod;
834 }
835
836 public void setFogPeriod(String per) {
837 fogPeriod = validDecimal(per);
838 }
839
840 public enum Sts {
841 UNKNOWN, PERM, OCC, REC, NIU, INT, RESV, TEMP, PRIV, MAND, DEST, EXT, ILLUM, HIST, PUB, SYNC, WATCH, UNWAT, DOUBT
842 }
843
844 public static final EnumMap<Sts, String> StsSTR = new EnumMap<Sts, String>(Sts.class);
845 static {
846 StsSTR.put(Sts.PERM, "permanent");
847 StsSTR.put(Sts.OCC, "occasional");
848 StsSTR.put(Sts.REC, "recommended");
849 StsSTR.put(Sts.NIU, "not_in_use");
850 StsSTR.put(Sts.INT, "intermittent");
851 StsSTR.put(Sts.RESV, "reserved");
852 StsSTR.put(Sts.TEMP, "tempory");
853 StsSTR.put(Sts.PRIV, "private");
854 StsSTR.put(Sts.MAND, "mandatory");
855 StsSTR.put(Sts.DEST, "destroyed");
856 StsSTR.put(Sts.EXT, "extinguished");
857 StsSTR.put(Sts.ILLUM, "illuminated");
858 StsSTR.put(Sts.HIST, "historic");
859 StsSTR.put(Sts.PUB, "public");
860 StsSTR.put(Sts.SYNC, "synchronized");
861 StsSTR.put(Sts.WATCH, "watched");
862 StsSTR.put(Sts.UNWAT, "unwatched");
863 StsSTR.put(Sts.DOUBT, "existence_doubtful");
864 }
865
866 private Sts status = Sts.UNKNOWN;
867
868 public Sts getStatus() {
869 return status;
870 }
871
872 public void setStatus(Sts sts) {
873 status = sts;
874 }
875
876 public enum Cns {
877 UNKNOWN, BRICK, CONC, BOULD, HSURF, USURF, WOOD, METAL, GRP, PAINT
878 }
879
880 public static final EnumMap<Cns, String> CnsSTR = new EnumMap<Cns, String>(Cns.class);
881 static {
882 CnsSTR.put(Cns.BRICK, "masonry");
883 CnsSTR.put(Cns.CONC, "concreted");
884 CnsSTR.put(Cns.BOULD, "boulders");
885 CnsSTR.put(Cns.HSURF, "hard_surfaced");
886 CnsSTR.put(Cns.USURF, "unsurfaced");
887 CnsSTR.put(Cns.WOOD, "wooden");
888 CnsSTR.put(Cns.METAL, "metal");
889 CnsSTR.put(Cns.GRP, "grp");
890 CnsSTR.put(Cns.PAINT, "painted");
891 }
892
893 private Cns construction = Cns.UNKNOWN;
894
895 public Cns getConstr() {
896 return construction;
897 }
898
899 public void setConstr(Cns cns) {
900 construction = cns;
901 }
902
903 public enum Con {
904 UNKNOWN, CONSP, NCONS, REFL
905 }
906
907 public static final EnumMap<Con, String> ConSTR = new EnumMap<Con, String>(Con.class);
908 static {
909 ConSTR.put(Con.CONSP, "conspicuous");
910 ConSTR.put(Con.NCONS, "not_conspicuous");
911 ConSTR.put(Con.REFL, "reflector");
912 }
913
914 private Con conspicuity = Con.UNKNOWN;
915
916 public Con getConsp() {
917 return conspicuity;
918 }
919
920 public void setConsp(Con con) {
921 conspicuity = con;
922 }
923
924 private Con reflectivity = Con.UNKNOWN;
925
926 public Con getRefl() {
927 return reflectivity;
928 }
929
930 public void setRefl(Con con) {
931 reflectivity = con;
932 }
933
934 public String information = "";
935
936 public String getInfo() {
937 return information;
938 }
939
940 public void setInfo(String str) {
941 information = str.trim();
942 }
943
944 public String source = "";
945
946 public String getSource() {
947 return source;
948 }
949
950 public void setSource(String str) {
951 source = str.trim();
952 }
953
954 public String elevation = "";
955
956 public String getElevation() {
957 return elevation;
958 }
959
960 public void setElevation(String str) {
961 elevation = validDecimal(str);
962 }
963
964 public String height = "";
965
966 public String getHeight() {
967 return height;
968 }
969
970 public void setHeight(String str) {
971 height = validDecimal(str);
972 }
973
974 public String ref = "";
975
976 public String getRef() {
977 return ref;
978 }
979
980 public void setRef(String str) {
981 ref = str;
982 }
983
984 public String lightRef = "";
985
986 public String getLightRef() {
987 return lightRef;
988 }
989
990 public void setLightRef(String str) {
991 lightRef = str;
992 }
993
994 public String fixme = "";
995
996 public String getFixme() {
997 return fixme;
998 }
999
1000 public void setFixme(String str) {
1001 fixme = str;
1002 }
1003
1004 public boolean testValid() {
1005 boolean tmp = false;
1006 dlg.manager.showVisualMessage("");
1007 switch (getObject()) {
1008 case BCNCAR:
1009 case BCNLAT:
1010 case BOYCAR:
1011 case BOYLAT:
1012 if ((getCategory() != Cat.NONE) && (getShape() != Shp.UNKNOWN))
1013 tmp = true;
1014 break;
1015 case BCNISD:
1016 case BCNSAW:
1017 case BCNSPP:
1018 case BOYISD:
1019 case BOYSAW:
1020 case BOYSPP:
1021 if (getShape() != Shp.UNKNOWN)
1022 tmp = true;
1023 break;
1024 case FLTCAR:
1025 case FLTISD:
1026 case FLTLAT:
1027 case FLTSAW:
1028 case FLTSPP:
1029 if (getObjColour(0) != Col.UNKNOWN)
1030 tmp = true;
1031 break;
1032 case LITMAJ:
1033 case LITMIN:
1034 case LITFLT:
1035 case LITVES:
1036 case LITHSE:
1037 case MORFAC:
1038 case SISTAW:
1039 case SISTAT:
1040 tmp = true;
1041 break;
1042 case LNDMRK:
1043 if (getCategory() != Cat.NONE)
1044 tmp = true;
1045 break;
1046 }
1047 if (tmp) {
1048 dlg.panelMain.moreButton.setVisible(true);
1049 dlg.panelMain.saveButton.setEnabled(true);
1050 Ent ent = EntMAP.get(getObject());
1051 dlg.panelMain.topButton.setEnabled((ent == Ent.BUOY)
1052 || (ent == Ent.BEACON) || (ent == Ent.FLOAT));
1053 dlg.panelMain.fogButton.setEnabled(true);
1054 dlg.panelMain.radButton.setEnabled(true);
1055 dlg.panelMain.litButton.setEnabled(true);
1056 return true;
1057 } else {
1058 dlg.panelMain.moreButton.setVisible(false);
1059 dlg.panelMain.moreButton.setText("v v v");
1060 dlg.panelMain.topButton.setEnabled(false);
1061 dlg.panelMain.fogButton.setEnabled(false);
1062 dlg.panelMain.radButton.setEnabled(false);
1063 dlg.panelMain.litButton.setEnabled(false);
1064 dlg.manager.showVisualMessage("Seamark not recognised");
1065 return false;
1066 }
1067 }
1068
1069 public void clearSign() {
1070 setObject(Obj.UNKNOWN);
1071 setCategory(Cat.NONE);
1072 setShape(Shp.UNKNOWN);
1073 setColour(Ent.BODY, Col.UNKNOWN);
1074 setPattern(Ent.BODY, Pat.NONE);
1075 setTopmark(Top.NONE);
1076 setColour(Ent.TOPMARK, Col.UNKNOWN);
1077 setPattern(Ent.TOPMARK, Pat.NONE);
1078 setFogSound(Fog.NONE);
1079 setRadar(Rtb.NONE);
1080 clrLight();
1081 dlg.panelMain.moreButton.setVisible(false);
1082 dlg.panelMain.saveButton.setEnabled(false);
1083 dlg.panelMain.topButton.setEnabled(false);
1084 dlg.panelMain.fogButton.setEnabled(false);
1085 dlg.panelMain.radButton.setEnabled(false);
1086 dlg.panelMain.litButton.setEnabled(false);
1087 dlg.panelMain.panelMore.syncPanel();
1088 dlg.panelMain.panelMore.setVisible(false);
1089 paintSign();
1090 }
1091
1092 public String validDecimal(String str) {
1093 str = str.trim().replace(',', '.');
1094 if (!(str.isEmpty()) && !(str.matches("^[+-]??\\d+(\\.\\d+)??$"))) {
1095 dlg.manager.showVisualMessage(Messages.getString("NotDecimal"));
1096 return "";
1097 } else {
1098 dlg.manager.showVisualMessage("");
1099 return str;
1100 }
1101 }
1102
1103 public String validDecimal(String str, float max) {
1104 str = validDecimal(str);
1105 if (!(str.isEmpty()) && (new Float(str) > max)) {
1106 dlg.manager.showVisualMessage(Messages.getString("TooBig") + " (" + max + ")");
1107 return "";
1108 } else {
1109 dlg.manager.showVisualMessage("");
1110 return str;
1111 }
1112 }
1113
1114 private boolean paintlock = false;
1115
1116 public void parseMark(Node node) {
1117 paintlock = true;
1118 dlg.manager.showVisualMessage("");
1119 String str = Main.pref.get("smedplugin.IALA");
1120 if (str.equals("C"))
1121 setRegion(Reg.C);
1122 else if (str.equals("B"))
1123 setRegion(Reg.B);
1124 else
1125 setRegion(Reg.A);
1126
1127 Map<String, String> keys = node.getKeys();
1128
1129 str = "";
1130 if (keys.containsKey("seamark:type"))
1131 str = keys.get("seamark:type");
1132
1133 setObject(Obj.UNKNOWN);
1134 for (Obj obj : ObjSTR.keySet()) {
1135 if (ObjSTR.get(obj).equals(str)) {
1136 setObject(obj);
1137 }
1138 }
1139
1140 if (str.equals("")) {
1141 dlg.manager.showVisualMessage("No seamark");
1142 }
1143 if (getObject() == Obj.UNKNOWN) {
1144 dlg.manager.showVisualMessage("Seamark not recognised");
1145 }
1146
1147 setName("");
1148 for (Obj obj : ObjSTR.keySet()) {
1149 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":name")) {
1150 str = keys.get("seamark:" + ObjSTR.get(obj) + ":name");
1151 setName(str);
1152 }
1153 }
1154 if (keys.containsKey("seamark:name")) {
1155 str = keys.get("seamark:name");
1156 setName(str);
1157 }
1158 if (getName().isEmpty()) {
1159 if (keys.containsKey("name")) {
1160 str = keys.get("name");
1161 setName(str);
1162 }
1163 }
1164
1165 for (Obj obj : ObjSTR.keySet()) {
1166 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":category")) {
1167 str = keys.get("seamark:" + ObjSTR.get(obj) + ":category");
1168 setCategory(Cat.NONE);
1169 for (Cat cat : CatSTR.keySet()) {
1170 if (CatSTR.get(cat).equals(str)) {
1171 setCategory(cat);
1172 }
1173 }
1174 }
1175 }
1176
1177 for (Obj obj : ObjSTR.keySet()) {
1178 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":shape")) {
1179 str = keys.get("seamark:" + ObjSTR.get(obj) + ":shape");
1180 setShape(Shp.UNKNOWN);
1181 for (Shp shp : ShpSTR.keySet()) {
1182 if (ShpSTR.get(shp).equals(str)) {
1183 setShape(shp);
1184 }
1185 }
1186 }
1187 }
1188 if (getShape() == Shp.UNKNOWN) {
1189 if (EntMAP.get(getObject()) == Ent.BUOY)
1190 setShape(Shp.BUOY);
1191 if (EntMAP.get(getObject()) == Ent.BEACON)
1192 setShape(Shp.BEACON);
1193 if (EntMAP.get(getObject()) == Ent.FLOAT)
1194 if (getObject() == Obj.LITVES)
1195 setShape(Shp.SUPER);
1196 else
1197 setShape(Shp.FLOAT);
1198 }
1199
1200 for (Obj obj : ObjSTR.keySet()) {
1201 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":colour")) {
1202 str = keys.get("seamark:" + ObjSTR.get(obj) + ":colour");
1203 bodyColour.clear();
1204 for (String item : str.split(";")) {
1205 for (Col col : ColSTR.keySet()) {
1206 if (ColSTR.get(col).equals(item)) {
1207 bodyColour.add(col);
1208 }
1209 }
1210 }
1211 }
1212 }
1213
1214 for (Obj obj : ObjSTR.keySet()) {
1215 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":colour_pattern")) {
1216 str = keys.get("seamark:" + ObjSTR.get(obj) + ":colour_pattern");
1217 setObjPattern(Pat.NONE);
1218 for (Pat pat : PatSTR.keySet()) {
1219 if (PatSTR.get(pat).equals(str)) {
1220 setObjPattern(pat);
1221 }
1222 }
1223 }
1224
1225 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":height")) {
1226 setHeight(keys.get("seamark:" + ObjSTR.get(obj) + ":height"));
1227 }
1228 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":elevation")) {
1229 setElevation(keys.get("seamark:" + ObjSTR.get(obj) + ":elevation"));
1230 }
1231 }
1232
1233 if ((getObject() == Obj.LNDMRK) && (getCategory() == Cat.NONE)) {
1234 setObject(Obj.LITHSE);
1235 }
1236
1237 if (getObject() == Obj.LITFLT) {
1238 switch (getObjColour(0)) {
1239 case RED:
1240 if ((getObjColour(1) == Col.WHITE) && (getObjColour(2) == Col.UNKNOWN)) {
1241 setObject(Obj.FLTSAW);
1242 setCategory(Cat.NONE);
1243 } else if (getObjColour(1) == Col.UNKNOWN) {
1244 setObject(Obj.FLTLAT);
1245 if (getRegion() == Reg.B) {
1246 setCategory(Cat.LAM_STBD);
1247 } else {
1248 setCategory(Cat.LAM_PORT);
1249 }
1250 } else if ((getObjColour(1) == Col.GREEN)
1251 && (getObjColour(2) == Col.RED)) {
1252 setObject(Obj.FLTLAT);
1253 if (getRegion() == Reg.B) {
1254 setCategory(Cat.LAM_PSTBD);
1255 } else {
1256 setCategory(Cat.LAM_PPORT);
1257 }
1258 } else if ((getObjColour(1) == Col.WHITE)
1259 && (getObjColour(2) == Col.RED)) {
1260 setObject(Obj.FLTLAT);
1261 setCategory(Cat.LAM_PORT);
1262 } else {
1263 setObject(Obj.FLTSPP);
1264 setCategory(Cat.NONE);
1265 }
1266 break;
1267 case GREEN:
1268 if (getObjColour(1) == Col.UNKNOWN) {
1269 setObject(Obj.FLTLAT);
1270 if (getRegion() == Reg.B) {
1271 setCategory(Cat.LAM_PORT);
1272 } else {
1273 setCategory(Cat.LAM_STBD);
1274 }
1275 } else if ((getObjColour(1) == Col.RED)
1276 && (getObjColour(2) == Col.GREEN)) {
1277 setObject(Obj.FLTLAT);
1278 if (getRegion() == Reg.B) {
1279 setCategory(Cat.LAM_PPORT);
1280 } else {
1281 setCategory(Cat.LAM_PSTBD);
1282 }
1283 } else if ((getObjColour(1) == Col.WHITE)
1284 && (getObjColour(2) == Col.GREEN)) {
1285 setObject(Obj.FLTLAT);
1286 setCategory(Cat.LAM_STBD);
1287 } else {
1288 setObject(Obj.FLTSPP);
1289 setCategory(Cat.NONE);
1290 }
1291 break;
1292 case YELLOW:
1293 if (getObjColour(1) == Col.BLACK) {
1294 setObject(Obj.FLTCAR);
1295 if (getObjColour(2) == Col.YELLOW) {
1296 setCategory(Cat.CAM_WEST);
1297 } else {
1298 setCategory(Cat.CAM_SOUTH);
1299 }
1300 } else {
1301 setObject(Obj.FLTSPP);
1302 setCategory(Cat.NONE);
1303 }
1304 break;
1305 case BLACK:
1306 if (getObjColour(1) == Col.RED) {
1307 setObject(Obj.FLTISD);
1308 setCategory(Cat.NONE);
1309 } else if (getObjColour(1) == Col.YELLOW) {
1310 setObject(Obj.FLTCAR);
1311 if (getObjColour(2) == Col.BLACK) {
1312 setCategory(Cat.CAM_EAST);
1313 } else {
1314 setCategory(Cat.CAM_NORTH);
1315 }
1316 } else {
1317 setObject(Obj.FLTSPP);
1318 setCategory(Cat.NONE);
1319 }
1320 break;
1321 default:
1322 setCategory(Cat.NONE);
1323 }
1324 }
1325
1326 for (Obj obj : ObjSTR.keySet()) {
1327 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":system")) {
1328 str = keys.get("seamark:" + ObjSTR.get(obj) + ":system");
1329 if (str.equals("iala-a"))
1330 setRegion(Reg.A);
1331 else if (str.equals("iala-b"))
1332 setRegion(Reg.B);
1333 else
1334 setRegion(Reg.C);
1335 } else if (GrpMAP.get(object) == Grp.LAT) {
1336 switch (getCategory()) {
1337 case LAM_PORT:
1338 if (getObjColour(0) == Col.RED) {
1339 if (getObjColour(1) == Col.WHITE)
1340 setRegion(Reg.C);
1341 else
1342 setRegion(Reg.A);
1343 }
1344 if (getObjColour(0) == Col.GREEN)
1345 setRegion(Reg.B);
1346 break;
1347 case LAM_PPORT:
1348 if (getObjColour(0) == Col.RED) {
1349 if (getObjColour(3) == Col.GREEN)
1350 setRegion(Reg.C);
1351 else
1352 setRegion(Reg.A);
1353 }
1354 if (getObjColour(0) == Col.GREEN)
1355 setRegion(Reg.B);
1356 break;
1357 case LAM_STBD:
1358 if (getObjColour(0) == Col.GREEN) {
1359 if (getObjColour(1) == Col.WHITE)
1360 setRegion(Reg.C);
1361 else
1362 setRegion(Reg.A);
1363 }
1364 if (getObjColour(0) == Col.RED)
1365 setRegion(Reg.B);
1366 break;
1367 case LAM_PSTBD:
1368 if (getObjColour(0) == Col.GREEN)
1369 setRegion(Reg.A);
1370 if (getObjColour(0) == Col.RED) {
1371 if (getObjColour(3) == Col.GREEN)
1372 setRegion(Reg.C);
1373 else
1374 setRegion(Reg.B);
1375 }
1376 break;
1377 }
1378 }
1379 }
1380
1381 if (keys.containsKey("seamark:topmark:shape")) {
1382 str = keys.get("seamark:topmark:shape");
1383 setTopmark(Top.NONE);
1384 for (Top top : TopSTR.keySet()) {
1385 if (TopSTR.get(top).equals(str)) {
1386 setTopmark(top);
1387 }
1388 }
1389 }
1390 if (keys.containsKey("seamark:topmark:colour")) {
1391 str = keys.get("seamark:topmark:colour");
1392 setTopColour(Col.UNKNOWN);
1393 for (Col col : ColSTR.keySet()) {
1394 if (ColSTR.get(col).equals(str)) {
1395 setTopColour(col);
1396 }
1397 }
1398 }
1399 if (keys.containsKey("seamark:topmark:colour_pattern")) {
1400 str = keys.get("seamark:topmark:colour_pattern");
1401 setTopPattern(Pat.NONE);
1402 for (Pat pat : PatSTR.keySet()) {
1403 if (PatSTR.get(pat).equals(str)) {
1404 setTopPattern(pat);
1405 }
1406 }
1407 }
1408
1409 clrLight();
1410 for (int i = 0; i < 30; i++) {
1411 String secStr = (i == 0) ? "" : (":" + Integer.toString(i));
1412 if (keys.containsKey("seamark:light" + secStr + ":colour")) {
1413 str = keys.get("seamark:light" + secStr + ":colour");
1414 for (Col col : ColSTR.keySet())
1415 if (ColSTR.get(col).equals(str))
1416 setLightAtt(Att.COL, i, col);
1417 }
1418 if (keys.containsKey("seamark:light" + secStr + ":character")) {
1419 str = keys.get("seamark:light" + secStr + ":character");
1420 if (str.contains("(") && str.contains(")")) {
1421 int i1 = str.indexOf("(");
1422 int i2 = str.indexOf(")");
1423 setLightAtt(Att.GRP, i, str.substring((i1+1), i2));
1424 str = str.substring(0, i1) + str.substring((i2+1), str.length());
1425 }
1426 setLightAtt(Att.CHR, i, str);
1427 }
1428 if (keys.containsKey("seamark:light" + secStr + ":group"))
1429 setLightAtt(Att.GRP, i, keys.get("seamark:light" + secStr + ":group"));
1430 if (keys.containsKey("seamark:light" + secStr + ":sequence"))
1431 setLightAtt(Att.SEQ, i, keys.get("seamark:light" + secStr + ":sequence"));
1432 if (keys.containsKey("seamark:light" + secStr + ":period"))
1433 setLightAtt(Att.PER, i, keys.get("seamark:light" + secStr + ":period"));
1434 if (keys.containsKey("seamark:light" + secStr + ":category")) {
1435 str = keys.get("seamark:light" + secStr + ":category");
1436 for (Lit lit : LitSTR.keySet())
1437 if (LitSTR.get(lit).equals(str))
1438 setLightAtt(Att.LIT, i, lit);
1439 }
1440 if (keys.containsKey("seamark:light" + secStr + ":sector_start"))
1441 setLightAtt(Att.BEG, i, keys.get("seamark:light" + secStr + ":sector_start"));
1442 if (keys.containsKey("seamark:light" + secStr + ":sector_end"))
1443 setLightAtt(Att.END, i, keys.get("seamark:light" + secStr + ":sector_end"));
1444 if (keys.containsKey("seamark:light" + secStr + ":radius"))
1445 setLightAtt(Att.RAD, i, keys.get("seamark:light" + secStr + ":radius"));
1446 if (keys.containsKey("seamark:light" + secStr + ":height"))
1447 setLightAtt(Att.HGT, i, keys.get("seamark:light" + secStr + ":height"));
1448 if (keys.containsKey("seamark:light" + secStr + ":range"))
1449 setLightAtt(Att.RNG, i, keys.get("seamark:light" + secStr + ":range"));
1450 if (keys.containsKey("seamark:light" + secStr + ":visibility")) {
1451 str = keys.get("seamark:light" + secStr + ":visibility");
1452 for (Vis vis : VisSTR.keySet())
1453 if (VisSTR.get(vis).equals(str))
1454 setLightAtt(Att.VIS, i, vis);
1455 }
1456 if (keys.containsKey("seamark:light" + secStr + ":exhibition")) {
1457 str = keys.get("seamark:light" + secStr + ":exhibition");
1458 for (Exh exh : ExhSTR.keySet())
1459 if (ExhSTR.get(exh).equals(str))
1460 setLightAtt(Att.EXH, i, exh);
1461 }
1462 if (keys.containsKey("seamark:light" + secStr + ":orientation"))
1463 setLightAtt(Att.ORT, i, keys.get("seamark:light" + secStr + ":orientation"));
1464 if (keys.containsKey("seamark:light" + secStr + ":multiple"))
1465 setLightAtt(Att.MLT, i, keys.get("seamark:light" + secStr + ":multiple"));
1466
1467 if (sectors.size() == i)
1468 break;
1469 }
1470
1471 if (keys.containsKey("seamark:fog_signal")) {
1472 setFogSound(Fog.UNKNOWN);
1473 }
1474 if (keys.containsKey("seamark:fog_signal:category")) {
1475 str = keys.get("seamark:fog_signal:category");
1476 setFogSound(Fog.NONE);
1477 for (Fog fog : FogSTR.keySet()) {
1478 if (FogSTR.get(fog).equals(str)) {
1479 setFogSound(fog);
1480 }
1481 }
1482 }
1483 if (keys.containsKey("seamark:fog_signal:group")) {
1484 setFogGroup(keys.get("seamark:fog_signal:group"));
1485 }
1486 if (keys.containsKey("seamark:fog_signal:period")) {
1487 setFogPeriod(keys.get("seamark:fog_signal:period"));
1488 }
1489 if (keys.containsKey("seamark:fog_signal:sequence")) {
1490 setFogSequence(keys.get("seamark:fog_signal:sequence"));
1491 }
1492 if (keys.containsKey("seamark:fog_signal:range")) {
1493 setFogRange(keys.get("seamark:fog_signal:range"));
1494 }
1495
1496 if (keys.containsKey("seamark:radar_reflector")) {
1497 setRadar(Rtb.REFLECTOR);
1498 }
1499 if (keys.containsKey("seamark:radar_transponder:category")) {
1500 str = keys.get("seamark:radar_transponder:category");
1501 setRadar(Rtb.NONE);
1502 for (Rtb rtb : RtbSTR.keySet()) {
1503 if (RtbSTR.get(rtb).equals(str)) {
1504 setRadar(rtb);
1505 }
1506 }
1507 }
1508 if (keys.containsKey("seamark:radar_transponder:group")) {
1509 setRaconGroup(keys.get("seamark:radar_transponder:group"));
1510 }
1511 if (keys.containsKey("seamark:radar_transponder:period")) {
1512 setRaconPeriod(keys.get("seamark:radar_transponder:period"));
1513 }
1514 if (keys.containsKey("seamark:radar_transponder:sequence")) {
1515 setRaconSequence(keys.get("seamark:radar_transponder:sequence"));
1516 }
1517 if (keys.containsKey("seamark:radar_transponder:range")) {
1518 setRaconRange(keys.get("seamark:radar_transponder:range"));
1519 }
1520 if (keys.containsKey("seamark:radar_transponder:sector_start")) {
1521 setRaconSector1(keys.get("seamark:radar_transponder:sector_start"));
1522 }
1523 if (keys.containsKey("seamark:radar_transponder:sector_end")) {
1524 setRaconSector2(keys.get("seamark:radar_transponder:sector_end"));
1525 }
1526
1527 if (keys.containsKey("seamark:information")) {
1528 setInfo(keys.get("seamark:information"));
1529 }
1530 if (keys.containsKey("seamark:source")) {
1531 setSource(keys.get("seamark:source"));
1532 }
1533 if (keys.containsKey("seamark:height")) {
1534 setHeight(keys.get("seamark:height"));
1535 }
1536 if (keys.containsKey("seamark:elevation")) {
1537 setElevation(keys.get("seamark:elevation"));
1538 }
1539 if (keys.containsKey("seamark:status")) {
1540 str = keys.get("seamark:status");
1541 setStatus(Sts.UNKNOWN);
1542 for (Sts sts : StsSTR.keySet()) {
1543 if (StsSTR.get(sts).equals(str)) {
1544 setStatus(sts);
1545 }
1546 }
1547 }
1548 if (keys.containsKey("seamark:construction")) {
1549 str = keys.get("seamark:construction");
1550 setConstr(Cns.UNKNOWN);
1551 for (Cns cns : CnsSTR.keySet()) {
1552 if (CnsSTR.get(cns).equals(str)) {
1553 setConstr(cns);
1554 }
1555 }
1556 }
1557 if (keys.containsKey("seamark:conspicuity")) {
1558 str = keys.get("seamark:conspicuity");
1559 setConsp(Con.UNKNOWN);
1560 for (Con con : ConSTR.keySet()) {
1561 if (ConSTR.get(con).equals(str)) {
1562 setConsp(con);
1563 }
1564 }
1565 }
1566 if (keys.containsKey("seamark:reflectivity")) {
1567 str = keys.get("seamark:reflectivity");
1568 setRefl(Con.UNKNOWN);
1569 for (Con con : ConSTR.keySet()) {
1570 if (ConSTR.get(con).equals(str)) {
1571 setRefl(con);
1572 }
1573 }
1574 }
1575
1576 if (keys.containsKey("seamark:ref")) {
1577 setRef(keys.get("seamark:ref"));
1578 }
1579 if (keys.containsKey("seamark:reference")) {
1580 setRef(keys.get("seamark:reference"));
1581 }
1582 if (keys.containsKey("seamark:light:ref")) {
1583 setLightRef(keys.get("seamark:light:ref"));
1584 }
1585 if (keys.containsKey("seamark:light:reference")) {
1586 setLightRef(keys.get("seamark:light:reference"));
1587 }
1588 if (keys.containsKey("seamark:fixme")) {
1589 setFixme(keys.get("seamark:fixme"));
1590 }
1591
1592 dlg.panelMain.syncPanel();
1593
1594 paintlock = false;
1595 paintSign();
1596 }
1597
1598 public void paintSign() {
1599
1600 if (paintlock)
1601 return;
1602
1603 dlg.panelMain.shapeIcon.setIcon(null);
1604 dlg.panelMain.litLabel.setText("");
1605 dlg.panelMain.colLabel.setText("");
1606 dlg.panelMain.radarLabel.setText("");
1607 dlg.panelMain.fogLabel.setText("");
1608 dlg.panelMain.topIcon.setIcon(null);
1609 dlg.panelMain.fogIcon.setIcon(null);
1610 dlg.panelMain.radarIcon.setIcon(null);
1611 dlg.panelMain.lightIcon.setIcon(null);
1612
1613 String colStr;
1614 String lblStr;
1615 String imgStr = "/images/";
1616 if (getShape() != Shp.UNKNOWN) {
1617 switch (getShape()) {
1618 case TOWER:
1619 imgStr += "Tower";
1620 break;
1621 case BUOY:
1622 case PILLAR:
1623 imgStr += "Pillar";
1624 break;
1625 case SPAR:
1626 imgStr += "Spar";
1627 break;
1628 case CAN:
1629 imgStr += "Can";
1630 break;
1631 case CONE:
1632 imgStr += "Cone";
1633 break;
1634 case SPHERE:
1635 imgStr += "Sphere";
1636 break;
1637 case BARREL:
1638 imgStr += "Barrel";
1639 break;
1640 case CAIRN:
1641 imgStr += "Cairn";
1642 break;
1643 case FLOAT:
1644 imgStr += "Float";
1645 break;
1646 case BEACON:
1647 case PILE:
1648 case LATTICE:
1649 case BUOYANT:
1650 imgStr += "Beacon";
1651 break;
1652 case SUPER:
1653 imgStr += "Super";
1654 break;
1655 case STAKE:
1656 case POLE:
1657 case POST:
1658 imgStr += "Stake";
1659 break;
1660 }
1661 colStr = imgStr;
1662 lblStr = "";
1663 for (Col col : bodyColour) {
1664 switch (col) {
1665 case WHITE:
1666 colStr += "_White";
1667 lblStr += "W";
1668 break;
1669 case RED:
1670 colStr += "_Red";
1671 lblStr += "R";
1672 break;
1673 case ORANGE:
1674 colStr += "_Orange";
1675 lblStr += "Or";
1676 break;
1677 case AMBER:
1678 colStr += "_Amber";
1679 lblStr += "Am";
1680 break;
1681 case YELLOW:
1682 colStr += "_Yellow";
1683 lblStr += "Y";
1684 break;
1685 case GREEN:
1686 colStr += "_Green";
1687 lblStr += "G";
1688 break;
1689 case BLUE:
1690 colStr += "_Blue";
1691 lblStr += "Bu";
1692 break;
1693 case VIOLET:
1694 colStr += "_Violet";
1695 lblStr += "Vi";
1696 break;
1697 case BLACK:
1698 colStr += "_Black";
1699 lblStr += "B";
1700 break;
1701 case GREY:
1702 colStr += "_Grey";
1703 lblStr += "Gr";
1704 break;
1705 case BROWN:
1706 colStr += "_Brown";
1707 lblStr += "Br";
1708 break;
1709 case MAGENTA:
1710 colStr += "_Magenta";
1711 lblStr += "Mg";
1712 break;
1713 case PINK:
1714 colStr += "_Pink";
1715 lblStr += "Pk";
1716 break;
1717 }
1718 }
1719 if (getShape() == Shp.PERCH) {
1720 if (getCategory() == Cat.LAM_PORT) {
1721 colStr = "/images/Perch_Port";
1722 } else {
1723 colStr = "/images/Perch_Starboard";
1724 }
1725 }
1726 if (!imgStr.equals("/images/")) {
1727 colStr += ".png";
1728 if (getClass().getResource(colStr) == null) {
1729 System.out.println("Missing image: " + colStr);
1730 imgStr += ".png";
1731 if (getClass().getResource(imgStr) == null) {
1732 System.out.println("Missing image: " + imgStr);
1733 } else {
1734 dlg.panelMain.shapeIcon.setIcon(new ImageIcon(getClass()
1735 .getResource(imgStr)));
1736 dlg.panelMain.colLabel.setText(lblStr);
1737 }
1738 } else {
1739 dlg.panelMain.shapeIcon.setIcon(new ImageIcon(getClass().getResource(colStr)));
1740 }
1741 } else {
1742 dlg.panelMain.shapeIcon.setIcon(null);
1743 }
1744 } else if (getObject() != Obj.UNKNOWN) {
1745 switch (getObject()) {
1746 case LNDMRK:
1747 switch (getCategory()) {
1748 case LMK_CHMY:
1749 imgStr += "Chimney";
1750 break;
1751 case LMK_CARN:
1752 imgStr += "Cairn";
1753 break;
1754 case LMK_DSHA:
1755 imgStr += "DishAerial";
1756 break;
1757 case LMK_FLGS:
1758 imgStr += "Flagstaff";
1759 break;
1760 case LMK_FLRS:
1761 imgStr += "FlareStack";
1762 break;
1763 case LMK_MNMT:
1764 imgStr += "Monument";
1765 break;
1766 case LMK_RADM:
1767 imgStr += "RadioMast";
1768 break;
1769 case LMK_TOWR:
1770 imgStr += "LandTower";
1771 break;
1772 case LMK_WNDM:
1773 imgStr += "Wind_Motor";
1774 break;
1775 case LMK_WTRT:
1776 imgStr += "WaterTower";
1777 break;
1778 }
1779 break;
1780 case LITHSE:
1781 imgStr += "Light_House";
1782 break;
1783 case LITMAJ:
1784 imgStr += "Light_Major";
1785 break;
1786 case LITMIN:
1787 imgStr += "Light_Minor";
1788 break;
1789 case LITFLT:
1790 imgStr += "Float";
1791 break;
1792 case LITVES:
1793 imgStr += "Super";
1794 break;
1795 case SISTAW:
1796 imgStr += "Signal_Station";
1797 break;
1798 case SISTAT:
1799 imgStr += "Signal_Station";
1800 break;
1801 }
1802 if (!imgStr.equals("/images/")) {
1803 imgStr += ".png";
1804 if (getClass().getResource(imgStr) == null) {
1805 System.out.println("Missing image: " + imgStr);
1806 } else {
1807 dlg.panelMain.shapeIcon.setIcon(new ImageIcon(getClass().getResource(imgStr)));
1808 }
1809 } else {
1810 dlg.panelMain.shapeIcon.setIcon(null);
1811 }
1812 }
1813
1814 if (getTopmark() != Top.NONE) {
1815 imgStr = "/images/Top_";
1816 switch (getTopmark()) {
1817 case CAN:
1818 imgStr += "Can";
1819 break;
1820 case CONE:
1821 imgStr += "Cone";
1822 break;
1823 case SPHERE:
1824 imgStr += "Sphere";
1825 break;
1826 case X_SHAPE:
1827 imgStr += "X";
1828 break;
1829 case NORTH:
1830 imgStr += "North";
1831 break;
1832 case SOUTH:
1833 imgStr += "South";
1834 break;
1835 case EAST:
1836 imgStr += "East";
1837 break;
1838 case WEST:
1839 imgStr += "West";
1840 break;
1841 case SPHERES2:
1842 imgStr += "Isol";
1843 break;
1844 }
1845 colStr = imgStr;
1846 for (Col col : topmarkColour) {
1847 switch (col) {
1848 case WHITE:
1849 colStr += "_White";
1850 break;
1851 case RED:
1852 colStr += "_Red";
1853 break;
1854 case ORANGE:
1855 colStr += "_Orange";
1856 break;
1857 case AMBER:
1858 colStr += "_Amber";
1859 break;
1860 case YELLOW:
1861 colStr += "_Yellow";
1862 break;
1863 case GREEN:
1864 colStr += "_Green";
1865 break;
1866 case BLUE:
1867 colStr += "_Blue";
1868 break;
1869 case VIOLET:
1870 colStr += "_Violet";
1871 break;
1872 case BLACK:
1873 colStr += "_Black";
1874 break;
1875 }
1876 }
1877 switch (getShape()) {
1878 case CAN:
1879 case CONE:
1880 case SPHERE:
1881 case BARREL:
1882 imgStr += "_Buoy_Small";
1883 colStr += "_Buoy_Small";
1884 break;
1885 case PILLAR:
1886 case SPAR:
1887 imgStr += "_Buoy";
1888 colStr += "_Buoy";
1889 break;
1890 case FLOAT:
1891 case SUPER:
1892 imgStr += "_Float";
1893 colStr += "_Float";
1894 break;
1895 case BUOYANT:
1896 case CAIRN:
1897 case PILE:
1898 case LATTICE:
1899 case TOWER:
1900 case STAKE:
1901 case POLE:
1902 case POST:
1903 case BEACON:
1904 imgStr += "_Beacon";
1905 colStr += "_Beacon";
1906 break;
1907 }
1908 colStr += ".png";
1909 if (getClass().getResource(colStr) == null) {
1910 System.out.println("Missing image: " + colStr);
1911 imgStr += ".png";
1912 if (getClass().getResource(imgStr) == null) {
1913 System.out.println("Missing image: " + imgStr);
1914 return;
1915 } else {
1916 dlg.panelMain.topIcon.setIcon(new ImageIcon(getClass().getResource(imgStr)));
1917 }
1918 } else {
1919 dlg.panelMain.topIcon.setIcon(new ImageIcon(getClass().getResource(colStr)));
1920 }
1921 } else {
1922 dlg.panelMain.topIcon.setIcon(null);
1923 }
1924
1925 if (getFogSound() != Fog.NONE) {
1926 dlg.panelMain.fogIcon.setIcon(new ImageIcon(getClass().getResource("/images/Fog_Signal.png")));
1927 String str = "";
1928 if (getFogSound() != Fog.UNKNOWN)
1929 switch (getFogSound()) {
1930 case HORN:
1931 str = "Horn";
1932 break;
1933 case SIREN:
1934 str = "Siren";
1935 break;
1936 case DIA:
1937 str = "Dia";
1938 break;
1939 case BELL:
1940 str = "Bell";
1941 break;
1942 case WHIS:
1943 str = "Whis";
1944 break;
1945 case GONG:
1946 str = "Gong";
1947 break;
1948 case EXPLOS:
1949 str = "Explos";
1950 break;
1951 }
1952 if (!getFogGroup().isEmpty())
1953 str += ("(" + getFogGroup() + ")");
1954 else
1955 str += " ";
1956 if (!getFogPeriod().isEmpty())
1957 str += getFogPeriod() + "s";
1958 dlg.panelMain.fogLabel.setText(str);
1959 }
1960
1961 if (RaType != Rtb.NONE) {
1962 if (getRadar() == Rtb.REFLECTOR) {
1963 dlg.panelMain.radarIcon.setIcon(new ImageIcon(getClass().getResource("/images/Radar_Reflector_355.png")));
1964 } else {
1965 dlg.panelMain.radarIcon.setIcon(new ImageIcon(getClass().getResource("/images/Radar_Station.png")));
1966 String str = "";
1967 if (getRadar() == Rtb.RAMARK)
1968 str += "Ramark";
1969 else
1970 str += "Racon";
1971 if (!getRaconGroup().isEmpty())
1972 str += ("(" + getRaconGroup() + ")");
1973 else
1974 str += " ";
1975 if (!getRaconPeriod().isEmpty())
1976 str += getRaconPeriod() + "s";
1977 dlg.panelMain.radarLabel.setText(str);
1978 }
1979 }
1980
1981 if (getLightAtt(Att.COL, 0) != Col.UNKNOWN) {
1982 if (sectors.size() == 1) {
1983 switch ((Col) getLightAtt(Att.COL, 0)) {
1984 case RED:
1985 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Red_120.png")));
1986 break;
1987 case GREEN:
1988 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Green_120.png")));
1989 break;
1990 case WHITE:
1991 case YELLOW:
1992 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_White_120.png")));
1993 break;
1994 default:
1995 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Magenta_120.png")));
1996 }
1997 }
1998 String c = (String) dlg.mark.getLightAtt(Att.CHR, 0);
1999 String tmp = "";
2000 if (c.contains("+")) {
2001 int i1 = c.indexOf("+");
2002 tmp = c.substring(i1, c.length());
2003 c = c.substring(0, i1);
2004 if (!((String) getLightAtt(Att.GRP, 0)).isEmpty()) {
2005 c += "(" + (String) getLightAtt(Att.GRP, 0) + ")";
2006 }
2007 if (tmp != null)
2008 c += tmp;
2009 } else if (!((String) getLightAtt(Att.GRP, 0)).isEmpty())
2010 c += "(" + (String) getLightAtt(Att.GRP, 0) + ")";
2011 switch ((Col) getLightAtt(Att.COL, 0)) {
2012 case RED:
2013 c += ".R";
2014 break;
2015 case GREEN:
2016 c += ".G";
2017 break;
2018 case AMBER:
2019 c += ".Am";
2020 break;
2021 case ORANGE:
2022 c += ".Or";
2023 break;
2024 case BLUE:
2025 c += ".Bu";
2026 break;
2027 case VIOLET:
2028 c += ".Vi";
2029 break;
2030 }
2031 tmp = (String) getLightAtt(Att.MLT, 0);
2032 if (!tmp.isEmpty())
2033 c = tmp + c;
2034 if (dlg.mark.getLightAtt(Att.LIT, 0) != Lit.UNKNOWN) {
2035 switch ((Lit)dlg.mark.getLightAtt(Att.LIT, 0)) {
2036 case VERT:
2037 c += "(Vert)";
2038 break;
2039 case HORIZ:
2040 c += "(Horiz)";
2041 break;
2042 }
2043 }
2044 tmp = (String) getLightAtt(Att.PER, 0);
2045 if (!tmp.isEmpty())
2046 c += " " + tmp + "s";
2047 dlg.panelMain.litLabel.setText(c);
2048 }
2049
2050 paintlock = false;
2051 }
2052
2053 public void saveSign(Node node) {
2054
2055 if (getObject() != Obj.UNKNOWN) {
2056
2057 Main.pref.put("smedplugin.IALA", getRegion() == Reg.C ? "C" : (getRegion() == Reg.B ? "B" : "A"));
2058
2059 for (String str : node.getKeys().keySet()) {
2060 if (str.trim().matches("^seamark:\\S+"))
2061 Main.main.undoRedo.add(new ChangePropertyCommand(node, str, null));
2062 }
2063
2064 if (!getName().isEmpty())
2065 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:name", getName()));
2066
2067 String objStr = ObjSTR.get(object);
2068 if (objStr != null) {
2069 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:type", objStr));
2070
2071 if (getShape() != Shp.FLOAT) {
2072 String str = CatSTR.get(getCategory());
2073 if (str != null)
2074 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":category", str));
2075 if ((getShape() != Shp.BUOY) && (getShape() != Shp.BEACON))
2076 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":shape", ShpSTR.get(getShape())));
2077 }
2078
2079 if ((getObjColour(0) != Col.UNKNOWN) && getShape() != Shp.PERCH) {
2080 String str = ColSTR.get(getObjColour(0));
2081 for (int i = 1; bodyColour.size() > i; i++) {
2082 str += (";" + ColSTR.get(getObjColour(i)));
2083 }
2084 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour", str));
2085 }
2086
2087 if (getObjPattern() != Pat.NONE) {
2088 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour_pattern", PatSTR.get(getObjPattern())));
2089 }
2090
2091 if ((GrpMAP.get(object) == Grp.LAT) && (getShape() != Shp.PERCH)
2092 || (getObject() == Obj.FLTLAT)) {
2093 switch (region) {
2094 case A:
2095 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":system", "iala-a"));
2096 break;
2097 case B:
2098 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":system", "iala-b"));
2099 break;
2100 case C:
2101 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":system", "other"));
2102 break;
2103 }
2104 }
2105 if (!getHeight().isEmpty()) {
2106 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":height", getHeight()));
2107 }
2108 if (!getElevation().isEmpty()) {
2109 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":elevation", getElevation()));
2110 }
2111 }
2112 if (getTopmark() != Top.NONE) {
2113 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:topmark:shape", TopSTR.get(getTopmark())));
2114 if (getTopPattern() != Pat.NONE)
2115 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:topmark:colour_pattern", PatSTR.get(getTopPattern())));
2116 if (getTopColour(0) != Col.UNKNOWN) {
2117 String str = ColSTR.get(getTopColour(0));
2118 for (int i = 1; topmarkColour.size() > i; i++) {
2119 str += (";" + ColSTR.get(getTopColour(i)));
2120 }
2121 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:topmark:colour", str));
2122 }
2123 }
2124
2125 for (int i = 0; i < sectors.size(); i++) {
2126 String secStr = (i == 0) ? "" : (":" + Integer.toString(i));
2127 if (sectors.get(i)[0] != Col.UNKNOWN)
2128 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", ColSTR.get(sectors.get(i)[0])));
2129 if (!((String) sectors.get(i)[1]).isEmpty())
2130 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":character", (String) sectors.get(i)[1]));
2131 if (!((String) sectors.get(i)[2]).isEmpty())
2132 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":group", (String) sectors.get(i)[2]));
2133 if (!((String) sectors.get(i)[3]).isEmpty())
2134 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sequence", (String) sectors.get(i)[3]));
2135 if (!((String) sectors.get(i)[4]).isEmpty())
2136 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":period", (String) sectors.get(i)[4]));
2137 if (sectors.get(i)[5] != Lit.UNKNOWN)
2138 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":category", LitSTR.get(sectors.get(i)[5])));
2139 if (!((String) sectors.get(i)[6]).isEmpty())
2140 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sector_start", (String) sectors.get(i)[6]));
2141 if (!((String) sectors.get(i)[7]).isEmpty())
2142 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sector_end", (String) sectors.get(i)[7]));
2143 if (!((String) sectors.get(i)[8]).isEmpty())
2144 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":radius", (String) sectors.get(i)[8]));
2145 if (!((String) sectors.get(i)[9]).isEmpty())
2146 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":height", (String) sectors.get(i)[9]));
2147 if (!((String) sectors.get(i)[10]).isEmpty())
2148 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":range", (String) sectors.get(i)[10]));
2149 if (sectors.get(i)[11] != Vis.UNKNOWN)
2150 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":visibility", VisSTR.get(sectors.get(i)[11])));
2151 if (sectors.get(i)[12] != Exh.UNKNOWN)
2152 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":exhibition", ExhSTR.get(sectors.get(i)[12])));
2153 if (!((String) sectors.get(i)[13]).isEmpty())
2154 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":orientation", (String) sectors.get(i)[13]));
2155 if (!((String) sectors.get(i)[14]).isEmpty())
2156 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":multiple", (String) sectors.get(i)[14]));
2157 }
2158
2159 if (getFogSound() != Fog.NONE) {
2160 if (getFogSound() == Fog.UNKNOWN)
2161 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal", "yes"));
2162 else
2163 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:category", FogSTR.get(getFogSound())));
2164 if (!getFogGroup().isEmpty()) {
2165 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:group", getFogGroup()));
2166 }
2167 if (!getFogPeriod().isEmpty()) {
2168 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:period", getFogPeriod()));
2169 }
2170 if (!getFogSequence().isEmpty()) {
2171 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:sequence", getFogSequence()));
2172 }
2173 if (!getFogRange().isEmpty()) {
2174 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:range", getFogRange()));
2175 }
2176 }
2177
2178 if (RaType != Rtb.NONE) {
2179 if (getRadar() == Rtb.REFLECTOR) {
2180 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_reflector", "yes"));
2181 } else {
2182 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:category", RtbSTR.get(getRadar())));
2183 if (!getRaconGroup().isEmpty()) {
2184 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:group", getRaconGroup()));
2185 }
2186 if (!getRaconPeriod().isEmpty()) {
2187 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:period", getRaconPeriod()));
2188 }
2189 if (!getRaconSequence().isEmpty()) {
2190 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:sequence", getRaconSequence()));
2191 }
2192 if (!getRaconRange().isEmpty()) {
2193 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:range", getRaconRange()));
2194 }
2195 if ((!getRaconSector1().isEmpty()) && (!getRaconSector2().isEmpty())) {
2196 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:sector_start", getRaconSector1()));
2197 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:sector_end", getRaconSector2()));
2198 }
2199 }
2200 }
2201
2202 if (!getInfo().isEmpty()) {
2203 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:information", getInfo()));
2204 }
2205 if (!getSource().isEmpty()) {
2206 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:source", getSource()));
2207 }
2208 if (getStatus() != Sts.UNKNOWN) {
2209 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:status", StsSTR.get(getStatus())));
2210 }
2211 if (getConstr() != Cns.UNKNOWN) {
2212 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:construction", CnsSTR.get(getConstr())));
2213 }
2214 if (getConsp() != Con.UNKNOWN) {
2215 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:conspicuity", ConSTR.get(getConsp())));
2216 }
2217 if (getRefl() != Con.UNKNOWN) {
2218 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:reflectivity", ConSTR.get(getRefl())));
2219 }
2220 if (!getRef().isEmpty()) {
2221 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:reference", getRef()));
2222 }
2223 if (!getLightRef().isEmpty()) {
2224 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light:reference", getLightRef()));
2225 }
2226 if (!getFixme().isEmpty()) {
2227 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fixme", getFixme()));
2228 }
2229 }
2230 }
2231
2232}
Note: See TracBrowser for help on using the repository browser.