[32907] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[30894] | 2 | package render;
|
---|
| 3 |
|
---|
| 4 | import java.awt.Color;
|
---|
| 5 | import java.awt.Font;
|
---|
[32394] | 6 | import java.awt.geom.AffineTransform;
|
---|
[32082] | 7 | import java.text.DecimalFormat;
|
---|
[30894] | 8 | import java.util.ArrayList;
|
---|
| 9 | import java.util.EnumMap;
|
---|
| 10 |
|
---|
[32394] | 11 | import s57.S57att.Att;
|
---|
| 12 | import s57.S57map.AttMap;
|
---|
| 13 | import s57.S57map.ObjTab;
|
---|
| 14 | import s57.S57obj.Obj;
|
---|
| 15 | import s57.S57val.BoySHP;
|
---|
| 16 | import s57.S57val.CatFOG;
|
---|
[32082] | 17 | import s57.S57val.CatLIT;
|
---|
[32394] | 18 | import s57.S57val.CatROS;
|
---|
| 19 | import s57.S57val.CatRTB;
|
---|
[35114] | 20 | import s57.S57val.CatRAS;
|
---|
[32082] | 21 | import s57.S57val.ColCOL;
|
---|
[32394] | 22 | import s57.S57val.LitCHR;
|
---|
[30894] | 23 | import symbols.Beacons;
|
---|
[31044] | 24 | import symbols.Symbols;
|
---|
[32394] | 25 | import symbols.Symbols.Delta;
|
---|
| 26 | import symbols.Symbols.Handle;
|
---|
| 27 | import symbols.Symbols.Scheme;
|
---|
[30894] | 28 | import symbols.Topmarks;
|
---|
| 29 |
|
---|
[32907] | 30 | /**
|
---|
| 31 | * @author Malcolm Herring
|
---|
| 32 | */
|
---|
[32394] | 33 | public class Signals extends Rules {
|
---|
[30894] | 34 |
|
---|
[33995] | 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 | }
|
---|
[30894] | 47 |
|
---|
[33995] | 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 | }
|
---|
[30894] | 59 |
|
---|
[33995] | 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 | }
|
---|
[30894] | 88 |
|
---|
[33995] | 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 | }
|
---|
[30894] | 102 |
|
---|
[33995] | 103 | static final DecimalFormat df = new DecimalFormat("#.#");
|
---|
[32090] | 104 |
|
---|
[33995] | 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))
|
---|
[35114] | 111 | radarTransponders();
|
---|
[33995] | 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 | }
|
---|
[30894] | 119 |
|
---|
[33995] | 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:
|
---|
[34652] | 128 | if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
|
---|
[33995] | 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:
|
---|
[34652] | 137 | if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
|
---|
[33995] | 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:
|
---|
[34652] | 145 | if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
|
---|
[33995] | 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:
|
---|
[34652] | 156 | if (feature.objs.containsKey(Obj.TOPMAR) || feature.objs.containsKey(Obj.DAYMAR)) {
|
---|
[33995] | 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 | }
|
---|
[30894] | 175 |
|
---|
[33995] | 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)) {
|
---|
[34652] | 184 | str += fogSignals.get(((ArrayList<?>) atts.get(Att.CATFOG).val).get(0));
|
---|
[33995] | 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 | }
|
---|
[32095] | 203 |
|
---|
[35114] | 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);
|
---|
[35086] | 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 | }
|
---|
[35114] | 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 | }
|
---|
[32394] | 262 |
|
---|
[33995] | 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;
|
---|
[34906] | 317 | case ROS_AISB:
|
---|
| 318 | case ROS_PAIS:
|
---|
[33995] | 319 | bstr += " AIS";
|
---|
| 320 | break;
|
---|
| 321 | default:
|
---|
| 322 | break;
|
---|
| 323 | }
|
---|
| 324 | }
|
---|
[34906] | 325 | Renderer.symbol(Beacons.RadarStation);
|
---|
[33995] | 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 | }
|
---|
[32394] | 333 |
|
---|
[33995] | 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 | }
|
---|
[32394] | 343 |
|
---|
[34896] | 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);
|
---|
[35687] | 349 | if (lights != null) {
|
---|
| 350 | for (AttMap atts : lights.values()) {
|
---|
| 351 | if (atts.containsKey(Att.COLOUR)) {
|
---|
| 352 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
---|
| 353 | if (cols.size() == 1) {
|
---|
| 354 | if (atts.containsKey(Att.CATLIT)
|
---|
| 355 | && ((ArrayList<?>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_FLDL)) {
|
---|
| 356 | Renderer.symbol(Beacons.Floodlight,
|
---|
| 357 | new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(90))));
|
---|
| 358 | } else {
|
---|
| 359 | tcol = cols.get(0);
|
---|
| 360 | if (col == null) {
|
---|
| 361 | col = tcol;
|
---|
| 362 | } else if (tcol != col) {
|
---|
| 363 | col = ColCOL.COL_MAG;
|
---|
| 364 | break;
|
---|
| 365 | }
|
---|
| 366 | }
|
---|
| 367 | } else {
|
---|
| 368 | col = ColCOL.COL_MAG;
|
---|
| 369 | break;
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
| 373 | if (col != null) {
|
---|
| 374 | Renderer.symbol(Beacons.LightFlare, new Scheme(LightColours.get(col)),
|
---|
| 375 | new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
|
---|
| 376 | }
|
---|
| 377 | String str = "";
|
---|
| 378 | if ((lights.get(1) != null) && (Renderer.zoom >= 12)) {
|
---|
| 379 | for (AttMap atts : lights.values()) {
|
---|
| 380 | Enum<ColCOL> col1 = null;
|
---|
| 381 | Enum<ColCOL> col2 = null;
|
---|
| 382 | double radius = 0.5;
|
---|
| 383 | if (atts.containsKey(Att.VALNMR)) {
|
---|
| 384 | radius += Math.log10((Double) atts.get(Att.VALNMR).val) * 2.0;
|
---|
| 385 | }
|
---|
| 386 | radius /= Math.pow(Renderer.zoom, 4) / 5000;
|
---|
| 387 | double s1 = 361;
|
---|
| 388 | double s2 = 361;
|
---|
| 389 | Double dir = null;
|
---|
| 390 | if (atts.containsKey(Att.COLOUR)) {
|
---|
| 391 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
---|
| 392 | col1 = cols.get(0);
|
---|
| 393 | if (cols.size() > 1)
|
---|
| 394 | col2 = cols.get(1);
|
---|
| 395 | } else {
|
---|
| 396 | continue;
|
---|
| 397 | }
|
---|
| 398 | if (atts.containsKey(Att.CATLIT)) {
|
---|
| 399 | ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
|
---|
| 400 | if (cats.contains(CatLIT.LIT_DIR)) {
|
---|
| 401 | if (atts.containsKey(Att.ORIENT)) {
|
---|
| 402 | dir = (Double) atts.get(Att.ORIENT).val;
|
---|
| 403 | s1 = ((dir - 4) + 360) % 360;
|
---|
| 404 | s2 = (dir + 4) % 360;
|
---|
| 405 | for (AttMap satts : lights.values()) {
|
---|
| 406 | double ss1 = 361;
|
---|
| 407 | double ss2 = 361;
|
---|
| 408 | Double sdir = null;
|
---|
| 409 | if (satts == atts)
|
---|
| 410 | continue;
|
---|
| 411 | ArrayList<CatLIT> scats = (ArrayList<CatLIT>) (satts.containsKey(Att.CATLIT)
|
---|
| 412 | ? (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<>());
|
---|
| 413 | if (scats.contains(CatLIT.LIT_DIR)) {
|
---|
| 414 | if (satts.containsKey(Att.ORIENT)) {
|
---|
| 415 | sdir = (Double) satts.get(Att.ORIENT).val;
|
---|
| 416 | ss1 = sdir;
|
---|
| 417 | ss2 = sdir;
|
---|
| 418 | }
|
---|
| 419 | } else {
|
---|
| 420 | if (satts.containsKey(Att.SECTR1)) {
|
---|
| 421 | ss1 = (Double) satts.get(Att.SECTR1).val;
|
---|
| 422 | }
|
---|
| 423 | if (satts.containsKey(Att.SECTR2)) {
|
---|
| 424 | ss2 = (Double) satts.get(Att.SECTR2).val;
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
| 427 | if ((ss1 > 360) || (ss2 > 360))
|
---|
| 428 | continue;
|
---|
| 429 | if (sdir != null) {
|
---|
| 430 | if (((dir - sdir + 360) % 360) < 8) {
|
---|
| 431 | s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360;
|
---|
| 432 | }
|
---|
| 433 | if (((sdir - dir + 360) % 360) < 8) {
|
---|
| 434 | s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360;
|
---|
| 435 | }
|
---|
| 436 | } else {
|
---|
| 437 | if (((dir - ss2 + 360) % 360) < 4) {
|
---|
| 438 | s1 = ss2;
|
---|
| 439 | }
|
---|
| 440 | if (((ss1 - dir + 360) % 360) < 4) {
|
---|
| 441 | s2 = ss1;
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 | if ((s1 > 360) && atts.containsKey(Att.SECTR1)) {
|
---|
| 449 | s1 = (Double) atts.get(Att.SECTR1).val;
|
---|
| 450 | } else if (dir == null) {
|
---|
| 451 | continue;
|
---|
| 452 | }
|
---|
| 453 | if ((s2 > 360) && atts.containsKey(Att.SECTR2)) {
|
---|
| 454 | s2 = (Double) atts.get(Att.SECTR2).val;
|
---|
| 455 | } else if (dir == null) {
|
---|
| 456 | continue;
|
---|
| 457 | }
|
---|
| 458 | str = "";
|
---|
| 459 | if (atts.containsKey(Att.LITCHR)) {
|
---|
| 460 | str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
|
---|
| 461 | }
|
---|
| 462 | if (atts.containsKey(Att.SIGGRP)) {
|
---|
| 463 | str += "(" + atts.get(Att.SIGGRP).val + ")";
|
---|
| 464 | } else if (!str.isEmpty()) {
|
---|
| 465 | str += ".";
|
---|
| 466 | }
|
---|
| 467 | if (atts.containsKey(Att.COLOUR)) {
|
---|
| 468 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
---|
| 469 | str += LightLetters.get(cols.get(0));
|
---|
| 470 | if (cols.size() > 1)
|
---|
| 471 | str += LightLetters.get(cols.get(1));
|
---|
| 472 | }
|
---|
| 473 | if (atts.containsKey(Att.SIGPER)) {
|
---|
| 474 | str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
|
---|
| 475 | }
|
---|
| 476 | if ((s1 < 360) && (s2 < 360) && (s1 != s2))
|
---|
| 477 | Renderer.lightSector(LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir,
|
---|
| 478 | (Renderer.zoom >= 15) ? str : "");
|
---|
| 479 | }
|
---|
| 480 | if (Renderer.zoom >= 15) {
|
---|
| 481 | class LitSect {
|
---|
| 482 | boolean dir;
|
---|
| 483 | LitCHR chr;
|
---|
| 484 | ColCOL col;
|
---|
| 485 | String grp;
|
---|
| 486 | double per;
|
---|
| 487 | double rng;
|
---|
| 488 | double hgt;
|
---|
| 489 | }
|
---|
[32394] | 490 |
|
---|
[35687] | 491 | ArrayList<LitSect> litatts = new ArrayList<>();
|
---|
| 492 | for (AttMap atts : lights.values()) {
|
---|
| 493 | LitSect sect = new LitSect();
|
---|
| 494 | sect.dir = (atts.containsKey(Att.CATLIT)
|
---|
| 495 | && ((ArrayList<CatLIT>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR));
|
---|
| 496 | sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0)
|
---|
| 497 | : LitCHR.CHR_UNKN;
|
---|
| 498 | switch (sect.chr) {
|
---|
| 499 | case CHR_AL:
|
---|
| 500 | sect.chr = LitCHR.CHR_F;
|
---|
| 501 | break;
|
---|
| 502 | case CHR_ALOC:
|
---|
| 503 | sect.chr = LitCHR.CHR_OC;
|
---|
| 504 | break;
|
---|
| 505 | case CHR_ALLFL:
|
---|
| 506 | sect.chr = LitCHR.CHR_LFL;
|
---|
| 507 | break;
|
---|
| 508 | case CHR_ALFL:
|
---|
| 509 | sect.chr = LitCHR.CHR_FL;
|
---|
| 510 | break;
|
---|
| 511 | case CHR_ALFFL:
|
---|
| 512 | sect.chr = LitCHR.CHR_FFL;
|
---|
| 513 | break;
|
---|
| 514 | default:
|
---|
| 515 | break;
|
---|
| 516 | }
|
---|
| 517 | sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
|
---|
| 518 | sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
|
---|
| 519 | sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
|
---|
| 520 | sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
|
---|
| 521 | ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR)
|
---|
| 522 | ? atts.get(Att.COLOUR).val : new ArrayList<>());
|
---|
| 523 | sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
|
---|
| 524 | if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
|
---|
| 525 | litatts.add(sect);
|
---|
| 526 | }
|
---|
| 527 | ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
|
---|
| 528 | for (LitSect lit : litatts) {
|
---|
| 529 | boolean found = false;
|
---|
| 530 | for (ArrayList<LitSect> group : groupings) {
|
---|
| 531 | LitSect mem = group.get(0);
|
---|
| 532 | if (lit.dir == mem.dir && lit.chr == mem.chr && lit.grp.equals(mem.grp)
|
---|
| 533 | && lit.per == mem.per && lit.hgt == mem.hgt) {
|
---|
| 534 | group.add(lit);
|
---|
| 535 | found = true;
|
---|
| 536 | }
|
---|
| 537 | }
|
---|
| 538 | if (!found) {
|
---|
| 539 | ArrayList<LitSect> tmp = new ArrayList<>();
|
---|
| 540 | tmp.add(lit);
|
---|
| 541 | groupings.add(tmp);
|
---|
| 542 | }
|
---|
| 543 | }
|
---|
| 544 | for (boolean moved = true; moved;) {
|
---|
| 545 | moved = false;
|
---|
| 546 | for (int i = 0; i < groupings.size() - 1; i++) {
|
---|
| 547 | if (groupings.get(i).size() < groupings.get(i + 1).size()) {
|
---|
| 548 | ArrayList<LitSect> tmp = groupings.remove(i);
|
---|
| 549 | groupings.add(i + 1, tmp);
|
---|
| 550 | moved = true;
|
---|
| 551 | }
|
---|
| 552 | }
|
---|
| 553 | }
|
---|
| 554 | class ColRng {
|
---|
| 555 | ColCOL col;
|
---|
| 556 | double rng;
|
---|
[32394] | 557 |
|
---|
[35687] | 558 | ColRng(ColCOL c, double r) {
|
---|
| 559 | col = c;
|
---|
| 560 | rng = r;
|
---|
| 561 | }
|
---|
| 562 | }
|
---|
[32394] | 563 |
|
---|
[35687] | 564 | int y = -30;
|
---|
| 565 | for (ArrayList<LitSect> group : groupings) {
|
---|
| 566 | ArrayList<ColRng> colrng = new ArrayList<>();
|
---|
| 567 | for (LitSect lit : group) {
|
---|
| 568 | boolean found = false;
|
---|
| 569 | for (ColRng cr : colrng) {
|
---|
| 570 | if (cr.col == lit.col) {
|
---|
| 571 | if (lit.rng > cr.rng) {
|
---|
| 572 | cr.rng = lit.rng;
|
---|
| 573 | }
|
---|
| 574 | found = true;
|
---|
| 575 | }
|
---|
| 576 | }
|
---|
| 577 | if (!found) {
|
---|
| 578 | colrng.add(new ColRng(lit.col, lit.rng));
|
---|
| 579 | }
|
---|
| 580 | }
|
---|
| 581 | for (boolean moved = true; moved;) {
|
---|
| 582 | moved = false;
|
---|
| 583 | for (int i = 0; i < colrng.size() - 1; i++) {
|
---|
| 584 | if (colrng.get(i).rng < colrng.get(i + 1).rng) {
|
---|
| 585 | ColRng tmp = colrng.remove(i);
|
---|
| 586 | colrng.add(i + 1, tmp);
|
---|
| 587 | moved = true;
|
---|
| 588 | }
|
---|
| 589 | }
|
---|
| 590 | }
|
---|
| 591 | LitSect tmp = group.get(0);
|
---|
| 592 | str = tmp.dir ? "Dir" : "";
|
---|
| 593 | str += LightCharacters.get(tmp.chr);
|
---|
| 594 | if (!tmp.grp.isEmpty())
|
---|
| 595 | str += "(" + tmp.grp + ")";
|
---|
| 596 | else
|
---|
| 597 | str += ".";
|
---|
| 598 | for (ColRng cr : colrng) {
|
---|
| 599 | str += LightLetters.get(cr.col);
|
---|
| 600 | }
|
---|
| 601 | if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
|
---|
| 602 | str += ".";
|
---|
| 603 | if (tmp.per > 0)
|
---|
| 604 | str += df.format(tmp.per) + "s";
|
---|
| 605 | if (tmp.hgt > 0)
|
---|
| 606 | str += df.format(tmp.hgt) + "m";
|
---|
| 607 | if (colrng.get(0).rng > 0)
|
---|
| 608 | str += df.format(colrng.get(0).rng) + ((colrng.size() > 1)
|
---|
| 609 | ? ((colrng.size() > 2) ? ("-" + df.format(colrng.get(colrng.size() - 1).rng))
|
---|
| 610 | : ("/" + df.format(colrng.get(1).rng)))
|
---|
| 611 | : "") + "M";
|
---|
| 612 | Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black,
|
---|
| 613 | new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
|
---|
| 614 | y += 40;
|
---|
| 615 | str = "";
|
---|
| 616 | }
|
---|
| 617 | }
|
---|
| 618 | } else {
|
---|
| 619 | if ((Renderer.zoom >= 15) && (lights.get(0) != null)) {
|
---|
| 620 | AttMap atts = lights.get(0);
|
---|
| 621 | ArrayList<CatLIT> cats = new ArrayList<>();
|
---|
| 622 | if (atts.containsKey(Att.CATLIT)) {
|
---|
| 623 | cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
|
---|
| 624 | }
|
---|
| 625 | str = (cats.contains(CatLIT.LIT_AIR) || cats.contains(CatLIT.LIT_AERO)) ? "Aero"
|
---|
| 626 | : cats.contains(CatLIT.LIT_DIR) ? "Dir" : "";
|
---|
| 627 | str += atts.containsKey(Att.MLTYLT) ? atts.get(Att.MLTYLT).val : "";
|
---|
| 628 | if (atts.containsKey(Att.LITCHR)) {
|
---|
| 629 | LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
|
---|
| 630 | if (atts.containsKey(Att.SIGGRP)) {
|
---|
| 631 | String grp = (String) atts.get(Att.SIGGRP).val;
|
---|
| 632 | switch (chr) {
|
---|
| 633 | case CHR_QLFL:
|
---|
| 634 | str += String.format("Q(%s)+LFl", grp);
|
---|
| 635 | break;
|
---|
| 636 | case CHR_VQLFL:
|
---|
| 637 | str += String.format("VQ(%s)+LFl", grp);
|
---|
| 638 | break;
|
---|
| 639 | case CHR_UQLFL:
|
---|
| 640 | str += String.format("UQ(%s)+LFl", grp);
|
---|
| 641 | break;
|
---|
| 642 | default:
|
---|
| 643 | str += String.format("%s(%s)", LightCharacters.get(chr), grp);
|
---|
| 644 | break;
|
---|
| 645 | }
|
---|
| 646 | } else {
|
---|
| 647 | str += LightCharacters.get(chr);
|
---|
| 648 | }
|
---|
| 649 | }
|
---|
| 650 | if (atts.containsKey(Att.COLOUR)) {
|
---|
| 651 | ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
|
---|
| 652 | if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
|
---|
| 653 | if (!str.isEmpty() && !str.endsWith(")")) {
|
---|
| 654 | str += ".";
|
---|
| 655 | }
|
---|
| 656 | for (ColCOL acol : cols) {
|
---|
| 657 | str += LightLetters.get(acol);
|
---|
| 658 | }
|
---|
| 659 | }
|
---|
| 660 | }
|
---|
| 661 | str += cats.contains(CatLIT.LIT_VERT) ? "(vert)" : "";
|
---|
| 662 | str += cats.contains(CatLIT.LIT_HORI) ? "(hor)" : "";
|
---|
| 663 | str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT)
|
---|
| 664 | || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
|
---|
| 665 | str += atts.containsKey(Att.SIGPER) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
|
---|
| 666 | str += atts.containsKey(Att.HEIGHT) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
|
---|
| 667 | str += atts.containsKey(Att.VALNMR) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
|
---|
| 668 | str += cats.contains(CatLIT.LIT_FRNT) ? "(Front)" : "";
|
---|
| 669 | str += cats.contains(CatLIT.LIT_REAR) ? "(Rear)" : "";
|
---|
| 670 | str += cats.contains(CatLIT.LIT_UPPR) ? "(Upper)" : "";
|
---|
| 671 | str += cats.contains(CatLIT.LIT_LOWR) ? "(Lower)" : "";
|
---|
| 672 | Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black,
|
---|
| 673 | new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
|
---|
| 674 | }
|
---|
| 675 | }
|
---|
| 676 | }
|
---|
| 677 | }
|
---|
[32394] | 678 | }
|
---|