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

Last change on this file since 35483 was 35483, checked in by malcolmh, 4 years ago

[Seachart] Publish new release

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