Changeset 11651 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-03-03T01:31:34+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r10742 r11651 17 17 18 18 public class OffsetBookmark { 19 p ublicstatic final List<OffsetBookmark> allBookmarks = new ArrayList<>();19 private static final List<OffsetBookmark> allBookmarks = new ArrayList<>(); 20 20 21 21 public String projectionCode; … … 94 94 } 95 95 96 /** 97 * Returns all bookmarks. 98 * @return all bookmarks (unmodifiable collection) 99 * @since 11651 100 */ 101 public static List<OffsetBookmark> getBookmarks() { 102 return Collections.unmodifiableList(allBookmarks); 103 } 104 105 /** 106 * Returns the number of bookmarks. 107 * @return the number of bookmarks 108 * @since 11651 109 */ 110 public static int getBookmarksSize() { 111 return allBookmarks.size(); 112 } 113 114 /** 115 * Adds a bookmark. 116 * @param ob bookmark to add 117 * @return {@code true} 118 * @since 11651 119 */ 120 public static boolean addBookmark(OffsetBookmark ob) { 121 return allBookmarks.add(ob); 122 } 123 124 /** 125 * Removes a bookmark. 126 * @param ob bookmark to remove 127 * @return {@code true} if this list contained the specified element 128 * @since 11651 129 */ 130 public static boolean removeBookmark(OffsetBookmark ob) { 131 return allBookmarks.remove(ob); 132 } 133 134 /** 135 * Returns the bookmark at the given index. 136 * @param index bookmark index 137 * @return the bookmark at the given index 138 * @throws IndexOutOfBoundsException if the index is out of range 139 * (<tt>index < 0 || index >= size()</tt>) 140 * @since 11651 141 */ 142 public static OffsetBookmark getBookmarkByIndex(int index) { 143 return allBookmarks.get(index); 144 } 145 96 146 public static OffsetBookmark getBookmarkByName(ImageryLayer layer, String name) { 97 147 for (OffsetBookmark b : allBookmarks) { -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r11581 r11651 231 231 public JComponent getOffsetMenuItem(JComponent subMenu) { 232 232 JMenuItem adjustMenuItem = new JMenuItem(getAdjustAction()); 233 if (OffsetBookmark.allBookmarks.isEmpty()) return adjustMenuItem; 233 List<OffsetBookmark> allBookmarks = OffsetBookmark.getBookmarks(); 234 if (allBookmarks.isEmpty()) return adjustMenuItem; 234 235 235 236 subMenu.add(adjustMenuItem); … … 237 238 boolean hasBookmarks = false; 238 239 int menuItemHeight = 0; 239 for (OffsetBookmark b : OffsetBookmark.allBookmarks) {240 for (OffsetBookmark b : allBookmarks) { 240 241 if (!b.isUsable(this)) { 241 242 continue; -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r11641 r11651 806 806 807 807 static class OffsetBookmarksPanel extends JPanel { 808 private final transient List<OffsetBookmark> bookmarks = OffsetBookmark.allBookmarks;809 808 private final OffsetsBookmarksModel model = new OffsetsBookmarksModel(); 810 809 … … 868 867 869 868 private OffsetBookmark getRow(int row) { 870 return bookmarks.get(row);869 return OffsetBookmark.getBookmarkByIndex(row); 871 870 } 872 871 873 872 private void addRow(OffsetBookmark i) { 874 bookmarks.add(i);873 OffsetBookmark.addBookmark(i); 875 874 int p = getRowCount() - 1; 876 875 fireTableRowsInserted(p, p); … … 879 878 @Override 880 879 public void removeRow(int i) { 881 bookmarks.remove(getRow(i));880 OffsetBookmark.removeBookmark(getRow(i)); 882 881 fireTableRowsDeleted(i, i); 883 882 } … … 885 884 @Override 886 885 public int getRowCount() { 887 return bookmarks.size();886 return OffsetBookmark.getBookmarksSize(); 888 887 } 889 888 890 889 @Override 891 890 public Object getValueAt(int row, int column) { 892 OffsetBookmark info = bookmarks.get(row);891 OffsetBookmark info = OffsetBookmark.getBookmarkByIndex(row); 893 892 switch (column) { 894 893 case 0: … … 910 909 @Override 911 910 public void setValueAt(Object o, int row, int column) { 912 OffsetBookmark info = bookmarks.get(row);911 OffsetBookmark info = OffsetBookmark.getBookmarkByIndex(row); 913 912 switch (column) { 914 913 case 1:
Note:
See TracChangeset
for help on using the changeset viewer.