Changeset 6541 in josm for trunk/src/org
- Timestamp:
- 2013-12-27T00:11:47+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategy.java
r6070 r6541 29 29 * in the JOSM preferences 30 30 * content of a tag whose name specified in the MapCSS style file, see the preference 31 * option <tt>mappaint.nameOrder</tt>.</li>31 * options <tt>mappaint.nameOrder</tt> and <tt>mappaint.nameComplementOrder</tt>.</li> 32 32 * </ul> 33 33 * </p> … … 163 163 }; 164 164 165 private List<String> nameTags = new ArrayList<String>(); 165 /** 166 * The list of default name complement tags from which a label candidate is derived. 167 * @since 6541 168 */ 169 static public final String[] DEFAULT_NAME_COMPLEMENT_TAGS = { 170 "capacity" 171 }; 172 173 private List<String> nameTags = new ArrayList<String>(); 174 private List<String> nameComplementTags = new ArrayList<String>(); 166 175 167 176 /** … … 177 186 } 178 187 179 /** 180 * Sets the name tags to be looked up in order to build up the label 181 * 182 * @param nameTags the name tags. null values are ignore. 183 */ 184 public void setNameTags(List<String> nameTags){ 188 private static List<String> buildNameTags(List<String> nameTags) { 185 189 if (nameTags == null) { 186 190 nameTags = Collections.emptyList(); 187 191 } 188 this.nameTags= new ArrayList<String>();192 ArrayList<String> result = new ArrayList<String>(); 189 193 for(String tag: nameTags) { 190 194 if (tag == null) { … … 195 199 continue; 196 200 } 197 this.nameTags.add(tag); 198 } 199 } 200 201 result.add(tag); 202 } 203 return result; 204 } 205 206 /** 207 * Sets the name tags to be looked up in order to build up the label. 208 * 209 * @param nameTags the name tags. null values are ignored. 210 */ 211 public void setNameTags(List<String> nameTags){ 212 this.nameTags = buildNameTags(nameTags); 213 } 214 215 /** 216 * Sets the name complement tags to be looked up in order to build up the label. 217 * 218 * @param nameComplementTags the name complement tags. null values are ignored. 219 * @since 6541 220 */ 221 public void setNameComplementTags(List<String> nameComplementTags){ 222 this.nameComplementTags = buildNameTags(nameComplementTags); 223 } 224 201 225 /** 202 226 * Replies an unmodifiable list of the name tags used to compose the label. … … 209 233 210 234 /** 235 * Replies an unmodifiable list of the name complement tags used to compose the label. 236 * 237 * @return the list of name complement tags 238 * @since 6541 239 */ 240 public List<String> getNameComplementTags() { 241 return Collections.unmodifiableList(nameComplementTags); 242 } 243 244 /** 211 245 * Initializes the name tags to use from a list of default name tags (see 212 * {@link #DEFAULT_NAME_TAGS}) and from name tags configured in the preferences 213 * using the preference key <tt>mappaint.nameOrder</tt>. 246 * {@link #DEFAULT_NAME_TAGS} and {@link #DEFAULT_NAME_COMPLEMENT_TAGS}) 247 * and from name tags configured in the preferences using the keys 248 * <tt>mappaint.nameOrder</tt> and <tt>mappaint.nameComplementOrder</tt>. 214 249 */ 215 250 public void initNameTagsFromPreferences() { 216 251 if (Main.pref == null){ 217 252 this.nameTags = new ArrayList<String>(Arrays.asList(DEFAULT_NAME_TAGS)); 253 this.nameComplementTags = new ArrayList<String>(Arrays.asList(DEFAULT_NAME_COMPLEMENT_TAGS)); 218 254 } else { 219 255 this.nameTags = new ArrayList<String>( 220 256 Main.pref.getCollection("mappaint.nameOrder", Arrays.asList(DEFAULT_NAME_TAGS)) 257 ); 258 this.nameComplementTags = new ArrayList<String>( 259 Main.pref.getCollection("mappaint.nameComplementOrder", Arrays.asList(DEFAULT_NAME_COMPLEMENT_TAGS)) 221 260 ); 222 261 } … … 228 267 for (String rn : nameTags) { 229 268 name = n.get(rn); 230 if (name != null) return name; 231 } 232 return null; 269 if (name != null) { 270 break; 271 } 272 } 273 for (String rn : nameComplementTags) { 274 String comp = n.get(rn); 275 if (comp != null) { 276 if (name == null) { 277 name = comp; 278 } else { 279 name += " (" + comp + ")"; 280 } 281 break; 282 } 283 } 284 return name; 233 285 } 234 286 -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r6530 r6541 342 342 * @since 6522 343 343 */ 344 public Rectangle getVirtualScreenBounds() {344 public static Rectangle getVirtualScreenBounds() { 345 345 Rectangle virtualBounds = new Rectangle(); 346 346 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Note:
See TracChangeset
for help on using the changeset viewer.