source: osm/applications/editors/josm/plugins/seachart/src/render/Signals.java@ 35096

Last change on this file since 35096 was 35096, checked in by malcolmh, 6 years ago

[Seachart] Publish new release

File size: 25.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package render;
3
4import java.awt.Color;
5import java.awt.Font;
6import java.awt.geom.AffineTransform;
7import java.text.DecimalFormat;
8import java.util.ArrayList;
9import java.util.EnumMap;
10
11import s57.S57att.Att;
12import s57.S57map.AttMap;
13import s57.S57map.ObjTab;
14import s57.S57obj.Obj;
15import s57.S57val.BoySHP;
16import s57.S57val.CatFOG;
17import s57.S57val.CatLIT;
18import s57.S57val.CatROS;
19import s57.S57val.CatRTB;
20import s57.S57val.ColCOL;
21import s57.S57val.LitCHR;
22import symbols.Beacons;
23import symbols.Symbols;
24import symbols.Symbols.Delta;
25import symbols.Symbols.Handle;
26import symbols.Symbols.Scheme;
27import symbols.Topmarks;
28
29/**
30 * @author Malcolm Herring
31 */
32public class Signals extends Rules {
33
34 static final EnumMap<ColCOL, Color> LightColours = new EnumMap<>(ColCOL.class);
35 static {
36 LightColours.put(ColCOL.COL_WHT, new Color(0xffff00));
37 LightColours.put(ColCOL.COL_RED, new Color(0xff0000));
38 LightColours.put(ColCOL.COL_GRN, new Color(0x00ff00));
39 LightColours.put(ColCOL.COL_BLU, new Color(0x0000ff));
40 LightColours.put(ColCOL.COL_YEL, new Color(0xffff00));
41 LightColours.put(ColCOL.COL_AMB, new Color(0xffc200));
42 LightColours.put(ColCOL.COL_VIO, new Color(0xee82ee));
43 LightColours.put(ColCOL.COL_ORG, Color.orange);
44 LightColours.put(ColCOL.COL_MAG, Color.magenta);
45 }
46
47 static final EnumMap<ColCOL, String> LightLetters = new EnumMap<>(ColCOL.class);
48 static {
49 LightLetters.put(ColCOL.COL_WHT, "W");
50 LightLetters.put(ColCOL.COL_RED, "R");
51 LightLetters.put(ColCOL.COL_GRN, "G");
52 LightLetters.put(ColCOL.COL_BLU, "Bu");
53 LightLetters.put(ColCOL.COL_YEL, "Y");
54 LightLetters.put(ColCOL.COL_AMB, "Am");
55 LightLetters.put(ColCOL.COL_VIO, "Vi");
56 LightLetters.put(ColCOL.COL_ORG, "Or");
57 }
58
59 static final EnumMap<LitCHR, String> LightCharacters = new EnumMap<>(LitCHR.class);
60 static {
61 LightCharacters.put(LitCHR.CHR_F, "F");
62 LightCharacters.put(LitCHR.CHR_FL, "Fl");
63 LightCharacters.put(LitCHR.CHR_LFL, "LFl");
64 LightCharacters.put(LitCHR.CHR_Q, "Q");
65 LightCharacters.put(LitCHR.CHR_VQ, "VQ");
66 LightCharacters.put(LitCHR.CHR_UQ, "UQ");
67 LightCharacters.put(LitCHR.CHR_ISO, "Iso");
68 LightCharacters.put(LitCHR.CHR_OC, "Oc");
69 LightCharacters.put(LitCHR.CHR_IQ, "IQ");
70 LightCharacters.put(LitCHR.CHR_IVQ, "IVQ");
71 LightCharacters.put(LitCHR.CHR_IUQ, "IUQ");
72 LightCharacters.put(LitCHR.CHR_MO, "Mo");
73 LightCharacters.put(LitCHR.CHR_FFL, "FFl");
74 LightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl");
75 LightCharacters.put(LitCHR.CHR_OCFL, "OcFl");
76 LightCharacters.put(LitCHR.CHR_FLFL, "FLFl");
77 LightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc");
78 LightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl");
79 LightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl");
80 LightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr");
81 LightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl");
82 LightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl");
83 LightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl");
84 LightCharacters.put(LitCHR.CHR_AL, "Al");
85 LightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl");
86 }
87
88 static final EnumMap<CatFOG, String> fogSignals = new EnumMap<>(CatFOG.class);
89 static {
90 fogSignals.put(CatFOG.FOG_EXPL, "Explos");
91 fogSignals.put(CatFOG.FOG_DIA, "Dia");
92 fogSignals.put(CatFOG.FOG_SIRN, "Siren");
93 fogSignals.put(CatFOG.FOG_NAUT, "Horn");
94 fogSignals.put(CatFOG.FOG_REED, "Horn");
95 fogSignals.put(CatFOG.FOG_TYPH, "Horn");
96 fogSignals.put(CatFOG.FOG_BELL, "Bell");
97 fogSignals.put(CatFOG.FOG_WHIS, "Whis");
98 fogSignals.put(CatFOG.FOG_GONG, "Gong");
99 fogSignals.put(CatFOG.FOG_HORN, "Horn");
100 }
101
102 static final DecimalFormat df = new DecimalFormat("#.#");
103
104 public static void addSignals() {
105 if (feature.objs.containsKey(Obj.RADRFL))
106 reflectors();
107 if (feature.objs.containsKey(Obj.FOGSIG))
108 fogSignals();
109 if (feature.objs.containsKey(Obj.RTPBCN))
110 radarStations();
111 if (feature.objs.containsKey(Obj.RADSTA))
112 radarStations();
113 if (feature.objs.containsKey(Obj.RDOSTA))
114 radioStations();
115 if (feature.objs.containsKey(Obj.LIGHTS))
116 lights();
117 }
118
119 public static void reflectors() {
120 if (Renderer.zoom >= 14) {
121 switch (feature.type) {
122 case BCNLAT:
123 case BCNCAR:
124 case BCNISD:
125 case BCNSAW:
126 case BCNSPP:
127 if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
128 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -140)));
129 } else {
130 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -80)));
131 }
132 break;
133 case LITFLT:
134 case LITVES:
135 case BOYINB:
136 if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
137 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -110)));
138 } else {
139 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -60)));
140 }
141 break;
142 case LITMAJ:
143 case LITMIN:
144 if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
145 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
146 } else {
147 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -30)));
148 }
149 break;
150 case BOYLAT:
151 case BOYCAR:
152 case BOYISD:
153 case BOYSAW:
154 case BOYSPP:
155 if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
156 if (testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_PILR) || testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_SPAR)) {
157 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(50, -160)));
158 } else {
159 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(25, -80)));
160 }
161 } else {
162 if (testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_PILR) || testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_SPAR)) {
163 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(30, -100)));
164 } else {
165 Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(10, -50)));
166 }
167 }
168 break;
169 default:
170 break;
171 }
172 }
173 }
174
175 public static void fogSignals() {
176 if (Renderer.zoom >= 11)
177 Renderer.symbol(Beacons.FogSignal);
178 if (Renderer.zoom >= 15) {
179 AttMap atts = feature.objs.get(Obj.FOGSIG).get(0);
180 if (atts != null) {
181 String str = "";
182 if (atts.containsKey(Att.CATFOG)) {
183 str += fogSignals.get(((ArrayList<?>) atts.get(Att.CATFOG).val).get(0));
184 }
185 if (atts.containsKey(Att.SIGGRP)) {
186 str += "(" + atts.get(Att.SIGGRP).val + ")";
187 } else {
188 str += " ";
189 }
190 if (atts.containsKey(Att.SIGPER)) {
191 str += df.format(atts.get(Att.SIGPER).val) + "s";
192 }
193 if (atts.containsKey(Att.VALMXR)) {
194 str += df.format(atts.get(Att.VALMXR).val) + "M";
195 }
196 if (!str.isEmpty()) {
197 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-60, -30)));
198 }
199 }
200 }
201 }
202
203 public static void radarStations() {
204 if (Renderer.zoom >= 11)
205 Renderer.symbol(Beacons.RadarStation);
206 if (Renderer.zoom >= 15) {
207 String bstr = "";
208 CatRTB cat = (CatRTB) getAttEnum(Obj.RTPBCN, Att.CATRTB);
209 String wal = getAttStr(Obj.RTPBCN, Att.RADWAL);
210 if ((cat == CatRTB.RTB_RAMK) || (cat == CatRTB.RTB_RACN)) {
211 switch (cat) {
212 case RTB_RAMK:
213 bstr += " Ramark";
214 break;
215 case RTB_RACN:
216 bstr += " Racon";
217 break;
218 default:
219 break;
220 }
221 String astr = getAttStr(Obj.RTPBCN, Att.SIGGRP);
222 if (!astr.isEmpty()) {
223 bstr += "(" + astr + ")";
224 }
225 Double per = (Double) getAttVal(Obj.RTPBCN, Att.SIGPER);
226 Double mxr = (Double) getAttVal(Obj.RTPBCN, Att.VALMXR);
227 if ((per != null) || (mxr != null)) {
228 bstr += (astr.isEmpty() ? " " : "");
229 if (per != null)
230 bstr += (per != 0) ? per.toString() + "s" : "";
231 if (mxr != null)
232 bstr += (mxr != 0) ? mxr.toString() + "M" : "";
233 }
234 }
235 if (!wal.isEmpty()) {
236 switch (wal) {
237 case "0.03-X":
238 bstr += "(3cm)";
239 break;
240 case "0.10-S":
241 bstr += "(10cm)";
242 break;
243 }
244 }
245 if (!bstr.isEmpty()) {
246 Renderer.labelText(bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
247 }
248 }
249 }
250
251 @SuppressWarnings("unchecked")
252 public static void radioStations() {
253 String bstr = "";
254 if (Renderer.zoom >= 11) {
255 ArrayList<CatROS> cats = (ArrayList<CatROS>) getAttList(Obj.RDOSTA, Att.CATROS);
256 for (CatROS ros : cats) {
257 switch (ros) {
258 case ROS_OMNI:
259 bstr += " RC";
260 break;
261 case ROS_DIRL:
262 bstr += " RD";
263 break;
264 case ROS_ROTP:
265 bstr += " RW";
266 break;
267 case ROS_CNSL:
268 bstr += " Consol";
269 break;
270 case ROS_RDF:
271 bstr += " RG";
272 break;
273 case ROS_QTA:
274 bstr += " R";
275 break;
276 case ROS_AERO:
277 bstr += " AeroRC";
278 break;
279 case ROS_DECA:
280 bstr += " Decca";
281 break;
282 case ROS_LORN:
283 bstr += " Loran";
284 break;
285 case ROS_DGPS:
286 bstr += " DGPS";
287 break;
288 case ROS_TORN:
289 bstr += " Toran";
290 break;
291 case ROS_OMGA:
292 bstr += " Omega";
293 break;
294 case ROS_SYLD:
295 bstr += " Syledis";
296 break;
297 case ROS_CHKA:
298 bstr += " Chiaka";
299 break;
300 case ROS_PCOM:
301 case ROS_COMB:
302 case ROS_FACS:
303 case ROS_TIME:
304 break;
305 case ROS_AISB:
306 case ROS_PAIS:
307 bstr += " AIS";
308 break;
309 default:
310 break;
311 }
312 }
313 Renderer.symbol(Beacons.RadarStation);
314 }
315 if (Renderer.zoom >= 15) {
316 if (!bstr.isEmpty()) {
317 Renderer.labelText(bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110)));
318 }
319 }
320 }
321
322 static class Sect {
323 int dir;
324 LitCHR chr;
325 ColCOL col;
326 ColCOL alt;
327 String grp;
328 double per;
329 double rng;
330 }
331
332 @SuppressWarnings("unchecked")
333 public static void lights() {
334 Enum<ColCOL> col = null;
335 Enum<ColCOL> tcol = null;
336 ObjTab lights = feature.objs.get(Obj.LIGHTS);
337 for (AttMap atts : lights.values()) {
338 if (atts.containsKey(Att.COLOUR)) {
339 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
340 if (cols.size() == 1) {
341 if (atts.containsKey(Att.CATLIT) && ((ArrayList<?>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_FLDL)) {
342 Renderer.symbol(Beacons.Floodlight, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(90))));
343 } else {
344 tcol = cols.get(0);
345 if (col == null) {
346 col = tcol;
347 } else if (tcol != col) {
348 col = ColCOL.COL_MAG;
349 break;
350 }
351 }
352 } else {
353 col = ColCOL.COL_MAG;
354 break;
355 }
356 }
357 }
358 if (col != null) {
359 Renderer.symbol(Beacons.LightFlare, new Scheme(LightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
360 }
361 String str = "";
362 if ((lights.get(1) != null) && (Renderer.zoom >= 12)) {
363 for (AttMap atts : lights.values()) {
364 Enum<ColCOL> col1 = null;
365 Enum<ColCOL> col2 = null;
366 double radius = 0.5;
367 if (atts.containsKey(Att.VALNMR)) {
368 radius += Math.log10((Double) atts.get(Att.VALNMR).val) * 2.0;
369 }
370 radius /= Math.pow(Renderer.zoom, 4) / 5000;
371 double s1 = 361;
372 double s2 = 361;
373 Double dir = null;
374 if (atts.containsKey(Att.COLOUR)) {
375 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
376 col1 = cols.get(0);
377 if (cols.size() > 1)
378 col2 = cols.get(1);
379 } else {
380 continue;
381 }
382 if (atts.containsKey(Att.CATLIT)) {
383 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
384 if (cats.contains(CatLIT.LIT_DIR)) {
385 if (atts.containsKey(Att.ORIENT)) {
386 dir = (Double) atts.get(Att.ORIENT).val;
387 s1 = ((dir - 4) + 360) % 360;
388 s2 = (dir + 4) % 360;
389 for (AttMap satts : lights.values()) {
390 double ss1 = 361;
391 double ss2 = 361;
392 Double sdir = null;
393 if (satts == atts)
394 continue;
395 ArrayList<CatLIT> scats = (ArrayList<CatLIT>) (satts.containsKey(Att.CATLIT) ? (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<>());
396 if (scats.contains(CatLIT.LIT_DIR)) {
397 if (satts.containsKey(Att.ORIENT)) {
398 sdir = (Double) satts.get(Att.ORIENT).val;
399 ss1 = sdir;
400 ss2 = sdir;
401 }
402 } else {
403 if (satts.containsKey(Att.SECTR1)) {
404 ss1 = (Double) satts.get(Att.SECTR1).val;
405 }
406 if (satts.containsKey(Att.SECTR2)) {
407 ss2 = (Double) satts.get(Att.SECTR2).val;
408 }
409 }
410 if ((ss1 > 360) || (ss2 > 360))
411 continue;
412 if (sdir != null) {
413 if (((dir - sdir + 360) % 360) < 8) {
414 s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360;
415 }
416 if (((sdir - dir + 360) % 360) < 8) {
417 s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360;
418 }
419 } else {
420 if (((dir - ss2 + 360) % 360) < 4) {
421 s1 = ss2;
422 }
423 if (((ss1 - dir + 360) % 360) < 4) {
424 s2 = ss1;
425 }
426 }
427 }
428 }
429 }
430 }
431 if ((s1 > 360) && atts.containsKey(Att.SECTR1)) {
432 s1 = (Double) atts.get(Att.SECTR1).val;
433 } else if (dir == null) {
434 continue;
435 }
436 if ((s2 > 360) && atts.containsKey(Att.SECTR2)) {
437 s2 = (Double) atts.get(Att.SECTR2).val;
438 } else if (dir == null) {
439 continue;
440 }
441 str = "";
442 if (atts.containsKey(Att.LITCHR)) {
443 str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
444 }
445 if (atts.containsKey(Att.SIGGRP)) {
446 str += "(" + atts.get(Att.SIGGRP).val + ")";
447 } else if (!str.isEmpty()) {
448 str += ".";
449 }
450 if (atts.containsKey(Att.COLOUR)) {
451 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
452 str += LightLetters.get(cols.get(0));
453 if (cols.size() > 1)
454 str += LightLetters.get(cols.get(1));
455 }
456 if (atts.containsKey(Att.SIGPER)) {
457 str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
458 }
459 if ((s1 <= 360) && (s2 <= 360) && (s1 != s2))
460 Renderer.lightSector(LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : "");
461 }
462 if (Renderer.zoom >= 15) {
463 class LitSect {
464 boolean dir;
465 LitCHR chr;
466 ColCOL col;
467 String grp;
468 double per;
469 double rng;
470 double hgt;
471 }
472
473 ArrayList<LitSect> litatts = new ArrayList<>();
474 for (AttMap atts : lights.values()) {
475 LitSect sect = new LitSect();
476 sect.dir = (atts.containsKey(Att.CATLIT) && ((ArrayList<CatLIT>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR));
477 sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
478 switch (sect.chr) {
479 case CHR_AL:
480 sect.chr = LitCHR.CHR_F;
481 break;
482 case CHR_ALOC:
483 sect.chr = LitCHR.CHR_OC;
484 break;
485 case CHR_ALLFL:
486 sect.chr = LitCHR.CHR_LFL;
487 break;
488 case CHR_ALFL:
489 sect.chr = LitCHR.CHR_FL;
490 break;
491 case CHR_ALFFL:
492 sect.chr = LitCHR.CHR_FFL;
493 break;
494 default:
495 break;
496 }
497 sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
498 sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
499 sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
500 sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
501 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
502 sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
503 if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
504 litatts.add(sect);
505 }
506 ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
507 for (LitSect lit : litatts) {
508 boolean found = false;
509 for (ArrayList<LitSect> group : groupings) {
510 LitSect mem = group.get(0);
511 if (lit.dir == mem.dir && lit.chr == mem.chr && lit.grp.equals(mem.grp) && lit.per == mem.per && lit.hgt == mem.hgt) {
512 group.add(lit);
513 found = true;
514 }
515 }
516 if (!found) {
517 ArrayList<LitSect> tmp = new ArrayList<>();
518 tmp.add(lit);
519 groupings.add(tmp);
520 }
521 }
522 for (boolean moved = true; moved;) {
523 moved = false;
524 for (int i = 0; i < groupings.size() - 1; i++) {
525 if (groupings.get(i).size() < groupings.get(i + 1).size()) {
526 ArrayList<LitSect> tmp = groupings.remove(i);
527 groupings.add(i + 1, tmp);
528 moved = true;
529 }
530 }
531 }
532 class ColRng {
533 ColCOL col;
534 double rng;
535
536 ColRng(ColCOL c, double r) {
537 col = c;
538 rng = r;
539 }
540 }
541
542 int y = -30;
543 for (ArrayList<LitSect> group : groupings) {
544 ArrayList<ColRng> colrng = new ArrayList<>();
545 for (LitSect lit : group) {
546 boolean found = false;
547 for (ColRng cr : colrng) {
548 if (cr.col == lit.col) {
549 if (lit.rng > cr.rng) {
550 cr.rng = lit.rng;
551 }
552 found = true;
553 }
554 }
555 if (!found) {
556 colrng.add(new ColRng(lit.col, lit.rng));
557 }
558 }
559 for (boolean moved = true; moved;) {
560 moved = false;
561 for (int i = 0; i < colrng.size() - 1; i++) {
562 if (colrng.get(i).rng < colrng.get(i + 1).rng) {
563 ColRng tmp = colrng.remove(i);
564 colrng.add(i + 1, tmp);
565 moved = true;
566 }
567 }
568 }
569 LitSect tmp = group.get(0);
570 str = tmp.dir ? "Dir" : "";
571 str += LightCharacters.get(tmp.chr);
572 if (!tmp.grp.isEmpty())
573 str += "(" + tmp.grp + ")";
574 else
575 str += ".";
576 for (ColRng cr : colrng) {
577 str += LightLetters.get(cr.col);
578 }
579 if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
580 str += ".";
581 if (tmp.per > 0)
582 str += df.format(tmp.per) + "s";
583 if (tmp.hgt > 0)
584 str += df.format(tmp.hgt) + "m";
585 if (colrng.get(0).rng > 0)
586 str += df.format(colrng.get(0).rng) + ((colrng.size() > 1) ? ((colrng.size() > 2) ? ("-" + df.format(colrng.get(colrng.size() - 1).rng)) : ("/" + df.format(colrng.get(1).rng))) : "") + "M";
587 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
588 y += 40;
589 str = "";
590 }
591 }
592 } else {
593 if (Renderer.zoom >= 15) {
594 AttMap atts = lights.get(0);
595 ArrayList<CatLIT> cats = new ArrayList<>();
596 if (atts.containsKey(Att.CATLIT)) {
597 cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
598 }
599 str = cats.contains(CatLIT.LIT_DIR) ? "Dir" : "";
600 str += atts.containsKey(Att.MLTYLT) ? atts.get(Att.MLTYLT).val : "";
601 if (atts.containsKey(Att.LITCHR)) {
602 LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
603 if (atts.containsKey(Att.SIGGRP)) {
604 String grp = (String) atts.get(Att.SIGGRP).val;
605 switch (chr) {
606 case CHR_QLFL:
607 str += String.format("Q(%s)+LFl", grp);
608 break;
609 case CHR_VQLFL:
610 str += String.format("VQ(%s)+LFl", grp);
611 break;
612 case CHR_UQLFL:
613 str += String.format("UQ(%s)+LFl", grp);
614 break;
615 default:
616 str += String.format("%s(%s)", LightCharacters.get(chr), grp);
617 break;
618 }
619 } else {
620 str += LightCharacters.get(chr);
621 }
622 }
623 if (atts.containsKey(Att.COLOUR)) {
624 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
625 if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
626 if (!str.isEmpty() && !str.endsWith(")")) {
627 str += ".";
628 }
629 for (ColCOL acol : cols) {
630 str += LightLetters.get(acol);
631 }
632 }
633 }
634 str += cats.contains(CatLIT.LIT_VERT) ? "(vert)" : "";
635 str += cats.contains(CatLIT.LIT_HORI) ? "(hor)" : "";
636 str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
637 str += atts.containsKey(Att.SIGPER) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
638 str += atts.containsKey(Att.HEIGHT) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
639 str += atts.containsKey(Att.VALNMR) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
640 str += cats.contains(CatLIT.LIT_FRNT) ? "(Front)" : "";
641 str += cats.contains(CatLIT.LIT_REAR) ? "(Rear)" : "";
642 str += cats.contains(CatLIT.LIT_UPPR) ? "(Upper)" : "";
643 str += cats.contains(CatLIT.LIT_LOWR) ? "(Lower)" : "";
644 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
645 }
646 }
647 }
648}
Note: See TracBrowser for help on using the repository browser.