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