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

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

[Seachart] Publish new release

File size: 25.5 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 switch (cat) {
211 case RTB_RAMK:
212 bstr += " Ramark";
213 break;
214 case RTB_RACN:
215 bstr += " Racon";
216 String astr = getAttStr(Obj.RTPBCN, Att.SIGGRP);
217 if (!astr.isEmpty()) {
218 bstr += "(" + astr + ")";
219 }
220 Double per = (Double) getAttVal(Obj.RTPBCN, Att.SIGPER);
221 Double mxr = (Double) getAttVal(Obj.RTPBCN, Att.VALMXR);
222 if ((per != null) || (mxr != null)) {
223 bstr += (astr.isEmpty() ? " " : "");
224 if (per != null)
225 bstr += (per != 0) ? per.toString() + "s" : "";
226 if (mxr != null)
227 bstr += (mxr != 0) ? mxr.toString() + "M" : "";
228 }
229 break;
230 default:
231 break;
232 }
233 if (!wal.isEmpty()) {
234 switch (wal) {
235 case "0.03-X":
236 bstr += "(3cm)";
237 break;
238 case "0.10-S":
239 bstr += "(10cm)";
240 break;
241 }
242 }
243 if (!bstr.isEmpty()) {
244 Renderer.labelText(bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
245 }
246 }
247 }
248
249 @SuppressWarnings("unchecked")
250 public static void radioStations() {
251 String bstr = "";
252 if (Renderer.zoom >= 11) {
253 ArrayList<CatROS> cats = (ArrayList<CatROS>) getAttList(Obj.RDOSTA, Att.CATROS);
254 for (CatROS ros : cats) {
255 switch (ros) {
256 case ROS_OMNI:
257 bstr += " RC";
258 break;
259 case ROS_DIRL:
260 bstr += " RD";
261 break;
262 case ROS_ROTP:
263 bstr += " RW";
264 break;
265 case ROS_CNSL:
266 bstr += " Consol";
267 break;
268 case ROS_RDF:
269 bstr += " RG";
270 break;
271 case ROS_QTA:
272 bstr += " R";
273 break;
274 case ROS_AERO:
275 bstr += " AeroRC";
276 break;
277 case ROS_DECA:
278 bstr += " Decca";
279 break;
280 case ROS_LORN:
281 bstr += " Loran";
282 break;
283 case ROS_DGPS:
284 bstr += " DGPS";
285 break;
286 case ROS_TORN:
287 bstr += " Toran";
288 break;
289 case ROS_OMGA:
290 bstr += " Omega";
291 break;
292 case ROS_SYLD:
293 bstr += " Syledis";
294 break;
295 case ROS_CHKA:
296 bstr += " Chiaka";
297 break;
298 case ROS_PCOM:
299 case ROS_COMB:
300 case ROS_FACS:
301 case ROS_TIME:
302 break;
303 case ROS_AISB:
304 case ROS_PAIS:
305 bstr += " AIS";
306 break;
307 default:
308 break;
309 }
310 }
311 Renderer.symbol(Beacons.RadarStation);
312 }
313 if (Renderer.zoom >= 15) {
314 if (!bstr.isEmpty()) {
315 Renderer.labelText(bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110)));
316 }
317 }
318 }
319
320 static class Sect {
321 int dir;
322 LitCHR chr;
323 ColCOL col;
324 ColCOL alt;
325 String grp;
326 double per;
327 double rng;
328 }
329
330 @SuppressWarnings("unchecked")
331 public static void lights() {
332 Enum<ColCOL> col = null;
333 Enum<ColCOL> tcol = null;
334 ObjTab lights = feature.objs.get(Obj.LIGHTS);
335 for (AttMap atts : lights.values()) {
336 if (atts.containsKey(Att.COLOUR)) {
337 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
338 if (cols.size() == 1) {
339 if (atts.containsKey(Att.CATLIT) && ((ArrayList<?>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_FLDL)) {
340 Renderer.symbol(Beacons.Floodlight, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(90))));
341 } else {
342 tcol = cols.get(0);
343 if (col == null) {
344 col = tcol;
345 } else if (tcol != col) {
346 col = ColCOL.COL_MAG;
347 break;
348 }
349 }
350 } else {
351 col = ColCOL.COL_MAG;
352 break;
353 }
354 }
355 }
356 if (col != null) {
357 Renderer.symbol(Beacons.LightFlare, new Scheme(LightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
358 }
359 String str = "";
360 if (lights.get(1) != null) {
361 for (AttMap atts : lights.values()) {
362 Enum<ColCOL> col1 = null;
363 Enum<ColCOL> col2 = null;
364 double radius = 0.5;
365 if (atts.containsKey(Att.VALNMR)) {
366 radius += Math.log10((Double) atts.get(Att.VALNMR).val) * 2.0;
367 }
368 radius /= Math.pow(Renderer.zoom, 4) / 5000;
369 double s1 = 361;
370 double s2 = 361;
371 Double dir = null;
372 if (atts.containsKey(Att.COLOUR)) {
373 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
374 col1 = cols.get(0);
375 if (cols.size() > 1)
376 col2 = cols.get(1);
377 } else {
378 continue;
379 }
380 if (atts.containsKey(Att.CATLIT)) {
381 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
382 if (cats.contains(CatLIT.LIT_DIR)) {
383 if (atts.containsKey(Att.ORIENT)) {
384 dir = (Double) atts.get(Att.ORIENT).val;
385 s1 = ((dir - 4) + 360) % 360;
386 s2 = (dir + 4) % 360;
387 for (AttMap satts : lights.values()) {
388 double ss1 = 361;
389 double ss2 = 361;
390 Double sdir = null;
391 if (satts == atts)
392 continue;
393 ArrayList<CatLIT> scats = (ArrayList<CatLIT>) (satts.containsKey(Att.CATLIT) ? (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<>());
394 if (scats.contains(CatLIT.LIT_DIR)) {
395 if (satts.containsKey(Att.ORIENT)) {
396 sdir = (Double) satts.get(Att.ORIENT).val;
397 ss1 = sdir;
398 ss2 = sdir;
399 }
400 } else {
401 if (satts.containsKey(Att.SECTR1)) {
402 ss1 = (Double) satts.get(Att.SECTR1).val;
403 }
404 if (satts.containsKey(Att.SECTR2)) {
405 ss2 = (Double) satts.get(Att.SECTR2).val;
406 }
407 }
408 if ((ss1 > 360) || (ss2 > 360))
409 continue;
410 if (sdir != null) {
411 if (((dir - sdir + 360) % 360) < 8) {
412 s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360;
413 }
414 if (((sdir - dir + 360) % 360) < 8) {
415 s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360;
416 }
417 } else {
418 if (((dir - ss2 + 360) % 360) < 4) {
419 s1 = ss2;
420 }
421 if (((ss1 - dir + 360) % 360) < 4) {
422 s2 = ss1;
423 }
424 }
425 }
426 }
427 }
428 }
429 if ((s1 > 360) && atts.containsKey(Att.SECTR1)) {
430 s1 = (Double) atts.get(Att.SECTR1).val;
431 } else if (dir == null) {
432 continue;
433 }
434 if ((s2 > 360) && atts.containsKey(Att.SECTR2)) {
435 s2 = (Double) atts.get(Att.SECTR2).val;
436 } else if (dir == null) {
437 continue;
438 }
439 str = "";
440 if (atts.containsKey(Att.LITCHR)) {
441 str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
442 }
443 if (atts.containsKey(Att.SIGGRP)) {
444 str += "(" + atts.get(Att.SIGGRP).val + ")";
445 } else if (!str.isEmpty()) {
446 str += ".";
447 }
448 if (atts.containsKey(Att.COLOUR)) {
449 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
450 str += LightLetters.get(cols.get(0));
451 if (cols.size() > 1)
452 str += LightLetters.get(cols.get(1));
453 }
454 if (atts.containsKey(Att.SIGPER)) {
455 str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
456 }
457 if ((s1 <= 360) && (s2 <= 360) && (s1 != s2))
458 Renderer.lightSector(LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : "");
459 }
460 if (Renderer.zoom >= 15) {
461 class LitSect {
462 boolean dir;
463 LitCHR chr;
464 ColCOL col;
465 String grp;
466 double per;
467 double rng;
468 double hgt;
469 }
470
471 ArrayList<LitSect> litatts = new ArrayList<>();
472 for (AttMap atts : lights.values()) {
473 LitSect sect = new LitSect();
474 sect.dir = (atts.containsKey(Att.CATLIT) && ((ArrayList<CatLIT>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR));
475 sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
476 switch (sect.chr) {
477 case CHR_AL:
478 sect.chr = LitCHR.CHR_F;
479 break;
480 case CHR_ALOC:
481 sect.chr = LitCHR.CHR_OC;
482 break;
483 case CHR_ALLFL:
484 sect.chr = LitCHR.CHR_LFL;
485 break;
486 case CHR_ALFL:
487 sect.chr = LitCHR.CHR_FL;
488 break;
489 case CHR_ALFFL:
490 sect.chr = LitCHR.CHR_FFL;
491 break;
492 default:
493 break;
494 }
495 sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
496 sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
497 sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
498 sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
499 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
500 sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
501 if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
502 litatts.add(sect);
503 }
504 ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
505 for (LitSect lit : litatts) {
506 boolean found = false;
507 for (ArrayList<LitSect> group : groupings) {
508 LitSect mem = group.get(0);
509 if (lit.dir == mem.dir && lit.chr == mem.chr && lit.grp.equals(mem.grp) && lit.per == mem.per && lit.hgt == mem.hgt) {
510 group.add(lit);
511 found = true;
512 }
513 }
514 if (!found) {
515 ArrayList<LitSect> tmp = new ArrayList<>();
516 tmp.add(lit);
517 groupings.add(tmp);
518 }
519 }
520 for (boolean moved = true; moved;) {
521 moved = false;
522 for (int i = 0; i < groupings.size() - 1; i++) {
523 if (groupings.get(i).size() < groupings.get(i + 1).size()) {
524 ArrayList<LitSect> tmp = groupings.remove(i);
525 groupings.add(i + 1, tmp);
526 moved = true;
527 }
528 }
529 }
530 class ColRng {
531 ColCOL col;
532 double rng;
533
534 ColRng(ColCOL c, double r) {
535 col = c;
536 rng = r;
537 }
538 }
539
540 int y = -30;
541 for (ArrayList<LitSect> group : groupings) {
542 ArrayList<ColRng> colrng = new ArrayList<>();
543 for (LitSect lit : group) {
544 boolean found = false;
545 for (ColRng cr : colrng) {
546 if (cr.col == lit.col) {
547 if (lit.rng > cr.rng) {
548 cr.rng = lit.rng;
549 }
550 found = true;
551 }
552 }
553 if (!found) {
554 colrng.add(new ColRng(lit.col, lit.rng));
555 }
556 }
557 for (boolean moved = true; moved;) {
558 moved = false;
559 for (int i = 0; i < colrng.size() - 1; i++) {
560 if (colrng.get(i).rng < colrng.get(i + 1).rng) {
561 ColRng tmp = colrng.remove(i);
562 colrng.add(i + 1, tmp);
563 moved = true;
564 }
565 }
566 }
567 LitSect tmp = group.get(0);
568 str = tmp.dir ? "Dir" : "";
569 str += LightCharacters.get(tmp.chr);
570 if (!tmp.grp.isEmpty())
571 str += "(" + tmp.grp + ")";
572 else
573 str += ".";
574 for (ColRng cr : colrng) {
575 str += LightLetters.get(cr.col);
576 }
577 if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
578 str += ".";
579 if (tmp.per > 0)
580 str += df.format(tmp.per) + "s";
581 if (tmp.hgt > 0)
582 str += df.format(tmp.hgt) + "m";
583 if (colrng.get(0).rng > 0)
584 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";
585 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
586 y += 40;
587 str = "";
588 }
589 }
590 } else {
591 if (Renderer.zoom >= 15) {
592 AttMap atts = lights.get(0);
593 ArrayList<CatLIT> cats = new ArrayList<>();
594 if (atts.containsKey(Att.CATLIT)) {
595 cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
596 }
597 str = cats.contains(CatLIT.LIT_DIR) ? "Dir" : "";
598 str += atts.containsKey(Att.MLTYLT) ? atts.get(Att.MLTYLT).val : "";
599 if (atts.containsKey(Att.LITCHR)) {
600 LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
601 if (atts.containsKey(Att.SIGGRP)) {
602 String grp = (String) atts.get(Att.SIGGRP).val;
603 switch (chr) {
604 case CHR_QLFL:
605 str += String.format("Q(%s)+LFl", grp);
606 break;
607 case CHR_VQLFL:
608 str += String.format("VQ(%s)+LFl", grp);
609 break;
610 case CHR_UQLFL:
611 str += String.format("UQ(%s)+LFl", grp);
612 break;
613 default:
614 str += String.format("%s(%s)", LightCharacters.get(chr), grp);
615 break;
616 }
617 } else {
618 str += LightCharacters.get(chr);
619 }
620 }
621 if (atts.containsKey(Att.COLOUR)) {
622 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
623 if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
624 if (!str.isEmpty() && !str.endsWith(")")) {
625 str += ".";
626 }
627 for (ColCOL acol : cols) {
628 str += LightLetters.get(acol);
629 }
630 }
631 }
632 str += cats.contains(CatLIT.LIT_VERT) ? "(vert)" : "";
633 str += cats.contains(CatLIT.LIT_HORI) ? "(hor)" : "";
634 str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
635 str += atts.containsKey(Att.SIGPER) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
636 str += atts.containsKey(Att.HEIGHT) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
637 str += atts.containsKey(Att.VALNMR) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
638 str += cats.contains(CatLIT.LIT_FRNT) ? "(Front)" : "";
639 str += cats.contains(CatLIT.LIT_REAR) ? "(Rear)" : "";
640 str += cats.contains(CatLIT.LIT_UPPR) ? "(Upper)" : "";
641 str += cats.contains(CatLIT.LIT_LOWR) ? "(Lower)" : "";
642 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
643 }
644 }
645 }
646}
Note: See TracBrowser for help on using the repository browser.