Changeset 12378 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-06-09T22:13:45+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
r11388 r12378 42 42 } 43 43 44 /** 45 * Gets the value for a given key with the given type 46 * @param <T> the expected type 47 * @param key the key 48 * @param def default value, can be null 49 * @param klass the same as T 50 * @return if a value that can be converted to class klass has been mapped to key, returns this 51 * value, def otherwise 52 */ 44 53 public <T> T get(String key, T def, Class<T> klass) { 45 54 return get(key, def, klass, false); … … 54 63 * @param suppressWarnings show or don't show a warning when some value is 55 64 * found, but cannot be converted to the requested type 56 * @return if a value withclass klass has been mapped to key, returns this65 * @return if a value that can be converted to class klass has been mapped to key, returns this 57 66 * value, def otherwise 58 67 */ … … 73 82 } 74 83 84 /** 85 * Gets a property for the given key (like stroke, ...) 86 * @param key The key of the property 87 * @return The value or <code>null</code> if it is not set. May be of any type 88 */ 75 89 public Object get(String key) { 76 90 return prop.get(key); 77 91 } 78 92 93 /** 94 * Sets the property for the given key 95 * @param key The key 96 * @param val The value 97 */ 79 98 public void put(String key, Object val) { 80 99 prop.put(key, val); 81 100 } 82 101 102 /** 103 * Sets the property for the given key, removes it if the value is <code>null</code> 104 * @param key The key 105 * @param val The value, may be <code>null</code> 106 */ 83 107 public void putOrClear(String key, Object val) { 84 108 if (val != null) { … … 89 113 } 90 114 115 /** 116 * Removes the property with the given key 117 * @param key The key 118 */ 91 119 public void remove(String key) { 92 120 prop.remove(key); 93 121 } 94 122 123 /** 124 * Converts an object to a given other class. 125 * 126 * Only conversions that are useful for MapCSS are supported 127 * @param <T> The class type 128 * @param o The object to convert 129 * @param klass The class 130 * @return The converted object or <code>null</code> if the conversion failed 131 */ 95 132 @SuppressWarnings("unchecked") 96 133 public static <T> T convertTo(Object o, Class<T> klass) { … … 235 272 } 236 273 274 /** 275 * Checks if this cascade has a value for given key 276 * @param key The key to check 277 * @return <code>true</code> if there is a value 278 */ 237 279 public boolean containsKey(String key) { 238 280 return prop.containsKey(key); 239 281 } 240 282 283 /** 284 * Get if the default selection drawing should be used for the object this cascade applies to 285 * @return <code>true</code> to use the default selection drawing 286 */ 241 287 public boolean isDefaultSelectedHandling() { 242 288 return defaultSelectedHandling; 243 289 } 244 290 291 /** 292 * Set that the default selection drawing should be used for the object this cascade applies to 293 * @param defaultSelectedHandling <code>true</code> to use the default selection drawing 294 */ 245 295 public void setDefaultSelectedHandling(boolean defaultSelectedHandling) { 246 296 this.defaultSelectedHandling = defaultSelectedHandling; -
trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java
r9239 r12378 15 15 public class Environment { 16 16 17 /** 18 * The primitive that is currently evaluated 19 */ 17 20 public OsmPrimitive osm; 18 21 22 /** 23 * The cascades that are currently evaluated 24 */ 19 25 public MultiCascade mc; 26 /** 27 * The current MapCSS layer 28 */ 20 29 public String layer; 30 /** 31 * The style source that is evaluated 32 */ 21 33 public StyleSource source; 22 34 private Context context = Context.PRIMITIVE; 35 36 /** 37 * The name of the default layer. It is used if no layer is specified in the MapCSS rule 38 */ 23 39 public static final String DEFAULT_LAYER = "default"; 24 40 … … 228 244 } 229 245 246 /** 247 * Gets the role of the matching primitive in the relation 248 * @return The role 249 */ 230 250 public String getRole() { 231 251 if (getContext().equals(Context.PRIMITIVE)) … … 239 259 } 240 260 261 /** 262 * Clears all matching context information 263 */ 241 264 public void clearSelectorMatchingInformation() { 242 265 parent = null; … … 246 269 } 247 270 271 /** 272 * Gets the current cascade for a given layer 273 * @param layer The layer to use, <code>null</code> to use the layer of the {@link Environment} 274 * @return The cascade 275 */ 248 276 public Cascade getCascade(String layer) { 249 277 return mc == null ? null : mc.getCascade(layer == null ? this.layer : layer); -
trunk/src/org/openstreetmap/josm/gui/mappaint/Keyword.java
r11137 r12378 14 14 */ 15 15 public class Keyword { 16 /** 17 * The string value for this keyword 18 */ 16 19 public final String val; 17 20 21 /** 22 * Create a new Keyword 23 * @param val The string value that is written in the MapCSS file 24 */ 18 25 public Keyword(String val) { 19 26 this.val = val.toLowerCase(Locale.ENGLISH); … … 38 45 } 39 46 47 /** 48 * Automated text positioning 49 */ 40 50 public static final Keyword AUTO = new Keyword("auto"); 51 /** 52 * Align text at the bottom 53 */ 41 54 public static final Keyword BOTTOM = new Keyword("bottom"); 55 /** 56 * Align text at the center 57 */ 42 58 public static final Keyword CENTER = new Keyword("center"); 59 /** 60 * Use default line width 61 */ 43 62 public static final Keyword DEFAULT = new Keyword("default"); 63 /** 64 * Align to the right 65 */ 44 66 public static final Keyword RIGHT = new Keyword("right"); 67 /** 68 * Thinnest line width 69 */ 45 70 public static final Keyword THINNEST = new Keyword("thinnest"); 46 71 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r12342 r12378 77 77 */ 78 78 public static class TagKeyReference { 79 /** 80 * The tag name 81 */ 79 82 public final String key; 80 83 84 /** 85 * Create a new {@link TagKeyReference} 86 * @param key The tag name 87 */ 81 88 public TagKeyReference(String key) { 82 89 this.key = key; … … 96 103 public static class IconReference { 97 104 105 /** 106 * The name of the icon 107 */ 98 108 public final String iconName; 109 /** 110 * The style source this reference occurred in 111 */ 99 112 public final StyleSource source; 100 113 114 /** 115 * Create a new {@link IconReference} 116 * @param iconName The icon name 117 * @param source The current style source 118 */ 101 119 public IconReference(String iconName, StyleSource source) { 102 120 this.iconName = iconName; … … 182 200 } 183 201 202 /** 203 * Returns the node icon that would be displayed for the given tag. 204 * @param tag The tag to look an icon for 205 * @return {@code null} if no icon found 206 */ 184 207 public static ImageIcon getNodeIcon(Tag tag) { 185 208 return getNodeIcon(tag, true); … … 225 248 } 226 249 250 /** 251 * Gets the directories that should be searched for icons 252 * @param source The style source the icon is from 253 * @return A list of directory names 254 */ 227 255 public static List<String> getIconSourceDirs(StyleSource source) { 228 256 List<String> dirs = new LinkedList<>(); … … 323 351 } 324 352 353 /** 354 * This class loads the map paint styles 355 */ 325 356 public static class MapPaintStyleLoader extends PleaseWaitRunnable { 326 357 private boolean canceled; 327 358 private final Collection<StyleSource> sources; 328 359 360 /** 361 * Create a new {@link MapPaintStyleLoader} 362 * @param sources The styles to load 363 */ 329 364 public MapPaintStyleLoader(Collection<StyleSource> sources) { 330 365 super(tr("Reloading style sources")); … … 396 431 } 397 432 433 /** 434 * Check if the styles can be moved 435 * @param sel The indexes of the selected styles 436 * @param i The number of places to move the styles 437 * @return <code>true</code> if that movement is possible 438 */ 398 439 public static boolean canMoveStyles(int[] sel, int i) { 399 440 if (sel.length == 0) … … 410 451 } 411 452 453 /** 454 * Toggles the active state of several styles 455 * @param sel The style indexes 456 */ 412 457 public static void toggleStyleActive(int... sel) { 413 458 List<StyleSource> data = styles.getStyleSources(); … … 491 536 } 492 537 538 /** 539 * Notifies all listeners that there was any update to the map paint styles 540 */ 493 541 public static void fireMapPaintSylesUpdated() { 494 542 listeners.fireEvent(MapPaintSylesUpdateListener::mapPaintStylesUpdated); 495 543 } 496 544 545 /** 546 * Notifies all listeners that there was an update to a specific map paint style 547 * @param index The style index 548 */ 497 549 public static void fireMapPaintStyleEntryUpdated(int index) { 498 550 listeners.fireEvent(l -> l.mapPaintStyleEntryUpdated(index)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/MultiCascade.java
r11388 r12378 17 17 18 18 private final Map<String, Cascade> layers; 19 /** 20 * The scale range this cascade is valid for 21 */ 19 22 public Range range; 20 23 … … 74 77 } 75 78 79 /** 80 * Gets all cascades for the known layers 81 * @return The cascades for the layers 82 */ 76 83 public Collection<Entry<String, Cascade>> getLayers() { 77 84 return layers.entrySet(); 78 85 } 79 86 87 /** 88 * Check whether this cascade has a given layer 89 * @param layer The layer to check for 90 * @return <code>true</code> if it has that layer 91 */ 80 92 public boolean hasLayer(String layer) { 81 93 return layers.containsKey(layer); -
trunk/src/org/openstreetmap/josm/gui/mappaint/Range.java
r11370 r12378 13 13 private final double upper; 14 14 15 /** 16 * The full scale range from zero to infinity 17 */ 15 18 public static final Range ZERO_TO_INFINITY = new Range(0.0, Double.POSITIVE_INFINITY); 16 19 … … 28 31 } 29 32 33 /** 34 * Check if a number is contained in this range 35 * @param x The number to test 36 * @return <code>true</code> if it is in this range 37 */ 30 38 public boolean contains(double x) { 31 39 return lower < x && x <= upper; … … 76 84 } 77 85 86 /** 87 * Gets the lower bound 88 * @return The lower, exclusive, bound 89 */ 78 90 public double getLower() { 79 91 return lower; 80 92 } 81 93 94 /** 95 * Gets the upper bound 96 * @return The upper, inclusive, bound 97 */ 82 98 public double getUpper() { 83 99 return upper; -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
r11781 r12378 18 18 private static final Storage<StyleCache> internPool = new Storage<>(); 19 19 20 /** 21 * An empty style cache entry 22 */ 20 23 public static final StyleCache EMPTY_STYLECACHE = (new StyleCache()).intern(); 21 24 -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleElementList.java
r9669 r12378 24 24 } 25 25 26 /** 27 * Create a new List of style elements 28 * @param init The list 29 */ 26 30 public StyleElementList(StyleElement... init) { 27 31 lst = new ArrayList<>(Arrays.asList(init)); 28 32 } 29 33 34 /** 35 * Create a new List of style elements 36 * @param sl The list 37 */ 30 38 public StyleElementList(Collection<StyleElement> sl) { 31 39 lst = new ArrayList<>(sl); 32 40 } 33 41 42 /** 43 * Create a new List of style elements 44 * @param sl The list 45 * @param s An item to merge to the list 46 */ 34 47 public StyleElementList(StyleElementList sl, StyleElement s) { 35 48 lst = new ArrayList<>(sl.lst); … … 42 55 } 43 56 57 /** 58 * Check if the list is empty 59 * @return <code>true</code> if it is empty 60 */ 44 61 public boolean isEmpty() { 45 62 return lst.isEmpty(); 46 63 } 47 64 65 /** 66 * Get the list size 67 * @return The list size 68 */ 48 69 public int size() { 49 70 return lst.size(); -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSetting.java
r9966 r12378 34 34 public interface StyleSetting { 35 35 36 /** 37 * Adds the menu entry for this style setting to the menu 38 * @param menu The menu to add the setting to 39 */ 36 40 void addMenuEntry(JMenu menu); 37 41 42 /** 43 * gets the value for this setting 44 * @return The value the user selected 45 */ 38 46 Object getValue(); 39 47 -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java
r9334 r12378 38 38 private final List<Throwable> errors = new CopyOnWriteArrayList<>(); 39 39 private final Set<String> warnings = new CopyOnWriteArraySet<>(); 40 /** 41 * The zip file containing the icons for this style 42 */ 40 43 public File zipIcons; 41 44 … … 245 248 } 246 249 250 /** 251 * Gets the background color that was set in this style 252 * @return The color or <code>null</code> if it was not set 253 */ 247 254 public Color getBackgroundColorOverride() { 248 255 return null;
Note:
See TracChangeset
for help on using the changeset viewer.