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

Last change on this file since 33193 was 33193, checked in by malcolmh, 8 years ago

catch rendering exception

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