Changeset 13243 in josm for trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
- Timestamp:
- 2017-12-26T17:50:55+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r12851 r13243 16 16 import org.openstreetmap.josm.data.StructUtils.WriteExplicitly; 17 17 import org.openstreetmap.josm.data.coor.EastNorth; 18 import org.openstreetmap.josm.data.coor.ILatLon; 18 19 import org.openstreetmap.josm.data.coor.LatLon; 19 20 import org.openstreetmap.josm.data.projection.Projection; … … 40 41 @StructEntry private double center_lon, center_lat; 41 42 43 /** 44 * Test if an image is usable for the given imagery layer. 45 * @param layer The layer to use the image at 46 * @return <code>true</code> if it is usable on the projection of the layer and the imagery name matches. 47 */ 42 48 public boolean isUsable(ImageryLayer layer) { 43 49 if (projection_code == null) return false; … … 55 61 } 56 62 63 /** 64 * Create a new {@link OffsetBookmark} object using (0, 0) as center 65 * <p> 66 * The use of the {@link #OffsetBookmark(String, String, String, EastNorth, ILatLon)} constructor is preferred. 67 * @param projectionCode The projection for which this object was created 68 * @param imageryName The name of the imagery on the layer 69 * @param name The name of the new bookmark 70 * @param dx The x displacement 71 * @param dy The y displacement 72 */ 57 73 public OffsetBookmark(String projectionCode, String imageryName, String name, double dx, double dy) { 58 74 this(projectionCode, imageryName, name, dx, dy, 0, 0); 59 75 } 60 76 77 /** 78 * Create a new {@link OffsetBookmark} object 79 * @param projectionCode The projection for which this object was created 80 * @param imageryName The name of the imagery on the layer 81 * @param name The name of the new bookmark 82 * @param displacement The displacement in east/north space. 83 * @param center The point on earth that was used as reference to align the image. 84 * @since 13243 85 */ 86 public OffsetBookmark(String projectionCode, String imageryName, String name, EastNorth displacement, ILatLon center) { 87 this(projectionCode, imageryName, name, displacement.east(), displacement.north(), center.lon(), center.lat()); 88 } 89 90 /** 91 * Create a new {@link OffsetBookmark} by specifying all values. 92 * <p> 93 * The use of the {@link #OffsetBookmark(String, String, String, EastNorth, ILatLon)} constructor is preferred. 94 * @param projectionCode The projection for which this object was created 95 * @param imageryName The name of the imagery on the layer 96 * @param name The name of the new bookmark 97 * @param dx The x displacement 98 * @param dy The y displacement 99 * @param centerLon The point on earth that was used as reference to align the image. 100 * @param centerLat The point on earth that was used as reference to align the image. 101 */ 61 102 public OffsetBookmark(String projectionCode, String imageryName, String name, double dx, double dy, double centerLon, double centerLat) { 62 103 this.projection_code = projectionCode; … … 69 110 } 70 111 112 /** 113 * Loads an old bookmark. For backward compatibility with settings. Do not use. 114 * @param list The settings that were read 115 */ 71 116 public OffsetBookmark(Collection<String> list) { 72 117 List<String> array = new ArrayList<>(list); … … 85 130 } 86 131 132 /** 133 * Get the projection code for which this bookmark was created. 134 * @return The projection. 135 */ 87 136 public String getProjectionCode() { 88 137 return projection_code; 89 138 } 90 139 140 /** 141 * Get the name of this bookmark. This name can e.g. be displayed in menus. 142 * @return The name 143 */ 91 144 public String getName() { 92 145 return name; 93 146 } 94 147 148 /** 149 * Get the name of the imagery for which this bookmark was created. It is used to match the bookmark to the right layers. 150 * @return The name 151 */ 95 152 public String getImageryName() { 96 153 return imagery_name; … … 149 206 } 150 207 208 /** 209 * Set the projection code for which this bookmark was created 210 * @param projectionCode The projection 211 */ 151 212 public void setProjectionCode(String projectionCode) { 152 213 this.projection_code = projectionCode; 153 214 } 154 215 216 /** 217 * Set the name of the bookmark 218 * @param name The name 219 * @see #getName() 220 */ 155 221 public void setName(String name) { 156 222 this.name = name; 157 223 } 158 224 225 /** 226 * Sets the name of the imagery 227 * @param imageryName The name 228 * @see #getImageryName() 229 */ 159 230 public void setImageryName(String imageryName) { 160 231 this.imagery_name = imageryName; 161 232 } 162 233 234 /** 235 * Update the displacement of this imagery. 236 * @param displacement The displacement 237 */ 163 238 public void setDisplacement(EastNorth displacement) { 164 239 this.dx = displacement.east(); … … 166 241 } 167 242 243 /** 244 * Load the global list of bookmarks from preferences. 245 */ 168 246 public static void loadBookmarks() { 169 247 List<OffsetBookmark> bookmarks = StructUtils.getListOfStructs( … … 184 262 } 185 263 264 /** 265 * Stores the bookmakrs in the settings. 266 */ 186 267 public static void saveBookmarks() { 187 268 StructUtils.putListOfStructs(Config.getPref(), "imagery.offsetbookmarks", allBookmarks, OffsetBookmark.class); … … 238 319 } 239 320 321 /** 322 * Gets a bookmark that is usable on the given layer by it's name. 323 * @param layer The layer to use the bookmark at 324 * @param name The name of the bookmark 325 * @return The bookmark if found, <code>null</code> if not. 326 */ 240 327 public static OffsetBookmark getBookmarkByName(ImageryLayer layer, String name) { 241 328 for (OffsetBookmark b : allBookmarks) { … … 246 333 } 247 334 248 public static void bookmarkOffset(String name, AbstractTileSourceLayer layer) { 335 /** 336 * Add a bookmark for the displacement of that layer 337 * @param name The bookmark name 338 * @param layer The layer to store the bookmark for 339 */ 340 public static void bookmarkOffset(String name, AbstractTileSourceLayer<?> layer) { 249 341 LatLon center; 250 342 if (MainApplication.isDisplayingMapView()) { … … 255 347 OffsetBookmark nb = new OffsetBookmark( 256 348 Main.getProjection().toCode(), layer.getInfo().getName(), 257 name, layer.getDisplaySettings().getD x(), layer.getDisplaySettings().getDy(), center.lon(), center.lat());349 name, layer.getDisplaySettings().getDisplacement(), center); 258 350 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext();) { 259 351 OffsetBookmark b = it.next();
Note:
See TracChangeset
for help on using the changeset viewer.