Changeset 30339 in osm for applications/editors/josm/plugins/smed2/src/render
- Timestamp:
- 2014-03-24T15:05:25+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src/render
- Files:
-
- 2 edited
-
Renderer.java (modified) (2 diffs)
-
Rules.java (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30333 r30339 18 18 import s57.S57val.*; 19 19 import s57.S57map; 20 import s57.S57att.Att; 20 21 import s57.S57map.*; 21 22 import symbols.Areas; … … 346 347 } 347 348 } 348 349 349 350 public static void labelText(Feature feature, String str, Font font, Color tc) { 350 351 labelText(feature, str, font, tc, LabelStyle.NONE, null, null, null); -
applications/editors/josm/plugins/smed2/src/render/Rules.java
r30333 r30339 74 74 } 75 75 76 public static void addName(Feature feature, int z, Font font) { 77 addName(feature, z, font, Color.black, new Delta(Handle.CC, new AffineTransform())); 78 } 79 public static void addName(Feature feature, int z, Font font, Color colour) { 80 addName(feature, z, font, colour, new Delta(Handle.CC, new AffineTransform())); 81 } 82 public static void addName(Feature feature, int z, Font font, Delta delta) { 83 addName(feature, z, font, Color.black, delta); 84 } 85 public static void addName(Feature feature, int z, Font font, Color colour, Delta delta) { 86 if (Renderer.zoom >= z) { 87 String name = getName(feature); 88 if (name != null) { 89 Renderer.labelText(feature, name, font, colour, delta); 90 } 91 } 92 } 93 76 94 static AttMap getAtts(Feature feature, Obj obj, int idx) { 77 95 HashMap<Integer, AttMap> objs = feature.objs.get(obj); … … 109 127 } 110 128 111 static boolean hasObject(Feature feature, Obj obj) { 112 return (feature.objs.containsKey(obj)); 113 } 114 115 static boolean hasAttribute(Feature feature, Obj obj, Att att) { 116 AttMap atts = getAtts(feature, obj, 0); 117 return ((atts != null) && (atts.containsKey(att))); 118 } 119 120 static boolean testAttribute(Feature feature, Obj obj, Att att, Object val) { 121 AttMap atts = getAtts(feature, obj, 0); 129 static boolean testAttribute(Feature feature, Obj obj, int idx, Att att, Object val) { 130 AttMap atts = getAtts(feature, obj, idx); 122 131 if (atts != null) { 123 132 AttVal item = atts.get(att); … … 221 230 else 222 231 Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 })); 223 if ((Renderer.zoom >= 12) && (name != null)) 224 Renderer.labelText(feature, name, new Font("Arial", Font.PLAIN, 100), Color.black); 232 addName(feature, 12, new Font("Arial", Font.PLAIN, 100), new Delta(Handle.CC, new AffineTransform())); 225 233 break; 226 234 case FAIRWY: … … 246 254 break; 247 255 case OSPARE: 248 if (testAttribute(feature, feature.type, Att.CATPRA, CatPRA.PRA_WFRM)) { 256 if (testAttribute(feature, feature.type, 0, Att.CATPRA, CatPRA.PRA_WFRM)) { 249 257 Renderer.symbol(feature, Areas.WindFarm); 250 258 Renderer.lineVector(feature, new LineStyle(Color.black, 20, new float[] { 40, 40 })); 251 if ((Renderer.zoom >= 15) && (name != null)) 252 Renderer.labelText(feature, name, new Font("Arial", Font.BOLD, 80), Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10))); 259 addName(feature, 15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10))); 253 260 } 254 261 break; 255 262 case RESARE: 263 case MIPARE: 256 264 if (Renderer.zoom >= 12) { 257 265 Renderer.lineSymbols(feature, Areas.Restricted, 1.0, null, null, 0, Mline); 258 if (testAttribute(feature, feature.type, Att.CATREA, CatREA.REA_NWAK)) { 266 if (testAttribute(feature, feature.type, 0, Att.CATREA, CatREA.REA_NWAK)) { 259 267 Renderer.symbol(feature, Areas.NoWake); 260 268 } … … 302 310 case SEA_GAT: 303 311 case SEA_NRRW: 304 if ((Renderer.zoom >= 12) && (name != null)) 305 Renderer.labelText(feature, name, new Font("Arial", Font.PLAIN, 100), Color.black); 312 addName(feature, 12, new Font("Arial", Font.PLAIN, 100)); 306 313 break; 307 314 default: … … 317 324 Renderer.lineSymbols(feature, Areas.Restricted, 0.5, Areas.LinePlane, null, 10, Mline); 318 325 } 319 if ((Renderer.zoom >= 15) && (name != null)) 320 Renderer.labelText(feature, name, new Font("Arial", Font.BOLD, 80), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90))); 326 addName(feature, 15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90))); 321 327 break; 322 328 default: … … 352 358 } else { 353 359 Renderer.symbol(feature, Beacons.Shapes.get(shape), getScheme(feature, feature.type)); 354 if ( hasObject(feature,Obj.TOPMAR)) {360 if (feature.objs.containsKey(Obj.TOPMAR)) { 355 361 Symbol topmark = Topmarks.Shapes.get(feature.objs.get(Obj.TOPMAR).get(0).get(Att.TOPSHP).val); 356 362 if (topmark != null) 357 363 Renderer.symbol(feature, Topmarks.Shapes.get(feature.objs.get(Obj.TOPMAR).get(0).get(Att.TOPSHP).val), getScheme(feature, Obj.TOPMAR), Topmarks.BeaconDelta); 358 } else if ( hasObject(feature,Obj.DAYMAR)) {364 } else if (feature.objs.containsKey(Obj.DAYMAR)) { 359 365 Symbol topmark = Topmarks.Shapes.get(feature.objs.get(Obj.DAYMAR).get(0).get(Att.TOPSHP).val); 360 366 if (topmark != null) … … 370 376 BoySHP shape = (BoySHP) getAttVal(feature, feature.type, 0, Att.BOYSHP); 371 377 Renderer.symbol(feature, Buoys.Shapes.get(shape), getScheme(feature, feature.type)); 372 if ( hasObject(feature,Obj.TOPMAR)) {378 if (feature.objs.containsKey(Obj.TOPMAR)) { 373 379 Symbol topmark = Topmarks.Shapes.get(feature.objs.get(Obj.TOPMAR).get(0).get(Att.TOPSHP).val); 374 380 if (topmark != null) 375 381 Renderer.symbol(feature, topmark, getScheme(feature, Obj.TOPMAR), Topmarks.BuoyDeltas.get(shape)); 376 } else if ( hasObject(feature,Obj.DAYMAR)) {382 } else if (feature.objs.containsKey(Obj.DAYMAR)) { 377 383 Symbol topmark = Topmarks.Shapes.get(feature.objs.get(Obj.DAYMAR).get(0).get(Att.TOPSHP).val); 378 384 if (topmark != null) … … 446 452 private static void distances(Feature feature) { 447 453 if (Renderer.zoom >= 14) { 448 if (!testAttribute(feature, Obj.DISMAR, Att.CATDIS, CatDIS.DIS_NONI)) { 454 if (!testAttribute(feature, Obj.DISMAR, 0, Att.CATDIS, CatDIS.DIS_NONI)) { 449 455 Renderer.symbol(feature, Harbours.DistanceI); 450 456 } else { 451 457 Renderer.symbol(feature, Harbours.DistanceU); 452 458 } 453 if ((Renderer.zoom >=15) && hasAttribute(feature, Obj.DISMAR, Att.WTWDIS)) { 454 AttMap atts = feature.objs.get(Obj.DISMAR).get(0); 455 Double dist = (Double) atts.get(Att.WTWDIS).val; 456 String str = ""; 457 if (atts.containsKey(Att.HUNITS)) { 458 switch ((UniHLU) atts.get(Att.HUNITS).val) { 459 case HLU_METR: 460 str += "m "; 461 break; 462 case HLU_FEET: 463 str += "ft "; 464 break; 465 case HLU_HMTR: 466 str += "hm "; 467 break; 468 case HLU_KMTR: 469 str += "km "; 470 break; 471 case HLU_SMIL: 472 str += "M "; 473 break; 474 case HLU_NMIL: 475 str += "NM "; 476 break; 477 default: 478 break; 459 if (Renderer.zoom >= 15) { 460 AttMap atts = getAtts(feature, Obj.DISMAR, 0); 461 if ((atts != null) && (atts.containsKey(Att.WTWDIS))) { 462 Double dist = (Double) atts.get(Att.WTWDIS).val; 463 String str = ""; 464 if (atts.containsKey(Att.HUNITS)) { 465 switch ((UniHLU) atts.get(Att.HUNITS).val) { 466 case HLU_METR: 467 str += "m "; 468 break; 469 case HLU_FEET: 470 str += "ft "; 471 break; 472 case HLU_HMTR: 473 str += "hm "; 474 break; 475 case HLU_KMTR: 476 str += "km "; 477 break; 478 case HLU_SMIL: 479 str += "M "; 480 break; 481 case HLU_NMIL: 482 str += "NM "; 483 break; 484 default: 485 break; 486 } 479 487 } 480 }481 str += String.format("%1.0f", dist);482 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 45)));488 str += String.format("%1.0f", dist); 489 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 45))); 490 } 483 491 } 484 492 } … … 535 543 Renderer.lineSymbols(feature, Areas.Restricted, 1.0, Areas.LineAnchor, null, 10, Mline); 536 544 } 537 if ((Renderer.zoom >= 15) && ((name) != null)) { 538 Renderer.labelText(feature, name, new Font("Arial", Font.BOLD, 60), Mline, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, 0))); 539 } 545 addName(feature, 15, new Font("Arial", Font.BOLD, 60), Mline, new Delta(Handle.LC, AffineTransform.getTranslateInstance(70, 0))); 540 546 ArrayList<StsSTS> sts = (ArrayList<StsSTS>)getAttVal(feature, Obj.ACHARE, 0, Att.STATUS); 541 547 if ((Renderer.zoom >= 15) && (sts != null) && (sts.contains(StsSTS.STS_RESV))) { … … 638 644 Renderer.symbol(feature, catSym); 639 645 Renderer.symbol(feature, fncSym); 640 /* if (!has_attribute("function") && !has_attribute("category") && has_object("light")) { 641 symbol("lighthouse"); 642 if ((zoom >= 15) && has_item_attribute("name")) 643 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:middle", 0, -70); 644 } else { 645 if ((zoom >= 15) && has_item_attribute("name")) 646 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:start", 60, -50); 647 } 648 } 649 */ 646 addName(feature, 15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50))); 650 647 Signals.addSignals(feature); 651 }652 653 private static void buildings(Feature feature) {654 648 } 655 649 … … 664 658 break; 665 659 case PILPNT: 666 if ( hasObject(feature,Obj.LIGHTS))660 if (feature.objs.containsKey(Obj.LIGHTS)) 667 661 Renderer.symbol(feature, Beacons.LightMinor); 668 662 else … … 680 674 private static void marinas(Feature feature) { 681 675 if (Renderer.zoom >= 16) { 682 683 } 684 } 676 ArrayList<Symbol> symbols = new ArrayList<Symbol>(); 677 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttVal(feature, Obj.SMCFAC, 0, Att.CATSCF); 678 for (CatSCF scf : scfs) { 679 symbols.add(Facilities.Cats.get(scf)); 680 } 681 Renderer.cluster(feature, symbols); 682 } 683 } 684 685 685 private static void moorings(Feature feature) { 686 686 switch ((CatMOR) getAttVal(feature, feature.type, 0, Att.CATMOR)) { … … 700 700 shape = BoySHP.BOY_SPHR; 701 701 Renderer.symbol(feature, Buoys.Shapes.get(shape), getScheme(feature, feature.type)); 702 Renderer.symbol(feature, Topmarks.TopMooring, Topmarks.BuoyDeltas.get(shape)); 702 703 break; 703 704 } … … 923 924 924 925 private static void obstructions(Feature feature) { 926 if ((Renderer.zoom >= 12) && (feature.type == Obj.OBSTRN)) { 927 switch ((CatOBS) getAttVal(feature, feature.type, 0, Att.CATOBS)) { 928 case OBS_BOOM: 929 Renderer.lineVector(feature, new LineStyle(Color.black, 5, new float[] { 20, 20 }, null)); 930 if (Renderer.zoom >= 15) Renderer.lineText(feature, "Boom", new Font("Arial", Font.PLAIN, 80), Color.black, 0.5, -20); 931 } 932 } 925 933 if ((Renderer.zoom >= 14) && (feature.type == Obj.UWTROC)) { 926 934 WatLEV lvl = (WatLEV) getAttVal(feature, feature.type, 0, Att.WATLEV); … … 968 976 else 969 977 Renderer.symbol(feature, Landmarks.Platform); 970 String name = getName(feature); 971 if ((Renderer.zoom >= 15) && (name != null)) 972 Renderer.labelText(feature, name, new Font("Arial", Font.BOLD, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50))); 978 addName(feature, 15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, -50))); 973 979 Signals.addSignals(feature); 974 980 } … … 983 989 } else if (feature.type == Obj.HULKES) { 984 990 Renderer.lineVector(feature, new LineStyle(Color.black, 4, null, new Color(0xffe000))); 985 String name = getName(feature); 986 if ((Renderer.zoom >= 15) && (name != null)) 987 Renderer.labelText(feature, name, new Font("Arial", Font.BOLD, 80), Color.black); 991 addName(feature, 15, new Font("Arial", Font.BOLD, 80)); 988 992 } 989 993 } … … 999 1003 else 1000 1004 Renderer.lineVector(feature, new LineStyle(new Color(0x80c48080, true), 20, null, null)); 1001 String name = getName(feature); 1002 if ((Renderer.zoom >= 10) && (name != null)) 1003 Renderer.labelText(feature, name, new Font("Arial", Font.BOLD, 150), new Color(0x80c48080, true)); 1005 addName(feature, 10, new Font("Arial", Font.BOLD, 150), new Color(0x80c48080, true)); 1004 1006 break; 1005 1007 case TSELNE: … … 1032 1034 if (Renderer.zoom >= 15) 1033 1035 Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 80), Color.black, 0.5, -30); 1036 break; 1037 case SLC_SWAY: 1038 Renderer.lineVector(feature, new LineStyle(Color.black, 2, null, new Color(0xffe000))); 1039 if ((Renderer.zoom >= 16) && feature.objs.containsKey(Obj.SMCFAC)) { 1040 ArrayList<Symbol> symbols = new ArrayList<Symbol>(); 1041 ArrayList<CatSCF> scfs = (ArrayList<CatSCF>) getAttVal(feature, Obj.SMCFAC, 0, Att.CATSCF); 1042 for (CatSCF scf : scfs) { 1043 symbols.add(Facilities.Cats.get(scf)); 1044 } 1045 Renderer.cluster(feature, symbols); 1046 } 1047 break; 1034 1048 } 1035 1049 }
Note:
See TracChangeset
for help on using the changeset viewer.
