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

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

[Seachart] Publish new release

File size: 52.6 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)))
530 || ((Renderer.zoom >= 11) && ((feature.type == Obj.BCNSAW) || hasObject(Obj.RTPBCN)))) {
531 if (testAttribute(feature.type, Att.STATUS, StsSTS.STS_ILLD)) {
532 Renderer.symbol(Beacons.Floodlight);
533 }
534 BcnSHP shape = (BcnSHP) getAttEnum(feature.type, Att.BCNSHP);
535 if (shape == BcnSHP.BCN_UNKN)
536 shape = BcnSHP.BCN_PILE;
537 if ((shape == BcnSHP.BCN_WTHY) && (feature.type == Obj.BCNLAT)) {
538 switch ((CatLAM) getAttEnum(feature.type, Att.CATLAM)) {
539 case LAM_PORT:
540 Renderer.symbol(Beacons.WithyPort);
541 break;
542 case LAM_STBD:
543 Renderer.symbol(Beacons.WithyStarboard);
544 break;
545 default:
546 Renderer.symbol(Beacons.Stake, getScheme(feature.type));
547 }
548 } else if ((shape == BcnSHP.BCN_PRCH) && (feature.type == Obj.BCNLAT) && !(feature.objs.containsKey(Obj.TOPMAR))) {
549 switch ((CatLAM) getAttEnum(feature.type, Att.CATLAM)) {
550 case LAM_PORT:
551 Renderer.symbol(Beacons.PerchPort);
552 break;
553 case LAM_STBD:
554 Renderer.symbol(Beacons.PerchStarboard);
555 break;
556 default:
557 Renderer.symbol(Beacons.Stake, getScheme(feature.type));
558 }
559 } else {
560 Renderer.symbol(Beacons.Shapes.get(shape), getScheme(feature.type));
561 if (feature.objs.containsKey(Obj.TOPMAR)) {
562 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
563 if (testAttribute(Obj.TOPMAR, Att.STATUS, StsSTS.STS_ILLD)) {
564 Renderer.symbol(Beacons.Floodlight);
565 }
566 if (topmap.containsKey(Att.TOPSHP)) {
567 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.BeaconDelta);
568 }
569 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
570 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
571 if (topmap.containsKey(Att.TOPSHP)) {
572 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.BeaconDelta);
573 }
574 }
575 }
576 if (hasObject(Obj.NOTMRK))
577 notices();
578 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
579 Signals.addSignals();
580 }
581 }
582
583 @SuppressWarnings("unchecked")
584 private static void buoys() {
585 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)))) {
586 BoySHP shape = (BoySHP) getAttEnum(feature.type, Att.BOYSHP);
587 if (shape == BoySHP.BOY_UNKN)
588 shape = BoySHP.BOY_PILR;
589 Renderer.symbol(Buoys.Shapes.get(shape), getScheme(feature.type));
590 if (feature.objs.containsKey(Obj.TOPMAR)) {
591 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
592 if (topmap.containsKey(Att.TOPSHP)) {
593 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.BuoyDeltas.get(shape));
594 }
595 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
596 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
597 if (topmap.containsKey(Att.TOPSHP)) {
598 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.BuoyDeltas.get(shape));
599 }
600 }
601 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
602 Signals.addSignals();
603 }
604 }
605
606 private static void bridges() {
607 if (Renderer.zoom >= 16) {
608 double verclr, verccl, vercop, horclr;
609 AttMap atts = feature.objs.get(Obj.BRIDGE).get(0);
610 String vstr = "";
611 String hstr = "";
612 if (atts != null) {
613 if (atts.containsKey(Att.HORCLR)) {
614 horclr = (Double) atts.get(Att.HORCLR).val;
615 hstr = String.valueOf(horclr);
616 }
617 if (atts.containsKey(Att.VERCLR)) {
618 verclr = (Double) atts.get(Att.VERCLR).val;
619 } else {
620 verclr = atts.containsKey(Att.VERCSA) ? (Double) atts.get(Att.VERCSA).val : 0;
621 }
622 verccl = atts.containsKey(Att.VERCCL) ? (Double) atts.get(Att.VERCCL).val : 0;
623 vercop = atts.containsKey(Att.VERCOP) ? (Double) atts.get(Att.VERCOP).val : 0;
624 if (verclr > 0) {
625 vstr += String.valueOf(verclr);
626 } else if (verccl > 0) {
627 if (vercop == 0) {
628 vstr += String.valueOf(verccl) + "/-";
629 } else {
630 vstr += String.valueOf(verccl) + "/" + String.valueOf(vercop);
631 }
632 }
633 if (hstr.isEmpty() && !vstr.isEmpty()) {
634 Renderer.labelText(vstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.VCLR, Color.black, Color.white, new Delta(Handle.CC));
635 } else if (!hstr.isEmpty() && !vstr.isEmpty()) {
636 Renderer.labelText(vstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.VCLR, Color.black, Color.white, new Delta(Handle.BC));
637 Renderer.labelText(hstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.HCLR, Color.black, Color.white, new Delta(Handle.TC));
638 } else if (!hstr.isEmpty() && vstr.isEmpty()) {
639 Renderer.labelText(hstr, new Font("Arial", Font.PLAIN, 30), Color.black, LabelStyle.HCLR, Color.black, Color.white, new Delta(Handle.CC));
640 }
641 }
642 }
643 }
644
645 private static void cables() {
646 if ((Renderer.zoom >= 16) && (feature.geom.length < 2)) {
647 if (feature.type == Obj.CBLSUB) {
648 Renderer.lineSymbols(Areas.Cable, 0.0, null, null, 0, Symbols.Mline);
649 } else if (feature.type == Obj.CBLOHD) {
650 AttMap atts = feature.objs.get(Obj.CBLOHD).get(0);
651 if ((atts != null) && (atts.containsKey(Att.CATCBL)) && (atts.get(Att.CATCBL).val == CatCBL.CBL_POWR)) {
652 Renderer.lineSymbols(Areas.CableDash, 0, Areas.CableDot, Areas.CableFlash, 2, Color.black);
653 } else {
654 Renderer.lineSymbols(Areas.CableDash, 0, Areas.CableDot, null, 2, Color.black);
655 }
656 if (atts != null) {
657 if (atts.containsKey(Att.VERCLR)) {
658 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)));
659 } else if (atts.containsKey(Att.VERCSA)) {
660 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)));
661 }
662 }
663 }
664 }
665 }
666
667 private static void callpoint() {
668 if (Renderer.zoom >= 14) {
669 Symbol symb = Harbours.CallPoint2;
670 TrfTRF trf = (TrfTRF) getAttEnum(feature.type, Att.TRAFIC);
671 if (trf != TrfTRF.TRF_TWOW) {
672 symb = Harbours.CallPoint1;
673 }
674 Double orient = 0.0;
675 if ((orient = (Double) getAttVal(feature.type, Att.ORIENT)) == null) {
676 orient = 0.0;
677 }
678 Renderer.symbol(symb, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(orient))));
679 String chn;
680 if (!(chn = getAttStr(feature.type, Att.COMCHA)).isEmpty()) {
681 Renderer.labelText(("Ch." + chn), new Font("Arial", Font.PLAIN, 50), Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 50)));
682 }
683 }
684 }
685
686 private static void depths() {
687 switch (feature.type) {
688 case SOUNDG:
689 if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
690 double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
691 String dstr = df.format(depth);
692 String[] tok = dstr.split("[-.]");
693 String ul = "";
694 String id = tok[0];
695 String dd = "";
696 if (tok[0].equals("")) {
697 for (int i = 0; i < tok[1].length(); i++) {
698 ul += "_";
699 }
700 id = tok[1];
701 dd = (tok.length == 3) ? tok[2] : "";
702 } else {
703 dd = (tok.length == 2) ? tok[1] : "";
704 }
705 Renderer.labelText(ul, new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.RC, AffineTransform.getTranslateInstance(10, 15)));
706 Renderer.labelText(id, new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.RC, AffineTransform.getTranslateInstance(10, 0)));
707 Renderer.labelText(dd, new Font("Arial", Font.PLAIN, 20), Color.black, new Delta(Handle.LC, AffineTransform.getTranslateInstance(15, 10)));
708 }
709 break;
710 case DEPCNT:
711 break;
712 default:
713 break;
714 }
715 }
716
717 private static void distances() {
718 if (Renderer.zoom >= 14) {
719 if (!testAttribute(Obj.DISMAR, Att.CATDIS, CatDIS.DIS_NONI)) {
720 Renderer.symbol(Harbours.DistanceI);
721 } else {
722 Renderer.symbol(Harbours.DistanceU);
723 }
724 if (Renderer.zoom >= 15) {
725 AttMap atts = getAtts(Obj.DISMAR, 0);
726 if ((atts != null) && (atts.containsKey(Att.WTWDIS))) {
727 Double dist = (Double) atts.get(Att.WTWDIS).val;
728 String str = "";
729 if (atts.containsKey(Att.HUNITS)) {
730 switch ((UniHLU) getAttEnum(Obj.DISMAR, Att.HUNITS)) {
731 case HLU_METR:
732 str += "m ";
733 break;
734 case HLU_FEET:
735 str += "ft ";
736 break;
737 case HLU_HMTR:
738 str += "hm ";
739 break;
740 case HLU_KMTR:
741 str += "km ";
742 break;
743 case HLU_SMIL:
744 str += "M ";
745 break;
746 case HLU_NMIL:
747 str += "NM ";
748 break;
749 default:
750 break;
751 }
752 }
753 str += String.format("%1.0f", dist);
754 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 45)));
755 }
756 }
757 }
758 }
759
760 @SuppressWarnings("unchecked")
761 private static void floats() {
762 if ((Renderer.zoom >= 12) || ((Renderer.zoom >= 11) && ((feature.type == Obj.LITVES) || (feature.type == Obj.BOYINB) || hasObject(Obj.RTPBCN)))) {
763 switch (feature.type) {
764 case LITVES:
765 Renderer.symbol(Buoys.Super, getScheme(feature.type));
766 break;
767 case LITFLT:
768 Renderer.symbol(Buoys.Float, getScheme(feature.type));
769 break;
770 case BOYINB:
771 Renderer.symbol(Buoys.Super, getScheme(feature.type));
772 break;
773 default:
774 break;
775 }
776 if (feature.objs.containsKey(Obj.TOPMAR)) {
777 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
778 if (topmap.containsKey(Att.TOPSHP)) {
779 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.FloatDelta);
780 }
781 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
782 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
783 if (topmap.containsKey(Att.TOPSHP)) {
784 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.FloatDelta);
785 }
786 }
787 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50)));
788 Signals.addSignals();
789 }
790 }
791
792 private static void gauges() {
793 if (Renderer.zoom >= 14) {
794 Renderer.symbol(Harbours.TideGauge);
795 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50)));
796 Signals.addSignals();
797 }
798 }
799
800 @SuppressWarnings("unchecked")
801 private static void harbours() {
802 String name = getName();
803 switch (feature.type) {
804 case ACHBRT:
805 if (Renderer.zoom >= 14) {
806 Renderer.symbol(Harbours.Anchor, new Scheme(Symbols.Msymb));
807 if (Renderer.zoom >= 15) {
808 Renderer.labelText(name == null ? "" : name, new Font("Arial", Font.PLAIN, 30), Symbols.Msymb, LabelStyle.RRCT, Symbols.Msymb, Color.white, new Delta(Handle.BC));
809 }
810 }
811 if (getAttVal(Obj.ACHBRT, Att.RADIUS) != null) {
812 double radius;
813 if ((radius = (Double) getAttVal(Obj.ACHBRT, Att.RADIUS)) != 0) {
814 UniHLU units = (UniHLU) getAttEnum(Obj.ACHBRT, Att.HUNITS);
815 if (units == UniHLU.HLU_UNKN) {
816 units = UniHLU.HLU_METR;
817 }
818 Renderer.lineCircle(new LineStyle(Symbols.Mline, 4, new float[] { 10, 10 }, null), radius, units);
819 }
820 }
821 break;
822 case ACHARE:
823 if (Renderer.zoom >= 12) {
824 if (feature.geom.prim != Pflag.AREA) {
825 Renderer.symbol(Harbours.Anchorage, new Scheme(Color.black));
826 } else {
827 Renderer.symbol(Harbours.Anchorage, new Scheme(Symbols.Mline));
828 Renderer.lineSymbols(Areas.Restricted, 1.0, Areas.LineAnchor, null, 10, Symbols.Mline);
829 }
830 addName(15, new Font("Arial", Font.BOLD, 60), Symbols.Mline, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, 0)));
831 ArrayList<StsSTS> sts = (ArrayList<StsSTS>) getAttList(Obj.ACHARE, Att.STATUS);
832 if ((Renderer.zoom >= 15) && (sts.contains(StsSTS.STS_RESV))) {
833 Renderer.labelText("Reserved", new Font("Arial", Font.PLAIN, 50), Symbols.Mline, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 60)));
834 }
835 ArrayList<CatACH> cats = (ArrayList<CatACH>) getAttList(Obj.ACHARE, Att.CATACH);
836 int dy = (cats.size() - 1) * -30;
837 for (CatACH cat : cats) {
838 switch (cat) {
839 case ACH_DEEP:
840 Renderer.labelText("DW", new Font("Arial", Font.BOLD, 50), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
841 dy += 60;
842 break;
843 case ACH_TANK:
844 Renderer.labelText("Tanker", new Font("Arial", Font.BOLD, 50), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
845 dy += 60;
846 break;
847 case ACH_H24P:
848 Renderer.labelText("24h", new Font("Arial", Font.BOLD, 50), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
849 dy += 60;
850 break;
851 case ACH_EXPL:
852 Renderer.symbol(Harbours.Explosives, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
853 dy += 60;
854 break;
855 case ACH_QUAR:
856 Renderer.symbol(Harbours.Hospital, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
857 dy += 60;
858 break;
859 case ACH_SEAP:
860 Renderer.symbol(Areas.Seaplane, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
861 dy += 60;
862 break;
863 default:
864 }
865 }
866 }
867 break;
868 case BERTHS:
869 if (Renderer.zoom >= 14) {
870 Renderer.lineVector(new LineStyle(Symbols.Mline, 6, new float[] { 20, 20 }));
871 Renderer.labelText(name == null ? " " : name, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, LabelStyle.RRCT, Symbols.Mline, Color.white);
872 }
873 break;
874 case BUISGL:
875 if (Renderer.zoom >= 16) {
876 if (testAttribute(Obj.BUISGL, Att.STATUS, StsSTS.STS_ILLD)) {
877 Renderer.symbol(Beacons.Floodlight);
878 }
879 ArrayList<Symbol> symbols = new ArrayList<>();
880 ArrayList<FncFNC> fncs = (ArrayList<FncFNC>) getAttList(Obj.BUISGL, Att.FUNCTN);
881 for (FncFNC fnc : fncs) {
882 symbols.add(Landmarks.Funcs.get(fnc));
883 }
884 if (feature.objs.containsKey(Obj.SMCFAC)) {
885 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttList(Obj.SMCFAC, Att.CATSCF);
886 for (CatSCF scf : scfs) {
887 symbols.add(Facilities.Cats.get(scf));
888 }
889 }
890 Renderer.cluster(symbols);
891 }
892 break;
893 case HRBFAC:
894 if (Renderer.zoom >= 12) {
895 ArrayList<CatHAF> cathaf = (ArrayList<CatHAF>) getAttList(Obj.HRBFAC, Att.CATHAF);
896 if (cathaf.size() == 1) {
897 switch (cathaf.get(0)) {
898 case HAF_MRNA:
899 Renderer.symbol(Harbours.Marina);
900 break;
901 case HAF_MANF:
902 Renderer.symbol(Harbours.MarinaNF);
903 break;
904 case HAF_FISH:
905 Renderer.symbol(Harbours.Fishing);
906 break;
907 default:
908 Renderer.symbol(Harbours.Harbour);
909 break;
910 }
911 } else {
912 Renderer.symbol(Harbours.Harbour);
913 }
914 }
915 break;
916 default:
917 break;
918 }
919 }
920
921 @SuppressWarnings("unchecked")
922 private static void highways() {
923 switch (feature.type) {
924 case ROADWY:
925 ArrayList<CatROD> cat = (ArrayList<CatROD>) (getAttList(Obj.ROADWY, Att.CATROD));
926 if (cat.size() > 0) {
927 switch (cat.get(0)) {
928 case ROD_MWAY:
929 Renderer.lineVector(new LineStyle(Color.black, 20));
930 break;
931 case ROD_MAJR:
932 Renderer.lineVector(new LineStyle(Color.black, 15));
933 break;
934 case ROD_MINR:
935 Renderer.lineVector(new LineStyle(Color.black, 10));
936 break;
937 default:
938 Renderer.lineVector(new LineStyle(Color.black, 5));
939 }
940 } else {
941 Renderer.lineVector(new LineStyle(Color.black, 5));
942 }
943 break;
944 case RAILWY:
945 Renderer.lineVector(new LineStyle(Color.gray, 10));
946 Renderer.lineVector(new LineStyle(Color.black, 10, new float[] { 30, 30 }));
947 break;
948 default:
949 }
950 }
951
952 @SuppressWarnings("unchecked")
953 private static void landmarks() {
954 if (!hasAttribute(Obj.LNDMRK, Att.CATLMK) && (!hasAttribute(Obj.LNDMRK, Att.FUNCTN) || testAttribute(Obj.LNDMRK, Att.FUNCTN, FncFNC.FNC_LGHT)) && hasObject(Obj.LIGHTS))
955 lights();
956 else if (Renderer.zoom >= 12) {
957 switch (feature.type) {
958 case LNDMRK:
959 if (testAttribute(Obj.LNDMRK, Att.STATUS, StsSTS.STS_ILLD)) {
960 Renderer.symbol(Beacons.Floodlight);
961 }
962 ArrayList<CatLMK> cats = (ArrayList<CatLMK>) getAttList(feature.type, Att.CATLMK);
963 Symbol catSym = Landmarks.Shapes.get(cats.get(0));
964 ArrayList<FncFNC> fncs = (ArrayList<FncFNC>) getAttList(feature.type, Att.FUNCTN);
965 Symbol fncSym = Landmarks.Funcs.get(fncs.get(0));
966 if ((fncs.get(0) == FncFNC.FNC_CHCH) && (cats.get(0) == CatLMK.LMK_TOWR))
967 catSym = Landmarks.ChurchTower;
968 if (cats.get(0) == CatLMK.LMK_RADR)
969 fncSym = Landmarks.RadioTV;
970 Renderer.symbol(catSym);
971 Renderer.symbol(fncSym);
972 break;
973 case SILTNK:
974 if (testAttribute(feature.type, Att.CATSIL, CatSIL.SIL_WTRT))
975 Renderer.symbol(Landmarks.WaterTower);
976 break;
977 default:
978 break;
979 }
980 if (Renderer.zoom >= 15)
981 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
982 Signals.addSignals();
983 }
984 }
985
986 @SuppressWarnings("unchecked")
987 private static void lights() {
988 boolean ok = false;
989 switch (feature.type) {
990 case LITMAJ:
991 case LNDMRK:
992 if (Renderer.zoom >= 12) {
993 Renderer.symbol(Beacons.LightMajor);
994 ok = true;
995 }
996 break;
997 case LITMIN:
998 case LIGHTS:
999 case PILPNT:
1000 if (Renderer.zoom >= 14) {
1001 if (testAttribute(Obj.LIGHTS, Att.CATLIT, CatLIT.LIT_FLDL)) {
1002 Renderer.symbol(Beacons.Floodlight, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(90))));
1003 Renderer.symbol(Harbours.SignalStation);
1004 } else {
1005 Renderer.symbol(Beacons.LightMinor);
1006 }
1007 ok = true;
1008 }
1009 break;
1010 default:
1011 break;
1012 }
1013 if (ok) {
1014 if (feature.objs.containsKey(Obj.TOPMAR)) {
1015 if (testAttribute(Obj.TOPMAR, Att.STATUS, StsSTS.STS_ILLD)) {
1016 Renderer.symbol(Beacons.Floodlight);
1017 }
1018 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
1019 if (topmap.containsKey(Att.TOPSHP)) {
1020 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), Topmarks.LightDelta);
1021 }
1022 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
1023 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
1024 if (topmap.containsKey(Att.TOPSHP)) {
1025 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), Topmarks.LightDelta);
1026 }
1027 }
1028 Signals.addSignals();
1029 }
1030 }
1031
1032 @SuppressWarnings("unchecked")
1033 private static void marinas() {
1034 if (Renderer.zoom >= 16) {
1035 ArrayList<Symbol> symbols = new ArrayList<>();
1036 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttList(Obj.SMCFAC, Att.CATSCF);
1037 for (CatSCF scf : scfs) {
1038 symbols.add(Facilities.Cats.get(scf));
1039 }
1040 Renderer.cluster(symbols);
1041 }
1042 }
1043
1044 private static void moorings() {
1045 if (Renderer.zoom >= 14) {
1046 switch ((CatMOR) getAttEnum(feature.type, Att.CATMOR)) {
1047 case MOR_DLPN:
1048 Renderer.symbol(Harbours.Dolphin);
1049 break;
1050 case MOR_DDPN:
1051 Renderer.symbol(Harbours.DeviationDolphin);
1052 break;
1053 case MOR_BLRD:
1054 case MOR_POST:
1055 Renderer.symbol(Harbours.Bollard);
1056 break;
1057 case MOR_BUOY:
1058 BoySHP shape = (BoySHP) getAttEnum(feature.type, Att.BOYSHP);
1059 if (shape == BoySHP.BOY_UNKN) {
1060 shape = BoySHP.BOY_SPHR;
1061 }
1062 Renderer.symbol(Buoys.Shapes.get(shape), getScheme(feature.type));
1063 Renderer.symbol(Topmarks.TopMooring, Topmarks.BuoyDeltas.get(shape));
1064 break;
1065 default:
1066 break;
1067 }
1068 Signals.addSignals();
1069 }
1070 }
1071
1072 @SuppressWarnings("unchecked")
1073 private static void notices() {
1074 if (Renderer.zoom >= 14) {
1075 double dx = 0.0, dy = 0.0;
1076 switch (feature.type) {
1077 case BCNCAR:
1078 case BCNISD:
1079 case BCNLAT:
1080 case BCNSAW:
1081 case BCNSPP:
1082 if (testAttribute(Obj.TOPMAR, Att.TOPSHP, TopSHP.TOP_BORD) || testAttribute(Obj.DAYMAR, Att.TOPSHP, TopSHP.TOP_BORD)) {
1083 dy = -100.0;
1084 } else {
1085 dy = -45.0;
1086 }
1087 break;
1088 case NOTMRK:
1089 dy = 0.0;
1090 break;
1091 default:
1092 return;
1093 }
1094 MarSYS sys = MarSYS.SYS_CEVN;
1095 BnkWTW bnk = BnkWTW.BWW_UNKN;
1096 AttVal<?> att = feature.atts.get(Att.MARSYS);
1097 if (att != null)
1098 sys = (MarSYS) att.val;
1099 att = feature.atts.get(Att.BNKWTW);
1100 if (att != null)
1101 bnk = (BnkWTW) att.val;
1102 ObjTab objs = feature.objs.get(Obj.NOTMRK);
1103 int n = objs.size();
1104 if (n > 5) {
1105 Renderer.symbol(Notices.Notice, new Delta(Handle.CC, AffineTransform.getTranslateInstance(dx, dy)));
1106 } else {
1107 int i = 0;
1108 for (AttMap atts : objs.values()) {
1109 if (atts.get(Att.MARSYS) != null)
1110 sys = ((ArrayList<MarSYS>) (atts.get(Att.MARSYS).val)).get(0);
1111 if (atts.get(Att.BNKWTW) != null)
1112 bnk = ((ArrayList<BnkWTW>) (atts.get(Att.BNKWTW).val)).get(0);
1113 CatNMK cat = CatNMK.NMK_UNKN;
1114 if (atts.get(Att.CATNMK) != null)
1115 cat = ((ArrayList<CatNMK>) (atts.get(Att.CATNMK).val)).get(0);
1116 Symbol sym = Notices.getNotice(cat, sys, bnk);
1117 Scheme sch = Notices.getScheme(sys, bnk);
1118 ArrayList<AddMRK> add = new ArrayList<>();
1119 if (atts.get(Att.ADDMRK) != null)
1120 add = (ArrayList<AddMRK>) (atts.get(Att.ADDMRK).val);
1121 Handle h = Handle.CC;
1122 double ax = 0.0;
1123 double ay = 0.0;
1124 switch (i) {
1125 case 0:
1126 if (n != 1)
1127 h = null;
1128 break;
1129 case 1:
1130 if (n <= 3) {
1131 h = Handle.RC;
1132 ax = -30;
1133 ay = dy;
1134 } else {
1135 h = Handle.BR;
1136 }
1137 break;
1138 case 2:
1139 if (n <= 3)
1140 h = Handle.LC;
1141 else
1142 h = Handle.BL;
1143 break;
1144 case 3:
1145 if (n == 4)
1146 h = Handle.TC;
1147 else
1148 h = Handle.TR;
1149 break;
1150 case 4:
1151 h = Handle.TL;
1152 break;
1153 }
1154 if (h != null) {
1155 Renderer.symbol(sym, sch, new Delta(h, AffineTransform.getTranslateInstance(dx, dy)));
1156 if (!add.isEmpty())
1157 Renderer.symbol(Notices.NoticeBoard, new Delta(Handle.BC, AffineTransform.getTranslateInstance(ax, ay - 30)));
1158 }
1159 i++;
1160 }
1161 }
1162 }
1163 }
1164
1165 private static void obstructions() {
1166 if ((Renderer.zoom >= 12) && (feature.type == Obj.OBSTRN)) {
1167 if (getAttEnum(feature.type, Att.CATOBS) == CatOBS.OBS_BOOM) {
1168 Renderer.lineVector(new LineStyle(Color.black, 5, new float[] { 20, 20 }, null));
1169 if (Renderer.zoom >= 15) {
1170 Renderer.lineText("Boom", new Font("Arial", Font.PLAIN, 80), Color.black, -20);
1171 }
1172 }
1173 }
1174 if ((Renderer.zoom >= 14) && (feature.type == Obj.UWTROC)) {
1175 switch ((WatLEV) getAttEnum(feature.type, Att.WATLEV)) {
1176 case LEV_CVRS:
1177 Renderer.symbol(Areas.RockC);
1178 break;
1179 case LEV_AWSH:
1180 Renderer.symbol(Areas.RockA);
1181 break;
1182 default:
1183 Renderer.symbol(Areas.Rock);
1184 }
1185 } else {
1186 Renderer.symbol(Areas.Rock);
1187 }
1188 }
1189
1190 private static void pipelines() {
1191 if ((Renderer.zoom >= 16) && (feature.geom.length < 2)) {
1192 if (feature.type == Obj.PIPSOL) {
1193 Renderer.lineSymbols(Areas.Pipeline, 1.0, null, null, 0, Symbols.Mline);
1194 } else if (feature.type == Obj.PIPOHD) {
1195 Renderer.lineVector(new LineStyle(Color.black, 8));
1196 AttMap atts = feature.atts;
1197 double verclr = 0;
1198 if (atts != null) {
1199 if (atts.containsKey(Att.VERCLR)) {
1200 verclr = (Double) atts.get(Att.VERCLR).val;
1201 } else {
1202 verclr = atts.containsKey(Att.VERCSA) ? (Double) atts.get(Att.VERCSA).val : 0;
1203 }
1204 if (verclr > 0) {
1205 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)));
1206 }
1207 }
1208 }
1209 }
1210 }
1211
1212 @SuppressWarnings("unchecked")
1213 private static void platforms() {
1214 ArrayList<CatOFP> cats = (ArrayList<CatOFP>) getAttList(Obj.OFSPLF, Att.CATOFP);
1215 if (cats.get(0) == CatOFP.OFP_FPSO)
1216 Renderer.symbol(Buoys.Storage);
1217 else
1218 Renderer.symbol(Landmarks.Platform);
1219 if (testAttribute(feature.type, Att.STATUS, StsSTS.STS_ILLD)) {
1220 Renderer.symbol(Beacons.Floodlight);
1221 }
1222 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50)));
1223 Signals.addSignals();
1224 }
1225
1226 @SuppressWarnings("unchecked")
1227 private static void points() {
1228 boolean ok = false;
1229 switch (feature.type) {
1230 case FOGSIG:
1231 if (Renderer.zoom >= 12) {
1232 if (feature.objs.containsKey(Obj.LIGHTS))
1233 lights();
1234 else
1235 Renderer.symbol(Harbours.Post);
1236 ok = true;
1237 }
1238 break;
1239 default:
1240 if (Renderer.zoom >= 14) {
1241 if (testAttribute(feature.type, Att.STATUS, StsSTS.STS_ILLD)) {
1242 Renderer.symbol(Beacons.Floodlight);
1243 }
1244 if (feature.objs.containsKey(Obj.LIGHTS))
1245 lights();
1246 else
1247 Renderer.symbol(Harbours.Post);
1248 ok = true;
1249 }
1250 break;
1251 }
1252 if (ok) {
1253 if (feature.objs.containsKey(Obj.TOPMAR)) {
1254 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0);
1255 if (topmap.containsKey(Att.TOPSHP)) {
1256 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.TOPMAR), null);
1257 }
1258 } else if (feature.objs.containsKey(Obj.DAYMAR)) {
1259 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0);
1260 if (topmap.containsKey(Att.TOPSHP)) {
1261 Renderer.symbol(Topmarks.Shapes.get(((ArrayList<TopSHP>) (topmap.get(Att.TOPSHP).val)).get(0)), getScheme(Obj.DAYMAR), null);
1262 }
1263 }
1264 Signals.addSignals();
1265 }
1266 }
1267
1268 private static void ports() {
1269 if (Renderer.zoom >= 14) {
1270 if (feature.type == Obj.CRANES) {
1271 if ((CatCRN) getAttEnum(feature.type, Att.CATCRN) == CatCRN.CRN_CONT)
1272 Renderer.symbol(Harbours.ContainerCrane);
1273 else
1274 Renderer.symbol(Harbours.PortCrane);
1275 } else if (feature.type == Obj.HULKES) {
1276 Renderer.lineVector(new LineStyle(Color.black, 4, null, new Color(0xffe000)));
1277 addName(15, new Font("Arial", Font.BOLD, 40));
1278 }
1279 }
1280 }
1281
1282 private static void separation() {
1283 switch (feature.type) {
1284 case TSEZNE:
1285 case TSSCRS:
1286 case TSSRON:
1287 if (Renderer.zoom <= 15)
1288 Renderer.lineVector(new LineStyle(Symbols.Mtss));
1289 else
1290 Renderer.lineVector(new LineStyle(Symbols.Mtss, 20, null, null));
1291 addName(10, new Font("Arial", Font.BOLD, 150), Symbols.Mline);
1292 break;
1293 case TSELNE:
1294 Renderer.lineVector(new LineStyle(Symbols.Mtss, 20, null, null));
1295 break;
1296 case TSSLPT:
1297 Renderer.lineSymbols(Areas.LaneArrow, 0.5, null, null, 0, Symbols.Mtss);
1298 break;
1299 case TSSBND:
1300 Renderer.lineVector(new LineStyle(Symbols.Mtss, 20, new float[] { 40, 40 }, null));
1301 break;
1302 case ISTZNE:
1303 Renderer.lineSymbols(Areas.Restricted, 1.0, null, null, 0, Symbols.Mtss);
1304 break;
1305 default:
1306 break;
1307 }
1308 }
1309
1310 @SuppressWarnings("unchecked")
1311 private static void shoreline() {
1312 CatSLC cat = (CatSLC) getAttEnum(feature.type, Att.CATSLC);
1313 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) {
1314 if ((cat != CatSLC.SLC_SWAY) && (cat != CatSLC.SLC_TWAL)) {
1315 if (Renderer.zoom >= 12) {
1316 Renderer.lineVector(new LineStyle(Color.black, 10, Symbols.Yland));
1317 } else {
1318 Renderer.lineVector(new LineStyle(Symbols.Yland));
1319 }
1320 }
1321 }
1322 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.SEAMARK)) {
1323 if (Renderer.zoom >= 12) {
1324 switch (cat) {
1325 case SLC_TWAL:
1326 WatLEV lev = (WatLEV) getAttEnum(feature.type, Att.WATLEV);
1327 if (lev == WatLEV.LEV_CVRS) {
1328 Renderer.lineVector(new LineStyle(Color.black, 10, new float[] { 40, 40 }, null));
1329 if (Renderer.zoom >= 15)
1330 Renderer.lineText("(covers)", new Font("Arial", Font.PLAIN, 60), Color.black, 80);
1331 } else {
1332 Renderer.lineVector(new LineStyle(Color.black, 10, null, null));
1333 }
1334 if (Renderer.zoom >= 15)
1335 Renderer.lineText("Training Wall", new Font("Arial", Font.PLAIN, 60), Color.black, -30);
1336 break;
1337 case SLC_SWAY:
1338 Renderer.lineVector(new LineStyle(Color.black, 2, null, new Color(0xffe000)));
1339 if ((Renderer.zoom >= 16) && feature.objs.containsKey(Obj.SMCFAC)) {
1340 ArrayList<Symbol> symbols = new ArrayList<>();
1341 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttList(Obj.SMCFAC, Att.CATSCF);
1342 for (CatSCF scf : scfs) {
1343 symbols.add(Facilities.Cats.get(scf));
1344 }
1345 Renderer.cluster(symbols);
1346 }
1347 break;
1348 default:
1349 break;
1350 }
1351 }
1352 }
1353 }
1354
1355 @SuppressWarnings("unchecked")
1356 private static void stations() {
1357 if (Renderer.zoom >= 14) {
1358 String str = "";
1359 switch (feature.type) {
1360 case SISTAT:
1361 Renderer.symbol(Harbours.SignalStation);
1362 str = "SS";
1363 ArrayList<CatSIT> tcats = (ArrayList<CatSIT>) getAttList(Obj.SISTAT, Att.CATSIT);
1364 switch (tcats.get(0)) {
1365 case SIT_IPT:
1366 str += "(INT)";
1367 break;
1368 case SIT_PRTE:
1369 str += "(Traffic)";
1370 break;
1371 case SIT_PRTC:
1372 str += "(Port Control)";
1373 break;
1374 case SIT_LOCK:
1375 str += "(Lock)";
1376 break;
1377 case SIT_BRDG:
1378 str += "(Bridge)";
1379 break;
1380 default:
1381 break;
1382 }
1383 break;
1384 case SISTAW:
1385 Renderer.symbol(Harbours.SignalStation);
1386 str = "SS";
1387 str = "SS";
1388 ArrayList<CatSIW> wcats = (ArrayList<CatSIW>) getAttList(Obj.SISTAW, Att.CATSIW);
1389 switch (wcats.get(0)) {
1390 case SIW_STRM:
1391 str += "(Storm)";
1392 break;
1393 case SIW_WTHR:
1394 str += "(Weather)";
1395 break;
1396 case SIW_ICE:
1397 str += "(Ice)";
1398 break;
1399 case SIW_TIDG:
1400 str = "Tide gauge";
1401 break;
1402 case SIW_TIDS:
1403 str = "Tide scale";
1404 break;
1405 case SIW_TIDE:
1406 str += "(Tide)";
1407 break;
1408 case SIW_TSTR:
1409 str += "(Stream)";
1410 break;
1411 case SIW_DNGR:
1412 str += "(Danger)";
1413 break;
1414 case SIW_MILY:
1415 str += "(Firing)";
1416 break;
1417 case SIW_TIME:
1418 str += "(Time)";
1419 break;
1420 default:
1421 break;
1422 }
1423 break;
1424 case RDOSTA:
1425 case RTPBCN:
1426 Renderer.symbol(Harbours.SignalStation);
1427 Renderer.symbol(Beacons.RadarStation);
1428 break;
1429 case RADRFL:
1430 Renderer.symbol(Topmarks.RadarReflector);
1431 break;
1432 case RADSTA:
1433 Renderer.symbol(Harbours.SignalStation);
1434 Renderer.symbol(Beacons.RadarStation);
1435 Renderer.labelText("Ra", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
1436 break;
1437 case PILBOP:
1438 Renderer.symbol(Harbours.Pilot);
1439 addName(15, new Font("Arial", Font.BOLD, 40), Symbols.Msymb, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, -40)));
1440 CatPIL cat = (CatPIL) getAttEnum(feature.type, Att.CATPIL);
1441 if (cat == CatPIL.PIL_HELI) {
1442 Renderer.labelText("H", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, 0)));
1443 }
1444 break;
1445 case CGUSTA:
1446 Renderer.symbol(Harbours.SignalStation);
1447 str = "CG";
1448 if (feature.objs.containsKey(Obj.RSCSTA))
1449 Renderer.symbol(Harbours.Rescue, new Delta(Handle.CC, AffineTransform.getTranslateInstance(130, 0)));
1450 break;
1451 case RSCSTA:
1452 Renderer.symbol(Harbours.Rescue);
1453 break;
1454 default:
1455 break;
1456 }
1457 if ((Renderer.zoom >= 15) && !str.isEmpty()) {
1458 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.LC, AffineTransform.getTranslateInstance(40, 0)));
1459 }
1460 Signals.addSignals();
1461 }
1462 }
1463
1464 private static void transits() {
1465 if (Renderer.zoom >= 14) {
1466 if (feature.type == Obj.RECTRC)
1467 Renderer.lineVector(new LineStyle(Color.black, 10, null, null));
1468 else if (feature.type == Obj.NAVLNE)
1469 Renderer.lineVector(new LineStyle(Color.black, 10, new float[] { 25, 25 }, null));
1470 }
1471 if (Renderer.zoom >= 15) {
1472 String str = "";
1473 String name = getName();
1474 if (name != null)
1475 str += name + " ";
1476 Double ort;
1477 if ((ort = (Double) getAttVal(feature.type, Att.ORIENT)) != null) {
1478 str += df.format(ort) + "º";
1479 if (!str.isEmpty())
1480 Renderer.lineText(str, new Font("Arial", Font.PLAIN, 80), Color.black, -20);
1481 }
1482 }
1483 }
1484
1485 private static void waterways() {
1486 Renderer.lineVector(new LineStyle(Symbols.Bwater, 20, (feature.geom.prim == Pflag.AREA) ? Symbols.Bwater : null));
1487 }
1488
1489 private static void wrecks() {
1490 if (Renderer.zoom >= 14) {
1491 switch ((CatWRK) getAttEnum(feature.type, Att.CATWRK)) {
1492 case WRK_DNGR:
1493 case WRK_MSTS:
1494 Renderer.symbol(Areas.WreckD);
1495 break;
1496 case WRK_HULS:
1497 Renderer.symbol(Areas.WreckS);
1498 break;
1499 default:
1500 Renderer.symbol(Areas.WreckND);
1501 }
1502 }
1503 }
1504}
Note: See TracBrowser for help on using the repository browser.