source: osm/applications/editors/josm/plugins/seachart/src/render/Rules.java@ 33941

Last change on this file since 33941 was 33941, checked in by malcolmh, 7 years ago

new topmarks & lights

File size: 52.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.ConcurrentModificationException;
10import java.util.EnumMap;
11import java.util.HashMap;
12
13import render.ChartContext.RuleSet;
14import render.Renderer.LabelStyle;
15import s57.S57att.Att;
16import s57.S57map.AttMap;
17import s57.S57map.Feature;
18import s57.S57map.ObjTab;
19import s57.S57map.Pflag;
20import s57.S57map.Rflag;
21import s57.S57obj.Obj;
22import s57.S57val;
23import s57.S57val.AddMRK;
24import s57.S57val.AttVal;
25import s57.S57val.BcnSHP;
26import s57.S57val.BnkWTW;
27import s57.S57val.BoySHP;
28import s57.S57val.CatACH;
29import s57.S57val.CatCBL;
30import s57.S57val.CatCRN;
31import s57.S57val.CatDIS;
32import s57.S57val.CatHAF;
33import s57.S57val.CatLAM;
34import s57.S57val.CatLIT;
35import s57.S57val.CatLMK;
36import s57.S57val.CatMOR;
37import s57.S57val.CatNMK;
38import s57.S57val.CatOBS;
39import s57.S57val.CatOFP;
40import s57.S57val.CatPIL;
41import s57.S57val.CatPRA;
42import s57.S57val.CatREA;
43import s57.S57val.CatROD;
44import s57.S57val.CatSCF;
45import s57.S57val.CatSEA;
46import s57.S57val.CatSIL;
47import s57.S57val.CatSIT;
48import s57.S57val.CatSIW;
49import s57.S57val.CatSLC;
50import s57.S57val.CatWED;
51import s57.S57val.CatWRK;
52import s57.S57val.ColCOL;
53import s57.S57val.ColPAT;
54import s57.S57val.FncFNC;
55import s57.S57val.MarSYS;
56import s57.S57val.StsSTS;
57import s57.S57val.TopSHP;
58import s57.S57val.TrfTRF;
59import s57.S57val.UniHLU;
60import s57.S57val.WatLEV;
61import symbols.Areas;
62import symbols.Beacons;
63import symbols.Buoys;
64import symbols.Facilities;
65import symbols.Harbours;
66import symbols.Landmarks;
67import symbols.Notices;
68import symbols.Symbols;
69import symbols.Symbols.Delta;
70import symbols.Symbols.Handle;
71import symbols.Symbols.LineStyle;
72import symbols.Symbols.Patt;
73import symbols.Symbols.Scheme;
74import symbols.Symbols.Symbol;
75import symbols.Topmarks;
76
77/**
78 * @author Malcolm Herring
79 */
80public class Rules {
81
82 static final DecimalFormat df = new DecimalFormat("#.#");
83
84 static final EnumMap<ColCOL, Color> bodyColours = new EnumMap<>(ColCOL.class);
85 static {
86 bodyColours.put(ColCOL.COL_UNK, new Color(0, true));
87 bodyColours.put(ColCOL.COL_WHT, new Color(0xffffff));
88 bodyColours.put(ColCOL.COL_BLK, new Color(0x000000));
89 bodyColours.put(ColCOL.COL_RED, new Color(0xd40000));
90 bodyColours.put(ColCOL.COL_GRN, new Color(0x00d400));
91 bodyColours.put(ColCOL.COL_BLU, Color.blue);
92 bodyColours.put(ColCOL.COL_YEL, new Color(0xffd400));
93 bodyColours.put(ColCOL.COL_GRY, Color.gray);
94 bodyColours.put(ColCOL.COL_BRN, new Color(0x8b4513));
95 bodyColours.put(ColCOL.COL_AMB, new Color(0xfbf00f));
96 bodyColours.put(ColCOL.COL_VIO, new Color(0xee82ee));
97 bodyColours.put(ColCOL.COL_ORG, Color.orange);
98 bodyColours.put(ColCOL.COL_MAG, new Color(0xf000f0));
99 bodyColours.put(ColCOL.COL_PNK, Color.pink);
100 }
101
102 static final EnumMap<ColPAT, Patt> pattMap = new EnumMap<>(ColPAT.class);
103 static {
104 pattMap.put(ColPAT.PAT_UNKN, Patt.Z);
105 pattMap.put(ColPAT.PAT_HORI, Patt.H);
106 pattMap.put(ColPAT.PAT_VERT, Patt.V);
107 pattMap.put(ColPAT.PAT_DIAG, Patt.D);
108 pattMap.put(ColPAT.PAT_BRDR, Patt.B);
109 pattMap.put(ColPAT.PAT_SQUR, Patt.S);
110 pattMap.put(ColPAT.PAT_CROS, Patt.C);
111 pattMap.put(ColPAT.PAT_SALT, Patt.X);
112 pattMap.put(ColPAT.PAT_STRP, Patt.H);
113 }
114
115 static String getName() {
116 AttVal<?> name = feature.atts.get(Att.OBJNAM);
117 if (name == null) {
118 AttMap atts = feature.objs.get(feature.type).get(0);
119 if (atts != null) {
120 name = atts.get(Att.OBJNAM);
121 }
122 }
123 return (name != null) ? (String) name.val : null;
124 }
125
126 public static void addName(int z, Font font) {
127 addName(z, font, Color.black, new Delta(Handle.CC, new AffineTransform()));
128 }
129
130 public static void addName(int z, Font font, Color colour) {
131 addName(z, font, colour, new Delta(Handle.CC, new AffineTransform()));
132 }
133
134 public static void addName(int z, Font font, Delta delta) {
135 addName(z, font, Color.black, delta);
136 }
137
138 public static void addName(int z, Font font, Color colour, Delta delta) {
139 if (Renderer.zoom >= z) {
140 String name = getName();
141 if (name != null) {
142 Renderer.labelText(name, font, colour, delta);
143 }
144 }
145 }
146
147 static AttMap getAtts(Obj obj, int idx) {
148 HashMap<Integer, AttMap> objs = feature.objs.get(obj);
149 if (objs == null)
150 return null;
151 else
152 return objs.get(idx);
153 }
154
155 public static Object getAttVal(Obj obj, Att att) {
156 AttMap atts;
157 HashMap<Integer, AttMap> objs;
158 AttVal<?> item;
159 if ((objs = feature.objs.get(obj)) != null)
160 atts = objs.get(0);
161 else
162 return null;
163 if ((item = atts.get(att)) == null)
164 return null;
165 else
166 return item.val;
167 }
168
169 public static String getAttStr(Obj obj, Att att) {
170 String str = (String) getAttVal(obj, att);
171 if (str != null) {
172 return str;
173 }
174 return "";
175 }
176
177 @SuppressWarnings("unchecked")
178 public static Enum<?> getAttEnum(Obj obj, Att att) {
179 ArrayList<?> list = (ArrayList<?>) getAttVal(obj, att);
180 if (list != null) {
181 return ((ArrayList<Enum<?>>) list).get(0);
182 }
183 return S57val.unknAtt(att);
184 }
185
186 @SuppressWarnings("unchecked")
187 public static ArrayList<?> getAttList(Obj obj, Att att) {
188 ArrayList<Enum<?>> list = (ArrayList<Enum<?>>) getAttVal(obj, att);
189 if (list != null) {
190 return list;
191 }
192 list = new ArrayList<>();
193 list.add(S57val.unknAtt(att));
194 return list;
195 }
196
197 @SuppressWarnings("unchecked")
198 static Scheme getScheme(Obj obj) {
199 ArrayList<Color> colours = new ArrayList<>();
200 for (ColCOL col : (ArrayList<ColCOL>) getAttList(obj, Att.COLOUR)) {
201 colours.add(bodyColours.get(col));
202 }
203 ArrayList<Patt> patterns = new ArrayList<>();
204 for (ColPAT pat : (ArrayList<ColPAT>) getAttList(obj, Att.COLPAT)) {
205 patterns.add(pattMap.get(pat));
206 }
207 return new Scheme(patterns, colours);
208 }
209
210 static boolean hasAttribute(Obj obj, Att att) {
211 AttMap atts;
212 if ((atts = getAtts(obj, 0)) != null) {
213 AttVal<?> item = atts.get(att);
214 return item != null;
215 }
216 return false;
217 }
218
219 static boolean testAttribute(Obj obj, Att att, Object val) {
220 AttMap atts;
221 if ((atts = getAtts(obj, 0)) != null) {
222 AttVal<?> item = atts.get(att);
223 if (item != null) {
224 switch (item.conv) {
225 case S:
226 case A:
227 return ((String) item.val).equals(val);
228 case E:
229 case L:
230 return ((ArrayList<?>) item.val).contains(val);
231 case F:
232 case I:
233 return item.val == val;
234 }
235 }
236 }
237 return false;
238 }
239
240 static boolean hasObject(Obj obj) {
241 return (feature.objs.containsKey(obj));
242 }
243
244 public static Feature feature;
245 static ArrayList<Feature> objects;
246
247 static boolean testObject(Obj obj) {
248 return ((objects = Renderer.map.features.get(obj)) != null);
249 }
250
251 static boolean testFeature(Feature f) {
252 return ((feature = f).reln == Rflag.MASTER);
253 }
254
255 public static boolean rules() {
256 try {
257 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) {
258 if (testObject(Obj.LNDARE)) for (Feature f : objects) if (testFeature(f)) areas();
259 if (testObject(Obj.BUAARE)) for (Feature f : objects) if (testFeature(f)) areas();
260 if (testObject(Obj.HRBFAC)) for (Feature f : objects) if (testFeature(f)) areas();
261 if (testObject(Obj.HRBBSN)) for (Feature f : objects) if (testFeature(f)) areas();
262 if (testObject(Obj.LOKBSN)) for (Feature f : objects) if (testFeature(f)) areas();
263 if (testObject(Obj.LKBSPT)) for (Feature f : objects) if (testFeature(f)) areas();
264 if (testObject(Obj.LAKARE)) for (Feature f : objects) if (testFeature(f)) areas();
265 if (testObject(Obj.RIVERS)) for (Feature f : objects) if (testFeature(f)) waterways();
266 if (testObject(Obj.CANALS)) for (Feature f : objects) if (testFeature(f)) waterways();
267 if (testObject(Obj.DEPARE)) for (Feature f : objects) if (testFeature(f)) areas();
268 if (testObject(Obj.COALNE)) for (Feature f : objects) if (testFeature(f)) areas();
269 if (testObject(Obj.ROADWY)) for (Feature f : objects) if (testFeature(f)) highways();
270 if (testObject(Obj.RAILWY)) for (Feature f : objects) if (testFeature(f)) highways();
271 }
272 if (Renderer.context.ruleset() == RuleSet.ALL) {
273 if (testObject(Obj.SOUNDG)) for (Feature f : objects) if (testFeature(f)) depths();
274 if (testObject(Obj.DEPCNT)) for (Feature f : objects) if (testFeature(f)) depths();
275 }
276 if (testObject(Obj.SLCONS)) for (Feature f : objects) if (testFeature(f)) shoreline();
277 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.SEAMARK)) {
278 if (testObject(Obj.PIPSOL)) for (Feature f : objects) if (testFeature(f)) pipelines();
279 if (testObject(Obj.CBLSUB)) for (Feature f : objects) if (testFeature(f)) cables();
280 if (testObject(Obj.PIPOHD)) for (Feature f : objects) if (testFeature(f)) pipelines();
281 if (testObject(Obj.CBLOHD)) for (Feature f : objects) if (testFeature(f)) cables();
282 if (testObject(Obj.TSEZNE)) for (Feature f : objects) if (testFeature(f)) separation();
283 if (testObject(Obj.TSSCRS)) for (Feature f : objects) if (testFeature(f)) separation();
284 if (testObject(Obj.TSSRON)) for (Feature f : objects) if (testFeature(f)) separation();
285 if (testObject(Obj.TSELNE)) for (Feature f : objects) if (testFeature(f)) separation();
286 if (testObject(Obj.TSSLPT)) for (Feature f : objects) if (testFeature(f)) separation();
287 if (testObject(Obj.TSSBND)) for (Feature f : objects) if (testFeature(f)) separation();
288 if (testObject(Obj.ISTZNE)) for (Feature f : objects) if (testFeature(f)) separation();
289 if (testObject(Obj.SNDWAV)) for (Feature f : objects) if (testFeature(f)) areas();
290 if (testObject(Obj.WEDKLP)) for (Feature f : objects) if (testFeature(f)) areas();
291 if (testObject(Obj.OSPARE)) for (Feature f : objects) if (testFeature(f)) areas();
292 if (testObject(Obj.FAIRWY)) for (Feature f : objects) if (testFeature(f)) areas();
293 if (testObject(Obj.DRGARE)) for (Feature f : objects) if (testFeature(f)) areas();
294 if (testObject(Obj.RESARE)) for (Feature f : objects) if (testFeature(f)) areas();
295 if (testObject(Obj.PRCARE)) for (Feature f : objects) if (testFeature(f)) areas();
296 if (testObject(Obj.SPLARE)) for (Feature f : objects) if (testFeature(f)) areas();
297 if (testObject(Obj.SEAARE)) for (Feature f : objects) if (testFeature(f)) areas();
298 if (testObject(Obj.OBSTRN)) for (Feature f : objects) if (testFeature(f)) obstructions();
299 if (testObject(Obj.UWTROC)) for (Feature f : objects) if (testFeature(f)) obstructions();
300 if (testObject(Obj.MARCUL)) for (Feature f : objects) if (testFeature(f)) areas();
301 if (testObject(Obj.RECTRC)) for (Feature f : objects) if (testFeature(f)) transits();
302 if (testObject(Obj.NAVLNE)) for (Feature f : objects) if (testFeature(f)) transits();
303 if (testObject(Obj.HRBFAC)) for (Feature f : objects) if (testFeature(f)) harbours();
304 if (testObject(Obj.ACHARE)) for (Feature f : objects) if (testFeature(f)) harbours();
305 if (testObject(Obj.ACHBRT)) for (Feature f : objects) if (testFeature(f)) harbours();
306 if (testObject(Obj.BERTHS)) for (Feature f : objects) if (testFeature(f)) harbours();
307 if (testObject(Obj.DISMAR)) for (Feature f : objects) if (testFeature(f)) distances();
308 if (testObject(Obj.HULKES)) for (Feature f : objects) if (testFeature(f)) ports();
309 if (testObject(Obj.CRANES)) for (Feature f : objects) if (testFeature(f)) ports();
310 if (testObject(Obj.LNDMRK)) for (Feature f : objects) if (testFeature(f)) landmarks();
311 if (testObject(Obj.SILTNK)) for (Feature f : objects) if (testFeature(f)) landmarks();
312 if (testObject(Obj.BUISGL)) for (Feature f : objects) if (testFeature(f)) harbours();
313 if (testObject(Obj.MORFAC)) for (Feature f : objects) if (testFeature(f)) moorings();
314 if (testObject(Obj.NOTMRK)) for (Feature f : objects) if (testFeature(f)) notices();
315 if (testObject(Obj.SMCFAC)) for (Feature f : objects) if (testFeature(f)) marinas();
316 if (testObject(Obj.BRIDGE)) for (Feature f : objects) if (testFeature(f)) bridges();
317 if (testObject(Obj.PILPNT)) for (Feature f : objects) if (testFeature(f)) points();
318 if (testObject(Obj.TOPMAR)) for (Feature f : objects) if (testFeature(f)) points();
319 if (testObject(Obj.DAYMAR)) for (Feature f : objects) if (testFeature(f)) points();
320 if (testObject(Obj.FOGSIG)) for (Feature f : objects) if (testFeature(f)) points();
321 if (testObject(Obj.RDOCAL)) for (Feature f : objects) if (testFeature(f)) callpoint();
322 if (testObject(Obj.LITMIN)) for (Feature f : objects) if (testFeature(f)) lights();
323 if (testObject(Obj.LITMAJ)) for (Feature f : objects) if (testFeature(f)) lights();
324 if (testObject(Obj.LIGHTS)) for (Feature f : objects) if (testFeature(f)) lights();
325 if (testObject(Obj.SISTAT)) for (Feature f : objects) if (testFeature(f)) stations();
326 if (testObject(Obj.SISTAW)) for (Feature f : objects) if (testFeature(f)) stations();
327 if (testObject(Obj.CGUSTA)) for (Feature f : objects) if (testFeature(f)) stations();
328 if (testObject(Obj.RDOSTA)) for (Feature f : objects) if (testFeature(f)) stations();
329 if (testObject(Obj.RADRFL)) for (Feature f : objects) if (testFeature(f)) stations();
330 if (testObject(Obj.RADSTA)) for (Feature f : objects) if (testFeature(f)) stations();
331 if (testObject(Obj.RTPBCN)) for (Feature f : objects) if (testFeature(f)) stations();
332 if (testObject(Obj.RSCSTA)) for (Feature f : objects) if (testFeature(f)) stations();
333 if (testObject(Obj.PILBOP)) for (Feature f : objects) if (testFeature(f)) stations();
334 if (testObject(Obj.WTWGAG)) for (Feature f : objects) if (testFeature(f)) gauges();
335 if (testObject(Obj.OFSPLF)) for (Feature f : objects) if (testFeature(f)) platforms();
336 if (testObject(Obj.WRECKS)) for (Feature f : objects) if (testFeature(f)) wrecks();
337 if (testObject(Obj.LITVES)) for (Feature f : objects) if (testFeature(f)) floats();
338 if (testObject(Obj.LITFLT)) for (Feature f : objects) if (testFeature(f)) floats();
339 if (testObject(Obj.BOYINB)) for (Feature f : objects) if (testFeature(f)) floats();
340 if (testObject(Obj.BOYLAT)) for (Feature f : objects) if (testFeature(f)) buoys();
341 if (testObject(Obj.BOYCAR)) for (Feature f : objects) if (testFeature(f)) buoys();
342 if (testObject(Obj.BOYISD)) for (Feature f : objects) if (testFeature(f)) buoys();
343 if (testObject(Obj.BOYSAW)) for (Feature f : objects) if (testFeature(f)) buoys();
344 if (testObject(Obj.BOYSPP)) for (Feature f : objects) if (testFeature(f)) buoys();
345 if (testObject(Obj.BCNLAT)) for (Feature f : objects) if (testFeature(f)) beacons();
346 if (testObject(Obj.BCNCAR)) for (Feature f : objects) if (testFeature(f)) beacons();
347 if (testObject(Obj.BCNISD)) for (Feature f : objects) if (testFeature(f)) beacons();
348 if (testObject(Obj.BCNSAW)) for (Feature f : objects) if (testFeature(f)) beacons();
349 if (testObject(Obj.BCNSPP)) for (Feature f : objects) if (testFeature(f)) beacons();
350 }
351 } catch (ConcurrentModificationException e) {
352 return false;
353 } catch (Exception e) {
354 return true;
355 }
356 return true;
357 }
358
359 private static void areas() {
360 String name = getName();
361 switch (feature.type) {
362 case BUAARE:
363 Renderer.lineVector(new LineStyle(new Color(0x20000000, true)));
364 break;
365 case COALNE:
366 if (Renderer.zoom >= 12)
367 Renderer.lineVector(new LineStyle(Color.black, 10));
368 break;
369 case DEPARE:
370 Double depmax = 0.0;
371 if (((depmax = (Double) getAttVal(Obj.DEPARE, Att.DRVAL2)) != null) && (depmax <= 0.0)) {
372 Renderer.lineVector(new LineStyle(Symbols.Gdries));
373 }
374 break;
375 case LAKARE:
376 if ((Renderer.zoom >= 12) || (feature.geom.area > 10.0))
377 Renderer.lineVector(new LineStyle(Symbols.Bwater));
378 break;
379 case DRGARE:
380 if (Renderer.zoom < 16)
381 Renderer.lineVector(new LineStyle(Color.black, 8, new float[] { 25, 25 }, new Color(0x40ffffff, true)));
382 else
383 Renderer.lineVector(new LineStyle(Color.black, 8, new float[] { 25, 25 }));
384 addName(12, new Font("Arial", Font.PLAIN, 100), new Delta(Handle.CC, new AffineTransform()));
385 break;
386 case FAIRWY:
387 if (feature.geom.area > 2.0) {
388 if (Renderer.zoom < 16)
389 Renderer.lineVector(new LineStyle(Symbols.Mline, 8, new float[] { 50, 50 }, new Color(0x40ffffff, true)));
390 else
391 Renderer.lineVector(new LineStyle(Symbols.Mline, 8, new float[] { 50, 50 }));
392 } else {
393 if (Renderer.zoom >= 14)
394 Renderer.lineVector(new LineStyle(new Color(0x40ffffff, true)));
395 }
396 break;
397 case LKBSPT:
398 case LOKBSN:
399 case HRBBSN:
400 if (Renderer.zoom >= 12) {
401 Renderer.lineVector(new LineStyle(Color.black, 10, Symbols.Bwater));
402 } else {
403 Renderer.lineVector(new LineStyle(Symbols.Bwater));
404 }
405 break;
406 case HRBFAC:
407 if (feature.objs.get(Obj.HRBBSN) != null) {
408 if (Renderer.zoom >= 12) {
409 Renderer.lineVector(new LineStyle(Color.black, 10, Symbols.Bwater));
410 } else {
411 Renderer.lineVector(new LineStyle(Symbols.Bwater));
412 }
413 }
414 break;
415 case LNDARE:
416 Renderer.lineVector(new LineStyle(Symbols.Yland));
417 break;
418 case MARCUL:
419 if (Renderer.zoom >= 12) {
420 if (Renderer.zoom >= 14) {
421 Renderer.symbol(Areas.MarineFarm);
422 }
423 if ((feature.geom.area > 0.2) || ((feature.geom.area > 0.05) && (Renderer.zoom >= 14)) || ((feature.geom.area > 0.005) && (Renderer.zoom >= 16))) {
424 Renderer.lineVector(new LineStyle(Color.black, 4, new float[] { 10, 10 }));
425 }
426 }
427 break;
428 case OSPARE:
429 if (testAttribute(feature.type, Att.CATPRA, CatPRA.PRA_WFRM)) {
430 Renderer.symbol(Areas.WindFarm);
431 Renderer.lineVector(new LineStyle(Color.black, 20, new float[] { 40, 40 }));
432 addName(15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10)));
433 }
434 break;
435 case RESARE:
436 case MIPARE:
437 if (Renderer.zoom >= 12) {
438 Renderer.lineSymbols(Areas.Restricted, 1.0, null, null, 0, Symbols.Mline);
439 if (testAttribute(feature.type, Att.CATREA, CatREA.REA_NWAK)) {
440 Renderer.symbol(Areas.NoWake);
441 }
442 }
443 break;
444 case PRCARE:
445 if (Renderer.zoom >= 12) {
446 Renderer.lineVector(new LineStyle(Symbols.Mline, 10, new float[] { 40, 40 }));
447 }
448 break;
449 case SEAARE:
450 switch ((CatSEA) getAttEnum(feature.type, Att.CATSEA)) {
451 case SEA_RECH:
452 if ((Renderer.zoom >= 10) && (name != null))
453 if (feature.geom.prim == Pflag.LINE) {
454 Renderer.lineText(name, new Font("Arial", Font.PLAIN, 150), Color.black, -40);
455 } else {
456 Renderer.labelText(name, new Font("Arial", Font.PLAIN, 150), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -40)));
457 }
458 break;
459 case SEA_BAY:
460 if ((Renderer.zoom >= 12) && (name != null))
461 if (feature.geom.prim == Pflag.LINE) {
462 Renderer.lineText(name, new Font("Arial", Font.PLAIN, 150), Color.black, -40);
463 } else {
464 Renderer.labelText(name, new Font("Arial", Font.PLAIN, 150), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -40)));
465 }
466 break;
467 case SEA_SHOL:
468 if (Renderer.zoom >= 14) {
469 if (feature.geom.prim == Pflag.AREA) {
470 Renderer.lineVector(new LineStyle(new Color(0xc480ff), 4, new float[] { 25, 25 }));
471 if (name != null) {
472 Renderer.labelText(name, new Font("Arial", Font.ITALIC, 75), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -40)));
473 Renderer.labelText("(Shoal)", new Font("Arial", Font.PLAIN, 60), Color.black, new Delta(Handle.BC));
474 }
475 } else if (feature.geom.prim == Pflag.LINE) {
476 if (name != null) {
477 Renderer.lineText(name, new Font("Arial", Font.ITALIC, 75), Color.black, -40);
478 Renderer.lineText("(Shoal)", new Font("Arial", Font.PLAIN, 60), Color.black, 0);
479 }
480 } else {
481 if (name != null) {
482 Renderer.labelText(name, new Font("Arial", Font.ITALIC, 75), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -40)));
483 Renderer.labelText("(Shoal)", new Font("Arial", Font.PLAIN, 60), Color.black, new Delta(Handle.BC));
484 }
485 }
486 }
487 break;
488 case SEA_GAT:
489 case SEA_NRRW:
490 addName(12, new Font("Arial", Font.PLAIN, 100));
491 break;
492 default:
493 break;
494 }
495 break;
496 case SNDWAV:
497 if (Renderer.zoom >= 12)
498 Renderer.fillPattern(Areas.Sandwaves);
499 break;
500 case WEDKLP:
501 if (Renderer.zoom >= 12) {
502 switch ((CatWED) getAttEnum(feature.type, Att.CATWED)) {
503 case WED_KELP:
504 if (feature.geom.prim == Pflag.AREA) {
505 Renderer.fillPattern(Areas.KelpA);
506 } else {
507 Renderer.symbol(Areas.KelpS);
508 }
509 break;
510 default:
511 break;
512 }
513 }
514 break;
515 case SPLARE:
516 if (Renderer.zoom >= 12) {
517 Renderer.symbol(Areas.Plane, new Scheme(Symbols.Msymb));
518 Renderer.lineSymbols(Areas.Restricted, 0.5, Areas.LinePlane, null, 10, Symbols.Mline);
519 }
520 addName(15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
521 break;
522 default:
523 break;
524 }
525 }
526
527 @SuppressWarnings("unchecked")
528 private static void beacons() {
529 if ((Renderer.zoom >= 14) || ((Renderer.zoom >= 12) && ((feature.type == Obj.BCNLAT) || (feature.type == Obj.BCNCAR))) || ((Renderer.zoom >= 11) && ((feature.type == Obj.BCNSAW) || hasObject(Obj.RTPBCN)))) {
530 BcnSHP shape = (BcnSHP) getAttEnum(feature.type, Att.BCNSHP);
531 if (shape == BcnSHP.BCN_UNKN)
532 shape = BcnSHP.BCN_PILE;
533 if ((shape == BcnSHP.BCN_WTHY) && (feature.type == Obj.BCNLAT)) {
534 switch ((CatLAM) getAttEnum(feature.type, Att.CATLAM)) {
535 case LAM_PORT:
536 Renderer.symbol(Beacons.WithyPort);
537 break;
538 case LAM_STBD:
539 Renderer.symbol(Beacons.WithyStarboard);
540 break;
541 default:
542 Renderer.symbol(Beacons.Stake, getScheme(feature.type));
543 }
544 } else if ((shape == BcnSHP.BCN_PRCH) && (feature.type == Obj.BCNLAT) && !(feature.objs.containsKey(Obj.TOPMAR))) {
545 switch ((CatLAM) getAttEnum(feature.type, Att.CATLAM)) {
546 case LAM_PORT:
547 Renderer.symbol(Beacons.PerchPort);
548 break;
549 case LAM_STBD:
550 Renderer.symbol(Beacons.PerchStarboard);
551 break;
552 default:
553 Renderer.symbol(Beacons.Stake, getScheme(feature.type));
554 }
555 } else {
556 Renderer.symbol(Beacons.Shapes.get(shape), getScheme(feature.type));
557 if (feature.objs.containsKey(Obj.TOPMAR)) {
558 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
559 if (topmap.containsKey(Att.TOPSHP)) {
560 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.BeaconDelta);
561 }
562 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
563 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
564 if (topmap.containsKey(Att.TOPSHP)) {
565 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.BeaconDelta);
566 }
567 }
568 }
569 if (hasObject(Obj.NOTMRK))
570 notices();
571 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
572 Signals.addSignals();
573 }
574 }
575
576 @SuppressWarnings("unchecked")
577 private static void buoys() {
578 if ((Renderer.zoom >= 14) || ((Renderer.zoom >= 12) && ((feature.type == Obj.BOYLAT) || (feature.type == Obj.BOYCAR))) || ((Renderer.zoom >= 11) && ((feature.type == Obj.BOYSAW) || hasObject(Obj.RTPBCN)))) {
579 BoySHP shape = (BoySHP) getAttEnum(feature.type, Att.BOYSHP);
580 if (shape == BoySHP.BOY_UNKN)
581 shape = BoySHP.BOY_PILR;
582 Renderer.symbol(Buoys.Shapes.get(shape), getScheme(feature.type));
583 if (feature.objs.containsKey(Obj.TOPMAR)) {
584 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
585 if (topmap.containsKey(Att.TOPSHP)) {
586 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.BuoyDeltas.get(shape));
587 }
588 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
589 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
590 if (topmap.containsKey(Att.TOPSHP)) {
591 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.BuoyDeltas.get(shape));
592 }
593 }
594 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
595 Signals.addSignals();
596 }
597 }
598
599 private static void bridges() {
600 if (Renderer.zoom >= 16) {
601 double verclr, verccl, vercop, horclr;
602 AttMap atts = feature.objs.get(Obj.BRIDGE).get(0);
603 String vstr = "";
604 String hstr = "";
605 if (atts != null) {
606 if (atts.containsKey(Att.HORCLR)) {
607 horclr = (Double) atts.get(Att.HORCLR).val;
608 hstr = String.valueOf(horclr);
609 }
610 if (atts.containsKey(Att.VERCLR)) {
611 verclr = (Double) atts.get(Att.VERCLR).val;
612 } else {
613 verclr = atts.containsKey(Att.VERCSA) ? (Double) atts.get(Att.VERCSA).val : 0;
614 }
615 verccl = atts.containsKey(Att.VERCCL) ? (Double) atts.get(Att.VERCCL).val : 0;
616 vercop = atts.containsKey(Att.VERCOP) ? (Double) atts.get(Att.VERCOP).val : 0;
617 if (verclr > 0) {
618 vstr += String.valueOf(verclr);
619 } else if (verccl > 0) {
620 if (vercop == 0) {
621 vstr += String.valueOf(verccl) + "/-";
622 } else {
623 vstr += String.valueOf(verccl) + "/" + String.valueOf(vercop);
624 }
625 }
626 if (hstr.isEmpty() && !vstr.isEmpty()) {
627 Renderer.labelText(vstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.VCLR, Color.black, Color.white, new Delta(Handle.CC));
628 } else if (!hstr.isEmpty() && !vstr.isEmpty()) {
629 Renderer.labelText(vstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.VCLR, Color.black, Color.white, new Delta(Handle.BC));
630 Renderer.labelText(hstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.HCLR, Color.black, Color.white, new Delta(Handle.TC));
631 } else if (!hstr.isEmpty() && vstr.isEmpty()) {
632 Renderer.labelText(hstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.HCLR, Color.black, Color.white, new Delta(Handle.CC));
633 }
634 }
635 }
636 }
637
638 private static void cables() {
639 if ((Renderer.zoom >= 16) && (feature.geom.length < 2)) {
640 if (feature.type == Obj.CBLSUB) {
641 Renderer.lineSymbols(Areas.Cable, 0.0, null, null, 0, Symbols.Mline);
642 } else if (feature.type == Obj.CBLOHD) {
643 AttMap atts = feature.objs.get(Obj.CBLOHD).get(0);
644 if ((atts != null) && (atts.containsKey(Att.CATCBL)) && (atts.get(Att.CATCBL).val == CatCBL.CBL_POWR)) {
645 Renderer.lineSymbols(Areas.CableDash, 0, Areas.CableDot, Areas.CableFlash, 2, Color.black);
646 } else {
647 Renderer.lineSymbols(Areas.CableDash, 0, Areas.CableDot, null, 2, Color.black);
648 }
649 if (atts != null) {
650 if (atts.containsKey(Att.VERCLR)) {
651 Renderer.labelText(String.valueOf(atts.get(Att.VERCLR).val), new Font("Arial", Font.PLAIN, 50), Color.black, LabelStyle.VCLR, Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 25)));
652 } else if (atts.containsKey(Att.VERCSA)) {
653 Renderer.labelText(String.valueOf(atts.get(Att.VERCSA).val), new Font("Arial", Font.PLAIN, 50), Color.black, LabelStyle.PCLR, Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 25)));
654 }
655 }
656 }
657 }
658 }
659
660 private static void callpoint() {
661 if (Renderer.zoom >= 14) {
662 Symbol symb = Harbours.CallPoint2;
663 TrfTRF trf = (TrfTRF) getAttEnum(feature.type, Att.TRAFIC);
664 if (trf != TrfTRF.TRF_TWOW) {
665 symb = Harbours.CallPoint1;
666 }
667 Double orient = 0.0;
668 if ((orient = (Double) getAttVal(feature.type, Att.ORIENT)) == null) {
669 orient = 0.0;
670 }
671 Renderer.symbol(symb, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(orient))));
672 String chn;
673 if (!(chn = getAttStr(feature.type, Att.COMCHA)).isEmpty()) {
674 Renderer.labelText(("Ch." + chn), new Font("Arial", Font.PLAIN, 50), Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 50)));
675 }
676 }
677 }
678
679 private static void depths() {
680 switch (feature.type) {
681 case SOUNDG:
682 if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
683 double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
684 String dstr = df.format(depth);
685 String[] tok = dstr.split("[-.]");
686 String ul = "";
687 String id = tok[0];
688 String dd = "";
689 if (tok[0].equals("")) {
690 for (int i = 0; i < tok[1].length(); i++) {
691 ul += "_";
692 }
693 id = tok[1];
694 dd = (tok.length == 3) ? tok[2] : "";
695 } else {
696 dd = (tok.length == 2) ? tok[1] : "";
697 }
698 Renderer.labelText(ul, new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.RC, AffineTransform.getTranslateInstance(10, 15)));
699 Renderer.labelText(id, new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.RC, AffineTransform.getTranslateInstance(10, 0)));
700 Renderer.labelText(dd, new Font("Arial", Font.PLAIN, 20), Color.black, new Delta(Handle.LC, AffineTransform.getTranslateInstance(15, 10)));
701 }
702 break;
703 case DEPCNT:
704 break;
705 default:
706 break;
707 }
708 }
709
710 private static void distances() {
711 if (Renderer.zoom >= 14) {
712 if (!testAttribute(Obj.DISMAR, Att.CATDIS, CatDIS.DIS_NONI)) {
713 Renderer.symbol(Harbours.DistanceI);
714 } else {
715 Renderer.symbol(Harbours.DistanceU);
716 }
717 if (Renderer.zoom >= 15) {
718 AttMap atts = getAtts(Obj.DISMAR, 0);
719 if ((atts != null) && (atts.containsKey(Att.WTWDIS))) {
720 Double dist = (Double) atts.get(Att.WTWDIS).val;
721 String str = "";
722 if (atts.containsKey(Att.HUNITS)) {
723 switch ((UniHLU) getAttEnum(Obj.DISMAR, Att.HUNITS)) {
724 case HLU_METR:
725 str += "m ";
726 break;
727 case HLU_FEET:
728 str += "ft ";
729 break;
730 case HLU_HMTR:
731 str += "hm ";
732 break;
733 case HLU_KMTR:
734 str += "km ";
735 break;
736 case HLU_SMIL:
737 str += "M ";
738 break;
739 case HLU_NMIL:
740 str += "NM ";
741 break;
742 default:
743 break;
744 }
745 }
746 str += String.format("%1.0f", dist);
747 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 45)));
748 }
749 }
750 }
751 }
752
753 @SuppressWarnings("unchecked")
754 private static void floats() {
755 if ((Renderer.zoom >= 12) || ((Renderer.zoom >= 11) && ((feature.type == Obj.LITVES) || (feature.type == Obj.BOYINB) || hasObject(Obj.RTPBCN)))) {
756 switch (feature.type) {
757 case LITVES:
758 Renderer.symbol(Buoys.Super, getScheme(feature.type));
759 break;
760 case LITFLT:
761 Renderer.symbol(Buoys.Float, getScheme(feature.type));
762 break;
763 case BOYINB:
764 Renderer.symbol(Buoys.Super, getScheme(feature.type));
765 break;
766 default:
767 break;
768 }
769 if (feature.objs.containsKey(Obj.TOPMAR)) {
770 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
771 if (topmap.containsKey(Att.TOPSHP)) {
772 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.FloatDelta);
773 }
774 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
775 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
776 if (topmap.containsKey(Att.TOPSHP)) {
777 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.FloatDelta);
778 }
779 }
780 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50)));
781 Signals.addSignals();
782 }
783 }
784
785 private static void gauges() {
786 if (Renderer.zoom >= 14) {
787 Renderer.symbol(Harbours.TideGauge);
788 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50)));
789 Signals.addSignals();
790 }
791 }
792
793 @SuppressWarnings("unchecked")
794 private static void harbours() {
795 String name = getName();
796 switch (feature.type) {
797 case ACHBRT:
798 if (Renderer.zoom >= 14) {
799 Renderer.symbol(Harbours.Anchor, new Scheme(Symbols.Msymb));
800 if (Renderer.zoom >= 15) {
801 Renderer.labelText(name == null ? "" : name, new Font("Arial", Font.PLAIN, 30), Symbols.Msymb, LabelStyle.RRCT, Symbols.Msymb, Color.white, new Delta(Handle.BC));
802 }
803 }
804 if (getAttVal(Obj.ACHBRT, Att.RADIUS) != null) {
805 double radius;
806 if ((radius = (Double) getAttVal(Obj.ACHBRT, Att.RADIUS)) != 0) {
807 UniHLU units = (UniHLU) getAttEnum(Obj.ACHBRT, Att.HUNITS);
808 if (units == UniHLU.HLU_UNKN) {
809 units = UniHLU.HLU_METR;
810 }
811 Renderer.lineCircle(new LineStyle(Symbols.Mline, 4, new float[] { 10, 10 }, null), radius, units);
812 }
813 }
814 break;
815 case ACHARE:
816 if (Renderer.zoom >= 12) {
817 if (feature.geom.prim != Pflag.AREA) {
818 Renderer.symbol(Harbours.Anchorage, new Scheme(Color.black));
819 } else {
820 Renderer.symbol(Harbours.Anchorage, new Scheme(Symbols.Mline));
821 Renderer.lineSymbols(Areas.Restricted, 1.0, Areas.LineAnchor, null, 10, Symbols.Mline);
822 }
823 addName(15, new Font("Arial", Font.BOLD, 60), Symbols.Mline, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, 0)));
824 ArrayList<StsSTS> sts = (ArrayList<StsSTS>) getAttList(Obj.ACHARE, Att.STATUS);
825 if ((Renderer.zoom >= 15) && (sts.contains(StsSTS.STS_RESV))) {
826 Renderer.labelText("Reserved", new Font("Arial", Font.PLAIN, 50), Symbols.Mline, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 60)));
827 }
828 ArrayList<CatACH> cats = (ArrayList<CatACH>) getAttList(Obj.ACHARE, Att.CATACH);
829 int dy = (cats.size() - 1) * -30;
830 for (CatACH cat : cats) {
831 switch (cat) {
832 case ACH_DEEP:
833 Renderer.labelText("DW", new Font("Arial", Font.BOLD, 50), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
834 dy += 60;
835 break;
836 case ACH_TANK:
837 Renderer.labelText("Tanker", new Font("Arial", Font.BOLD, 50), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
838 dy += 60;
839 break;
840 case ACH_H24P:
841 Renderer.labelText("24h", new Font("Arial", Font.BOLD, 50), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
842 dy += 60;
843 break;
844 case ACH_EXPL:
845 Renderer.symbol(Harbours.Explosives, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
846 dy += 60;
847 break;
848 case ACH_QUAR:
849 Renderer.symbol(Harbours.Hospital, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
850 dy += 60;
851 break;
852 case ACH_SEAP:
853 Renderer.symbol(Areas.Seaplane, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
854 dy += 60;
855 break;
856 default:
857 }
858 }
859 }
860 break;
861 case BERTHS:
862 if (Renderer.zoom >= 14) {
863 Renderer.lineVector(new LineStyle(Symbols.Mline, 6, new float[] { 20, 20 }));
864 Renderer.labelText(name == null ? " " : name, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, LabelStyle.RRCT, Symbols.Mline, Color.white);
865 }
866 break;
867 case BUISGL:
868 if (Renderer.zoom >= 16) {
869 if (hasAttribute(Obj.BUISGL, Att.STATUS) && (testAttribute(Obj.BUISGL, Att.STATUS, StsSTS.STS_ILLD))) {
870 Renderer.symbol(Beacons.Floodlight);
871 }
872 ArrayList<Symbol> symbols = new ArrayList<>();
873 ArrayList<FncFNC> fncs = (ArrayList<FncFNC>) getAttList(Obj.BUISGL, Att.FUNCTN);
874 for (FncFNC fnc : fncs) {
875 symbols.add(Landmarks.Funcs.get(fnc));
876 }
877 if (feature.objs.containsKey(Obj.SMCFAC)) {
878 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttList(Obj.SMCFAC, Att.CATSCF);
879 for (CatSCF scf : scfs) {
880 symbols.add(Facilities.Cats.get(scf));
881 }
882 }
883 Renderer.cluster(symbols);
884 }
885 break;
886 case HRBFAC:
887 if (Renderer.zoom >= 12) {
888 ArrayList<CatHAF> cathaf = (ArrayList<CatHAF>) getAttList(Obj.HRBFAC, Att.CATHAF);
889 if (cathaf.size() == 1) {
890 switch (cathaf.get(0)) {
891 case HAF_MRNA:
892 Renderer.symbol(Harbours.Marina);
893 break;
894 case HAF_MANF:
895 Renderer.symbol(Harbours.MarinaNF);
896 break;
897 case HAF_FISH:
898 Renderer.symbol(Harbours.Fishing);
899 break;
900 default:
901 Renderer.symbol(Harbours.Harbour);
902 break;
903 }
904 } else {
905 Renderer.symbol(Harbours.Harbour);
906 }
907 }
908 break;
909 default:
910 break;
911 }
912 }
913
914 @SuppressWarnings("unchecked")
915 private static void highways() {
916 switch (feature.type) {
917 case ROADWY:
918 ArrayList<CatROD> cat = (ArrayList<CatROD>) (getAttList(Obj.ROADWY, Att.CATROD));
919 if (cat.size() > 0) {
920 switch (cat.get(0)) {
921 case ROD_MWAY:
922 Renderer.lineVector(new LineStyle(Color.black, 20));
923 break;
924 case ROD_MAJR:
925 Renderer.lineVector(new LineStyle(Color.black, 15));
926 break;
927 case ROD_MINR:
928 Renderer.lineVector(new LineStyle(Color.black, 10));
929 break;
930 default:
931 Renderer.lineVector(new LineStyle(Color.black, 5));
932 }
933 } else {
934 Renderer.lineVector(new LineStyle(Color.black, 5));
935 }
936 break;
937 case RAILWY:
938 Renderer.lineVector(new LineStyle(Color.gray, 10));
939 Renderer.lineVector(new LineStyle(Color.black, 10, new float[] { 30, 30 }));
940 break;
941 default:
942 }
943 }
944
945 @SuppressWarnings("unchecked")
946 private static void landmarks() {
947 if (!hasAttribute(Obj.LNDMRK, Att.CATLMK) && (!hasAttribute(Obj.LNDMRK, Att.FUNCTN) || testAttribute(Obj.LNDMRK, Att.FUNCTN, FncFNC.FNC_LGHT)) && hasObject(Obj.LIGHTS))
948 lights();
949 else if (Renderer.zoom >= 12) {
950 switch (feature.type) {
951 case LNDMRK:
952 if (hasAttribute(Obj.LNDMRK, Att.STATUS) && (testAttribute(Obj.LNDMRK, Att.STATUS, StsSTS.STS_ILLD))) {
953 Renderer.symbol(Beacons.Floodlight);
954 }
955 ArrayList<CatLMK> cats = (ArrayList<CatLMK>) getAttList(feature.type, Att.CATLMK);
956 Symbol catSym = Landmarks.Shapes.get(cats.get(0));
957 ArrayList<FncFNC> fncs = (ArrayList<FncFNC>) getAttList(feature.type, Att.FUNCTN);
958 Symbol fncSym = Landmarks.Funcs.get(fncs.get(0));
959 if ((fncs.get(0) == FncFNC.FNC_CHCH) && (cats.get(0) == CatLMK.LMK_TOWR))
960 catSym = Landmarks.ChurchTower;
961 if (cats.get(0) == CatLMK.LMK_RADR)
962 fncSym = Landmarks.RadioTV;
963 Renderer.symbol(catSym);
964 Renderer.symbol(fncSym);
965 break;
966 case SILTNK:
967 if (testAttribute(feature.type, Att.CATSIL, CatSIL.SIL_WTRT))
968 Renderer.symbol(Landmarks.WaterTower);
969 break;
970 default:
971 break;
972 }
973 if (Renderer.zoom >= 15)
974 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
975 Signals.addSignals();
976 }
977 }
978
979 @SuppressWarnings("unchecked")
980 private static void points() {
981 boolean ok = false;
982 switch (feature.type) {
983 case FOGSIG:
984 if (Renderer.zoom >= 12) {
985 if (feature.objs.containsKey(Obj.LIGHTS))
986 lights();
987 else
988 Renderer.symbol(Harbours.Post);
989 ok = true;
990 }
991 break;
992 default:
993 if (Renderer.zoom >= 14) {
994 if (feature.objs.containsKey(Obj.LIGHTS))
995 lights();
996 else
997 Renderer.symbol(Harbours.Post);
998 ok = true;
999 }
1000 break;
1001 }
1002 if (ok) {
1003 if (feature.objs.containsKey(Obj.TOPMAR)) {
1004 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
1005 if (topmap.containsKey(Att.TOPSHP)) {
1006 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), null);
1007 }
1008 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
1009 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
1010 if (topmap.containsKey(Att.TOPSHP)) {
1011 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), null);
1012 }
1013 }
1014 Signals.addSignals();
1015 }
1016 }
1017
1018 @SuppressWarnings("unchecked")
1019 private static void lights() {
1020 boolean ok = false;
1021 switch (feature.type) {
1022 case LITMAJ:
1023 case LNDMRK:
1024 if (Renderer.zoom >= 12) {
1025 Renderer.symbol(Beacons.LightMajor);
1026 ok = true;
1027 }
1028 break;
1029 case LITMIN:
1030 case LIGHTS:
1031 case PILPNT:
1032 if (Renderer.zoom >= 14) {
1033 if (hasAttribute(Obj.LIGHTS, Att.CATLIT) && (testAttribute(Obj.LIGHTS, Att.CATLIT, CatLIT.LIT_FLDL))) {
1034 Renderer.symbol(Beacons.Floodlight);
1035 Renderer.symbol(Harbours.SignalStation);
1036 } else {
1037 Renderer.symbol(Beacons.LightMinor);
1038 }
1039 ok = true;
1040 }
1041 break;
1042 default:
1043 break;
1044 }
1045 if (ok) {
1046 AffineTransform tr = new AffineTransform();
1047 if (feature.objs.containsKey(Obj.TOPMAR)) {
1048 if (hasAttribute(Obj.TOPMAR, Att.STATUS) && (testAttribute(Obj.TOPMAR, Att.STATUS, StsSTS.STS_ILLD))) {
1049 Renderer.symbol(Beacons.Floodlight);
1050 }
1051 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
1052 if (topmap.containsKey(Att.TOPSHP)) {
1053 if (hasAttribute(Obj.TOPMAR, Att.ORIENT)) {
1054 tr.rotate(Math.toRadians((Double) getAttVal(Obj.TOPMAR, Att.ORIENT)));
1055 }
1056 tr.translate(0, -20);
1057 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), new Delta(Handle.BC, tr));
1058 }
1059 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
1060 if (hasAttribute(Obj.DAYMAR, Att.STATUS) && (testAttribute(Obj.DAYMAR, Att.STATUS, StsSTS.STS_ILLD))) {
1061 Renderer.symbol(Beacons.Floodlight);
1062 }
1063 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
1064 if (topmap.containsKey(Att.TOPSHP)) {
1065 if (hasAttribute(Obj.DAYMAR, Att.ORIENT)) {
1066 tr.rotate(Math.toRadians((Double) getAttVal(Obj.DAYMAR, Att.ORIENT)));
1067 }
1068 tr.translate(0, -20);
1069 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), new Delta(Handle.BC, tr));
1070 }
1071 }
1072 Signals.addSignals();
1073 }
1074 }
1075
1076 @SuppressWarnings("unchecked")
1077 private static void marinas() {
1078 if (Renderer.zoom >= 16) {
1079 ArrayList<Symbol> symbols = new ArrayList<>();
1080 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttList(Obj.SMCFAC, Att.CATSCF);
1081 for (CatSCF scf : scfs) {
1082 symbols.add(Facilities.Cats.get(scf));
1083 }
1084 Renderer.cluster(symbols);
1085 }
1086 }
1087
1088 private static void moorings() {
1089 if (Renderer.zoom >= 14) {
1090 switch ((CatMOR) getAttEnum(feature.type, Att.CATMOR)) {
1091 case MOR_DLPN:
1092 Renderer.symbol(Harbours.Dolphin);
1093 break;
1094 case MOR_DDPN:
1095 Renderer.symbol(Harbours.DeviationDolphin);
1096 break;
1097 case MOR_BLRD:
1098 case MOR_POST:
1099 Renderer.symbol(Harbours.Bollard);
1100 break;
1101 case MOR_BUOY:
1102 BoySHP shape = (BoySHP) getAttEnum(feature.type, Att.BOYSHP);
1103 if (shape == BoySHP.BOY_UNKN) {
1104 shape = BoySHP.BOY_SPHR;
1105 }
1106 Renderer.symbol(Buoys.Shapes.get(shape), getScheme(feature.type));
1107 Renderer.symbol(Topmarks.TopMooring, Topmarks.BuoyDeltas.get(shape));
1108 break;
1109 default:
1110 break;
1111 }
1112 Signals.addSignals();
1113 }
1114 }
1115
1116 @SuppressWarnings("unchecked")
1117 private static void notices() {
1118 if (Renderer.zoom >= 14) {
1119 double dx = 0.0, dy = 0.0;
1120 switch (feature.type) {
1121 case BCNCAR:
1122 case BCNISD:
1123 case BCNLAT:
1124 case BCNSAW:
1125 case BCNSPP:
1126 if (testAttribute(Obj.TOPMAR, Att.TOPSHP, TopSHP.TOP_BORD) || testAttribute(Obj.DAYMAR, Att.TOPSHP, TopSHP.TOP_BORD)) {
1127 dy = -100.0;
1128 } else {
1129 dy = -45.0;
1130 }
1131 break;
1132 case NOTMRK:
1133 dy = 0.0;
1134 break;
1135 default:
1136 return;
1137 }
1138 MarSYS sys = MarSYS.SYS_CEVN;
1139 BnkWTW bnk = BnkWTW.BWW_UNKN;
1140 AttVal<?> att = feature.atts.get(Att.MARSYS);
1141 if (att != null)
1142 sys = (MarSYS) att.val;
1143 att = feature.atts.get(Att.BNKWTW);
1144 if (att != null)
1145 bnk = (BnkWTW) att.val;
1146 ObjTab objs = feature.objs.get(Obj.NOTMRK);
1147 int n = objs.size();
1148 if (n > 5) {
1149 Renderer.symbol(Notices.Notice, new Delta(Handle.CC, AffineTransform.getTranslateInstance(dx, dy)));
1150 } else {
1151 int i = 0;
1152 for (AttMap atts : objs.values()) {
1153 if (atts.get(Att.MARSYS) != null)
1154 sys = ((ArrayList<MarSYS>) (atts.get(Att.MARSYS).val)).get(0);
1155 if (atts.get(Att.BNKWTW) != null)
1156 bnk = ((ArrayList<BnkWTW>) (atts.get(Att.BNKWTW).val)).get(0);
1157 CatNMK cat = CatNMK.NMK_UNKN;
1158 if (atts.get(Att.CATNMK) != null)
1159 cat = ((ArrayList<CatNMK>) (atts.get(Att.CATNMK).val)).get(0);
1160 Symbol sym = Notices.getNotice(cat, sys, bnk);
1161 Scheme sch = Notices.getScheme(sys, bnk);
1162 ArrayList<AddMRK> add = new ArrayList<>();
1163 if (atts.get(Att.ADDMRK) != null)
1164 add = (ArrayList<AddMRK>) (atts.get(Att.ADDMRK).val);
1165 Handle h = Handle.CC;
1166 double ax = 0.0;
1167 double ay = 0.0;
1168 switch (i) {
1169 case 0:
1170 if (n != 1)
1171 h = null;
1172 break;
1173 case 1:
1174 if (n <= 3) {
1175 h = Handle.RC;
1176 ax = -30;
1177 ay = dy;
1178 } else {
1179 h = Handle.BR;
1180 }
1181 break;
1182 case 2:
1183 if (n <= 3)
1184 h = Handle.LC;
1185 else
1186 h = Handle.BL;
1187 break;
1188 case 3:
1189 if (n == 4)
1190 h = Handle.TC;
1191 else
1192 h = Handle.TR;
1193 break;
1194 case 4:
1195 h = Handle.TL;
1196 break;
1197 }
1198 if (h != null) {
1199 Renderer.symbol(sym, sch, new Delta(h, AffineTransform.getTranslateInstance(dx, dy)));
1200 if (!add.isEmpty())
1201 Renderer.symbol(Notices.NoticeBoard, new Delta(Handle.BC, AffineTransform.getTranslateInstance(ax, ay - 30)));
1202 }
1203 i++;
1204 }
1205 }
1206 }
1207 }
1208
1209 private static void obstructions() {
1210 if ((Renderer.zoom >= 12) && (feature.type == Obj.OBSTRN)) {
1211 if (getAttEnum(feature.type, Att.CATOBS) == CatOBS.OBS_BOOM) {
1212 Renderer.lineVector(new LineStyle(Color.black, 5, new float[] { 20, 20 }, null));
1213 if (Renderer.zoom >= 15) {
1214 Renderer.lineText("Boom", new Font("Arial", Font.PLAIN, 80), Color.black, -20);
1215 }
1216 }
1217 }
1218 if ((Renderer.zoom >= 14) && (feature.type == Obj.UWTROC)) {
1219 switch ((WatLEV) getAttEnum(feature.type, Att.WATLEV)) {
1220 case LEV_CVRS:
1221 Renderer.symbol(Areas.RockC);
1222 break;
1223 case LEV_AWSH:
1224 Renderer.symbol(Areas.RockA);
1225 break;
1226 default:
1227 Renderer.symbol(Areas.Rock);
1228 }
1229 } else {
1230 Renderer.symbol(Areas.Rock);
1231 }
1232 }
1233
1234 private static void pipelines() {
1235 if ((Renderer.zoom >= 16) && (feature.geom.length < 2)) {
1236 if (feature.type == Obj.PIPSOL) {
1237 Renderer.lineSymbols(Areas.Pipeline, 1.0, null, null, 0, Symbols.Mline);
1238 } else if (feature.type == Obj.PIPOHD) {
1239 Renderer.lineVector(new LineStyle(Color.black, 8));
1240 AttMap atts = feature.atts;
1241 double verclr = 0;
1242 if (atts != null) {
1243 if (atts.containsKey(Att.VERCLR)) {
1244 verclr = (Double) atts.get(Att.VERCLR).val;
1245 } else {
1246 verclr = atts.containsKey(Att.VERCSA) ? (Double) atts.get(Att.VERCSA).val : 0;
1247 }
1248 if (verclr > 0) {
1249 Renderer.labelText(String.valueOf(verclr), new Font("Arial", Font.PLAIN, 50), Color.black, LabelStyle.VCLR, Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 25)));
1250 }
1251 }
1252 }
1253 }
1254 }
1255
1256 @SuppressWarnings("unchecked")
1257 private static void platforms() {
1258 ArrayList<CatOFP> cats = (ArrayList<CatOFP>) getAttList(Obj.OFSPLF, Att.CATOFP);
1259 if (cats.get(0) == CatOFP.OFP_FPSO)
1260 Renderer.symbol(Buoys.Storage);
1261 else
1262 Renderer.symbol(Landmarks.Platform);
1263 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50)));
1264 Signals.addSignals();
1265 }
1266
1267 private static void ports() {
1268 if (Renderer.zoom >= 14) {
1269 if (feature.type == Obj.CRANES) {
1270 if ((CatCRN) getAttEnum(feature.type, Att.CATCRN) == CatCRN.CRN_CONT)
1271 Renderer.symbol(Harbours.ContainerCrane);
1272 else
1273 Renderer.symbol(Harbours.PortCrane);
1274 } else if (feature.type == Obj.HULKES) {
1275 Renderer.lineVector(new LineStyle(Color.black, 4, null, new Color(0xffe000)));
1276 addName(15, new Font("Arial", Font.BOLD, 40));
1277 }
1278 }
1279 }
1280
1281 private static void separation() {
1282 switch (feature.type) {
1283 case TSEZNE:
1284 case TSSCRS:
1285 case TSSRON:
1286 if (Renderer.zoom <= 15)
1287 Renderer.lineVector(new LineStyle(Symbols.Mtss));
1288 else
1289 Renderer.lineVector(new LineStyle(Symbols.Mtss, 20, null, null));
1290 addName(10, new Font("Arial", Font.BOLD, 150), Symbols.Mline);
1291 break;
1292 case TSELNE:
1293 Renderer.lineVector(new LineStyle(Symbols.Mtss, 20, null, null));
1294 break;
1295 case TSSLPT:
1296 Renderer.lineSymbols(Areas.LaneArrow, 0.5, null, null, 0, Symbols.Mtss);
1297 break;
1298 case TSSBND:
1299 Renderer.lineVector(new LineStyle(Symbols.Mtss, 20, new float[] { 40, 40 }, null));
1300 break;
1301 case ISTZNE:
1302 Renderer.lineSymbols(Areas.Restricted, 1.0, null, null, 0, Symbols.Mtss);
1303 break;
1304 default:
1305 break;
1306 }
1307 }
1308
1309 @SuppressWarnings("unchecked")
1310 private static void shoreline() {
1311 CatSLC cat = (CatSLC) getAttEnum(feature.type, Att.CATSLC);
1312 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) {
1313 if ((cat != CatSLC.SLC_SWAY) && (cat != CatSLC.SLC_TWAL)) {
1314 if (Renderer.zoom >= 12) {
1315 Renderer.lineVector(new LineStyle(Color.black, 10, Symbols.Yland));
1316 } else {
1317 Renderer.lineVector(new LineStyle(Symbols.Yland));
1318 }
1319 }
1320 }
1321 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.SEAMARK)) {
1322 if (Renderer.zoom >= 12) {
1323 switch (cat) {
1324 case SLC_TWAL:
1325 WatLEV lev = (WatLEV) getAttEnum(feature.type, Att.WATLEV);
1326 if (lev == WatLEV.LEV_CVRS) {
1327 Renderer.lineVector(new LineStyle(Color.black, 10, new float[] { 40, 40 }, null));
1328 if (Renderer.zoom >= 15)
1329 Renderer.lineText("(covers)", new Font("Arial", Font.PLAIN, 60), Color.black, 80);
1330 } else {
1331 Renderer.lineVector(new LineStyle(Color.black, 10, null, null));
1332 }
1333 if (Renderer.zoom >= 15)
1334 Renderer.lineText("Training Wall", new Font("Arial", Font.PLAIN, 60), Color.black, -30);
1335 break;
1336 case SLC_SWAY:
1337 Renderer.lineVector(new LineStyle(Color.black, 2, null, new Color(0xffe000)));
1338 if ((Renderer.zoom >= 16) && feature.objs.containsKey(Obj.SMCFAC)) {
1339 ArrayList<Symbol> symbols = new ArrayList<>();
1340 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttList(Obj.SMCFAC, Att.CATSCF);
1341 for (CatSCF scf : scfs) {
1342 symbols.add(Facilities.Cats.get(scf));
1343 }
1344 Renderer.cluster(symbols);
1345 }
1346 break;
1347 default:
1348 break;
1349 }
1350 }
1351 }
1352 }
1353
1354 @SuppressWarnings("unchecked")
1355 private static void stations() {
1356 if (Renderer.zoom >= 14) {
1357 String str = "";
1358 switch (feature.type) {
1359 case SISTAT:
1360 Renderer.symbol(Harbours.SignalStation);
1361 str = "SS";
1362 ArrayList<CatSIT> tcats = (ArrayList<CatSIT>) getAttList(Obj.SISTAT, Att.CATSIT);
1363 switch (tcats.get(0)) {
1364 case SIT_IPT:
1365 str += "(INT)";
1366 break;
1367 case SIT_PRTE:
1368 str += "(Traffic)";
1369 break;
1370 case SIT_PRTC:
1371 str += "(Port Control)";
1372 break;
1373 case SIT_LOCK:
1374 str += "(Lock)";
1375 break;
1376 case SIT_BRDG:
1377 str += "(Bridge)";
1378 break;
1379 default:
1380 break;
1381 }
1382 break;
1383 case SISTAW:
1384 Renderer.symbol(Harbours.SignalStation);
1385 str = "SS";
1386 str = "SS";
1387 ArrayList<CatSIW> wcats = (ArrayList<CatSIW>) getAttList(Obj.SISTAW, Att.CATSIW);
1388 switch (wcats.get(0)) {
1389 case SIW_STRM:
1390 str += "(Storm)";
1391 break;
1392 case SIW_WTHR:
1393 str += "(Weather)";
1394 break;
1395 case SIW_ICE:
1396 str += "(Ice)";
1397 break;
1398 case SIW_TIDG:
1399 str = "Tide gauge";
1400 break;
1401 case SIW_TIDS:
1402 str = "Tide scale";
1403 break;
1404 case SIW_TIDE:
1405 str += "(Tide)";
1406 break;
1407 case SIW_TSTR:
1408 str += "(Stream)";
1409 break;
1410 case SIW_DNGR:
1411 str += "(Danger)";
1412 break;
1413 case SIW_MILY:
1414 str += "(Firing)";
1415 break;
1416 case SIW_TIME:
1417 str += "(Time)";
1418 break;
1419 default:
1420 break;
1421 }
1422 break;
1423 case RDOSTA:
1424 case RTPBCN:
1425 Renderer.symbol(Harbours.SignalStation);
1426 Renderer.symbol(Beacons.RadarStation);
1427 break;
1428 case RADRFL:
1429 Renderer.symbol(Topmarks.RadarReflector);
1430 break;
1431 case RADSTA:
1432 Renderer.symbol(Harbours.SignalStation);
1433 Renderer.symbol(Beacons.RadarStation);
1434 Renderer.labelText("Ra", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
1435 break;
1436 case PILBOP:
1437 Renderer.symbol(Harbours.Pilot);
1438 addName(15, new Font("Arial", Font.BOLD, 40), Symbols.Msymb, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, -40)));
1439 CatPIL cat = (CatPIL) getAttEnum(feature.type, Att.CATPIL);
1440 if (cat == CatPIL.PIL_HELI) {
1441 Renderer.labelText("H", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, 0)));
1442 }
1443 break;
1444 case CGUSTA:
1445 Renderer.symbol(Harbours.SignalStation);
1446 str = "CG";
1447 if (feature.objs.containsKey(Obj.RSCSTA))
1448 Renderer.symbol(Harbours.Rescue, new Delta(Handle.CC, AffineTransform.getTranslateInstance(130, 0)));
1449 break;
1450 case RSCSTA:
1451 Renderer.symbol(Harbours.Rescue);
1452 break;
1453 default:
1454 break;
1455 }
1456 if ((Renderer.zoom >= 15) && !str.isEmpty()) {
1457 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.LC, AffineTransform.getTranslateInstance(40, 0)));
1458 }
1459 Signals.addSignals();
1460 }
1461 }
1462
1463 private static void transits() {
1464 if (Renderer.zoom >= 14) {
1465 if (feature.type == Obj.RECTRC)
1466 Renderer.lineVector(new LineStyle(Color.black, 10, null, null));
1467 else if (feature.type == Obj.NAVLNE)
1468 Renderer.lineVector(new LineStyle(Color.black, 10, new float[] { 25, 25 }, null));
1469 }
1470 if (Renderer.zoom >= 15) {
1471 String str = "";
1472 String name = getName();
1473 if (name != null)
1474 str += name + " ";
1475 Double ort;
1476 if ((ort = (Double) getAttVal(feature.type, Att.ORIENT)) != null) {
1477 str += df.format(ort) + "º";
1478 if (!str.isEmpty())
1479 Renderer.lineText(str, new Font("Arial", Font.PLAIN, 80), Color.black, -20);
1480 }
1481 }
1482 }
1483
1484 private static void waterways() {
1485 Renderer.lineVector(new LineStyle(Symbols.Bwater, 20, (feature.geom.prim == Pflag.AREA) ? Symbols.Bwater : null));
1486 }
1487
1488 private static void wrecks() {
1489 if (Renderer.zoom >= 14) {
1490 switch ((CatWRK) getAttEnum(feature.type, Att.CATWRK)) {
1491 case WRK_DNGR:
1492 case WRK_MSTS:
1493 Renderer.symbol(Areas.WreckD);
1494 break;
1495 case WRK_HULS:
1496 Renderer.symbol(Areas.WreckS);
1497 break;
1498 default:
1499 Renderer.symbol(Areas.WreckND);
1500 }
1501 }
1502 }
1503}
Note: See TracBrowser for help on using the repository browser.