- Timestamp:
- 2014-09-11T19:27:03+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r7005 r7527 17 17 * Represents the history of an OSM primitive. The history consists 18 18 * of a list of object snapshots with a specific version. 19 * 19 * @since 1670 20 20 */ 21 public class History{ 21 public class History { 22 22 23 private static interface FilterPredicate { 23 24 boolean matches(HistoryOsmPrimitive primitive); … … 38 39 /** the object id */ 39 40 private final long id; 41 /** the object type */ 40 42 private final OsmPrimitiveType type; 41 43 42 44 /** 43 * Creates a new history for an OSM primitive 45 * Creates a new history for an OSM primitive. 44 46 * 45 47 * @param id the id. > 0 required. … … 62 64 } 63 65 66 /** 67 * Returns a new copy of this history, sorted in ascending order. 68 * @return a new copy of this history, sorted in ascending order 69 */ 64 70 public History sortAscending() { 65 71 List<HistoryOsmPrimitive> copy = new ArrayList<>(versions); … … 72 78 } 73 79 } 74 80 ); 75 81 return new History(id, type, copy); 76 82 } 77 83 84 /** 85 * Returns a new copy of this history, sorted in descending order. 86 * @return a new copy of this history, sorted in descending order 87 */ 78 88 public History sortDescending() { 79 89 List<HistoryOsmPrimitive> copy = new ArrayList<>(versions); … … 86 96 } 87 97 } 88 98 ); 89 99 return new History(id, type,copy); 90 100 } 91 101 102 /** 103 * Returns a new partial copy of this history, from the given date 104 * @param fromDate the starting date 105 * @return a new partial copy of this history, from the given date 106 */ 92 107 public History from(final Date fromDate) { 93 108 return filter( … … 99 114 } 100 115 } 101 ); 102 } 103 116 ); 117 } 118 119 /** 120 * Returns a new partial copy of this history, until the given date 121 * @param untilDate the end date 122 * @return a new partial copy of this history, until the given date 123 */ 104 124 public History until(final Date untilDate) { 105 125 return filter( … … 111 131 } 112 132 } 113 ); 114 } 115 133 ); 134 } 135 136 /** 137 * Returns a new partial copy of this history, between the given dates 138 * @param fromDate the starting date 139 * @param untilDate the end date 140 * @return a new partial copy of this history, between the given dates 141 */ 116 142 public History between(Date fromDate, Date untilDate) { 117 143 return this.from(fromDate).until(untilDate); 118 144 } 119 145 146 /** 147 * Returns a new partial copy of this history, from the given version number 148 * @param fromVersion the starting version number 149 * @return a new partial copy of this history, from the given version number 150 */ 120 151 public History from(final long fromVersion) { 121 152 return filter( … … 127 158 } 128 159 } 129 ); 130 } 131 160 ); 161 } 162 163 /** 164 * Returns a new partial copy of this history, to the given version number 165 * @param untilVersion the ending version number 166 * @return a new partial copy of this history, to the given version number 167 */ 132 168 public History until(final long untilVersion) { 133 169 return filter( … … 139 175 } 140 176 } 141 ); 142 } 143 177 ); 178 } 179 180 /** 181 * Returns a new partial copy of this history, betwwen the given version numbers 182 * @param fromVersion the starting version number 183 * @param untilVersion the ending version number 184 * @return a new partial copy of this history, between the given version numbers 185 */ 144 186 public History between(long fromVersion, long untilVersion) { 145 187 return this.from(fromVersion).until(untilVersion); 146 188 } 147 189 190 /** 191 * Returns a new partial copy of this history, for the given user id 192 * @param uid the user id 193 * @return a new partial copy of this history, for the given user id 194 */ 148 195 public History forUserId(final long uid) { 149 196 return filter( … … 155 202 } 156 203 } 157 ); 158 } 159 204 ); 205 } 206 207 /** 208 * Replies the primitive id for this history. 209 * 210 * @return the primitive id 211 * @see #getPrimitiveId 212 * @see #getType 213 */ 160 214 public long getId() { 161 215 return id; … … 166 220 * 167 221 * @return the primitive id 222 * @see #getId 168 223 */ 169 224 public PrimitiveId getPrimitiveId() { … … 171 226 } 172 227 173 public boolean contains(long version){ 228 /** 229 * Determines if this history contains a specific version number. 230 * @param version the version number to look for 231 * @return {@code true} if this history contains {@code version}, {@code false} otherwise 232 */ 233 public boolean contains(long version) { 174 234 for (HistoryOsmPrimitive primitive: versions) { 175 235 if (primitive.matches(id,version)) … … 194 254 } 195 255 256 /** 257 * Replies the history primitive at given <code>date</code>. null, 258 * if no such primitive exists. 259 * 260 * @param date the date 261 * @return the history primitive at given <code>date</code> 262 */ 196 263 public HistoryOsmPrimitive getByDate(Date date) { 197 264 History h = sortAscending(); … … 209 276 } 210 277 278 /** 279 * Replies the history primitive at index <code>idx</code>. 280 * 281 * @param idx the index 282 * @return the history primitive at index <code>idx</code> 283 * @throws IndexOutOfBoundsException if index out or range 284 */ 211 285 public HistoryOsmPrimitive get(int idx) throws IndexOutOfBoundsException { 212 286 if (idx < 0 || idx >= versions.size()) 213 throw new IndexOutOfBoundsException(MessageFormat.format("Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx)); 287 throw new IndexOutOfBoundsException(MessageFormat.format( 288 "Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx)); 214 289 return versions.get(idx); 215 290 } 216 291 292 /** 293 * Replies the earliest entry of this history. 294 * @return the earliest entry of this history 295 */ 217 296 public HistoryOsmPrimitive getEarliest() { 218 297 if (isEmpty()) … … 221 300 } 222 301 302 /** 303 * Replies the latest entry of this history. 304 * @return the latest entry of this history 305 */ 223 306 public HistoryOsmPrimitive getLatest() { 224 307 if (isEmpty()) … … 227 310 } 228 311 312 /** 313 * Replies the number of versions. 314 * @return the number of versions 315 */ 229 316 public int getNumVersions() { 230 317 return versions.size(); … … 239 326 } 240 327 328 /** 329 * Replies the primitive type for this history. 330 * @return the primitive type 331 * @see #getId 332 */ 241 333 public OsmPrimitiveType getType() { 242 334 return type; -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r7524 r7527 29 29 import org.openstreetmap.josm.tools.WindowGeometry; 30 30 31 /** 32 * Manager allowing to show/hide history dialogs. 33 * @since 2019 34 */ 31 35 public class HistoryBrowserDialogManager implements MapView.LayerChangeListener { 36 32 37 private static HistoryBrowserDialogManager instance; 38 39 /** 40 * Replies the unique instance. 41 * @return the unique instance 42 */ 33 43 public static HistoryBrowserDialogManager getInstance() { 34 44 if (instance == null) { … … 45 55 } 46 56 57 /** 58 * Determines if an history dialog exists for the given object id. 59 * @param id the object id 60 * @return {@code true} if an history dialog exists for the given object id, {@code false} otherwise 61 */ 47 62 public boolean existsDialog(long id) { 48 63 return dialogs.containsKey(id); 49 64 } 50 65 51 p ublicvoid show(long id, HistoryBrowserDialog dialog) {66 protected void show(long id, HistoryBrowserDialog dialog) { 52 67 if (dialogs.values().contains(dialog)) { 53 68 show(id); … … 60 75 Main.debug("#10462 - JFrame.isDefaultLookAndFeelDecorated: "+JFrame.isDefaultLookAndFeelDecorated()); 61 76 Main.debug("#10462 - dialog.isUndecorated: "+dialog.isUndecorated()); 77 Main.debug("#10462 - UIManager.getLookAndFeel: "+UIManager.getLookAndFeel()); 62 78 Main.debug("#10462 - LookAndFeel.getSupportsWindowDecorations: "+UIManager.getLookAndFeel().getSupportsWindowDecorations()); 63 79 Main.debug("#10462 - JRootPane.getWindowDecorationStyle: "+dialog.getRootPane().getWindowDecorationStyle()); 64 80 Main.debug("#10462 - Window.getIconImages: "+dialog.getIconImages()); 65 81 Main.debug("#10462 - Dialog.getTitle: "+dialog.getTitle()); 82 Main.debug("#10462 - Dialog.getInsets: "+dialog.getInsets()); 66 83 } 67 84 dialogs.put(id, dialog); … … 69 86 } 70 87 71 p ublicvoid show(long id) {88 protected void show(long id) { 72 89 if (dialogs.keySet().contains(id)) { 73 90 dialogs.get(id).toFront(); … … 87 104 final String WINDOW_GEOMETRY_PREF = getClass().getName() + ".geometry"; 88 105 89 p ublicvoid placeOnScreen(HistoryBrowserDialog dialog) {106 protected void placeOnScreen(HistoryBrowserDialog dialog) { 90 107 WindowGeometry geometry = new WindowGeometry(WINDOW_GEOMETRY_PREF, WindowGeometry.centerOnScreen(new Dimension(850, 500))); 91 108 geometry.applySafe(dialog); 92 109 Point p = dialog.getLocation(); 93 while (hasDialogWithCloseUpperLeftCorner(p)) {110 while (hasDialogWithCloseUpperLeftCorner(p)) { 94 111 p.x += 20; 95 112 p.y += 20; … … 98 115 } 99 116 117 /** 118 * Hides the specified history dialog and cleans associated resources. 119 * @param dialog History dialog to hide 120 */ 100 121 public void hide(HistoryBrowserDialog dialog) { 101 122 long id = 0; … … 129 150 } 130 151 152 /** 153 * Show history dialog for the given history. 154 * @param h History to show 155 */ 131 156 public void show(History h) { 132 157 if (h == null) … … 151 176 public void layerRemoved(Layer oldLayer) { 152 177 // remove all history browsers if the number of layers drops to 0 153 //154 178 if (Main.isDisplayingMapView() && Main.map.mapView.getNumLayers() == 0) { 155 179 hideAll(); … … 157 181 } 158 182 183 /** 184 * Show history dialog(s) for the given primitive(s). 185 * @param primitives The primitive(s) for which history will be displayed 186 */ 159 187 public void showHistory(final Collection<? extends PrimitiveId> primitives) { 160 188 final Collection<? extends PrimitiveId> notNewPrimitives = Utils.filter(primitives, notNewPredicate);
Note:
See TracChangeset
for help on using the changeset viewer.