Changeset 32398 in osm for applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java
- Timestamp:
- 2016-06-25T11:56:57+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java
r32395 r32398 15 15 public class ChosenRelationComponent extends JLabel implements ChosenRelationListener { 16 16 17 //private ChosenRelation chRel;18 19 17 public ChosenRelationComponent(ChosenRelation rel) { 20 18 super(""); 21 /* setBackground(Color.white);22 setOpaque(true);23 setBorder(new LineBorder(Color.black, 1, true));*/24 //this.chRel = rel;25 19 rel.addChosenRelationListener(this); 26 20 } … … 32 26 } 33 27 34 private final staticString[] TYPE_KEYS = new String[] {28 private static final String[] TYPE_KEYS = new String[] { 35 29 "natural", "landuse", "place", "waterway", "leisure", "amenity", "restriction", "public_transport", "route", "enforcement" 36 30 }; 37 31 38 private final staticString[] NAMING_TAGS = new String[] {32 private static final String[] NAMING_TAGS = new String[] { 39 33 "name", "place_name", "ref", "destination", "note" 40 34 }; 41 35 42 36 protected String prepareText(Relation rel) { 43 if (rel == null 37 if (rel == null) 44 38 return ""; 45 39 46 40 String type = rel.get("type"); 47 if (type == null || type.length() == 0 41 if (type == null || type.length() == 0) { 48 42 type = "-"; 49 43 } 50 44 51 45 String tag = null; 52 for (int i = 0; i < TYPE_KEYS.length && tag == null; i++ )46 for (int i = 0; i < TYPE_KEYS.length && tag == null; i++) { 53 47 if (rel.hasKey(TYPE_KEYS[i])) { 54 48 tag = TYPE_KEYS[i]; 55 49 } 56 if (tag != null ) { 50 } 51 if (tag != null) { 57 52 tag = tag.substring(0, 2) + "=" + rel.get(tag); 58 53 } 59 54 60 55 String name = null; 61 for (int i = 0; i < NAMING_TAGS.length && name == null; i++ )62 if (rel.hasKey(NAMING_TAGS[i]) 56 for (int i = 0; i < NAMING_TAGS.length && name == null; i++) { 57 if (rel.hasKey(NAMING_TAGS[i])) { 63 58 name = rel.get(NAMING_TAGS[i]); 64 59 } 60 } 65 61 66 62 StringBuilder sb = new StringBuilder(); 67 63 sb.append(type.substring(0, 1)); 68 if (type.equals("boundary") && rel.hasKey("admin_level") 64 if (type.equals("boundary") && rel.hasKey("admin_level")) { 69 65 sb.append(rel.get("admin_level")); 70 66 } 71 if (name != null 67 if (name != null) { 72 68 sb.append(" \"").append(name).append('"'); 73 69 } 74 if (tag != null 70 if (tag != null) { 75 71 sb.append("; ").append(tag); 76 72 }
Note:
See TracChangeset
for help on using the changeset viewer.