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