Changeset 8332 in josm for trunk/src/org
- Timestamp:
- 2015-05-06T00:23:51+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java
r8240 r8332 9 9 import java.util.List; 10 10 import java.util.Map; 11 import java.util.Map.Entry; 11 12 import java.util.concurrent.Future; 12 13 import java.util.regex.Matcher; … … 128 129 private final Map<OsmPrimitive, Date> toLoad; 129 130 130 p ublicHistoryLoaderAndListener(Map<OsmPrimitive, Date> toLoad) {131 private HistoryLoaderAndListener(Map<OsmPrimitive, Date> toLoad) { 131 132 this.toLoad = toLoad; 132 133 add(toLoad.keySet()); … … 138 139 public void historyUpdated(HistoryDataSet source, PrimitiveId id) { 139 140 Map<OsmPrimitive, Date> toLoadNext = new HashMap<>(); 140 for (Iterator<OsmPrimitive> it = toLoad.keySet().iterator(); it.hasNext();) { 141 OsmPrimitive p = it.next(); 141 for (Iterator<Entry<OsmPrimitive, Date>> it = toLoad.entrySet().iterator(); it.hasNext();) { 142 Entry<OsmPrimitive, Date> entry = it.next(); 143 OsmPrimitive p = entry.getKey(); 142 144 History history = source.getHistory(p.getPrimitiveId()); 143 Date date = toLoad.get(p);145 Date date = entry.getValue(); 144 146 // If the history has been loaded and a timestamp is known 145 147 if (history != null && date != null) { -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r8285 r8332 573 573 public boolean allElements; 574 574 575 /** 576 * Constructs a new {@code SearchSetting}. 577 */ 575 578 public SearchSetting() { 576 579 this("", SearchMode.replace, false /* case insensitive */, -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
r8308 r8332 27 27 import java.util.HashMap; 28 28 import java.util.List; 29 import java.util.Map; 30 31 import org.openstreetmap.josm.Main; 29 32 30 33 /** … … 86 89 } 87 90 91 private void readBytes(InputStream in, byte[] b) throws IOException { 92 if (in.read(b) < b.length) { 93 Main.error("Failed to read expected amount of bytes ("+ b.length +") from stream"); 94 } 95 } 96 88 97 /** 89 98 * Load a Grid Shift File from an InputStream. The Grid Shift node … … 98 107 * @throws IOException 99 108 */ 100 public void loadGridShiftFile(InputStream in, boolean loadAccuracy 109 public void loadGridShiftFile(InputStream in, boolean loadAccuracy) throws IOException { 101 110 byte[] b8 = new byte[8]; 102 111 boolean bigEndian = true; … … 104 113 toEllipsoid = ""; 105 114 topLevelSubGrid = null; 106 in.read(b8);115 readBytes(in, b8); 107 116 String overviewHeaderCountId = new String(b8, StandardCharsets.UTF_8); 108 117 if (!"NUM_OREC".equals(overviewHeaderCountId)) 109 118 throw new IllegalArgumentException("Input file is not an NTv2 grid shift file"); 110 in.read(b8);119 readBytes(in, b8); 111 120 overviewHeaderCount = NTV2Util.getIntBE(b8, 0); 112 121 if (overviewHeaderCount == 11) { … … 119 128 throw new IllegalArgumentException("Input file is not an NTv2 grid shift file"); 120 129 } 121 in.read(b8);122 in.read(b8);130 readBytes(in, b8); 131 readBytes(in, b8); 123 132 subGridHeaderCount = NTV2Util.getInt(b8, bigEndian); 124 in.read(b8);125 in.read(b8);133 readBytes(in, b8); 134 readBytes(in, b8); 126 135 subGridCount = NTV2Util.getInt(b8, bigEndian); 127 136 NTV2SubGrid[] subGrid = new NTV2SubGrid[subGridCount]; 128 in.read(b8);129 in.read(b8);137 readBytes(in, b8); 138 readBytes(in, b8); 130 139 shiftType = new String(b8, StandardCharsets.UTF_8); 131 in.read(b8);132 in.read(b8);140 readBytes(in, b8); 141 readBytes(in, b8); 133 142 version = new String(b8, StandardCharsets.UTF_8); 134 in.read(b8);135 in.read(b8);143 readBytes(in, b8); 144 readBytes(in, b8); 136 145 fromEllipsoid = new String(b8, StandardCharsets.UTF_8); 137 in.read(b8);138 in.read(b8);146 readBytes(in, b8); 147 readBytes(in, b8); 139 148 toEllipsoid = new String(b8, StandardCharsets.UTF_8); 140 in.read(b8);141 in.read(b8);149 readBytes(in, b8); 150 readBytes(in, b8); 142 151 fromSemiMajorAxis = NTV2Util.getDouble(b8, bigEndian); 143 in.read(b8);144 in.read(b8);152 readBytes(in, b8); 153 readBytes(in, b8); 145 154 fromSemiMinorAxis = NTV2Util.getDouble(b8, bigEndian); 146 in.read(b8);147 in.read(b8);155 readBytes(in, b8); 156 readBytes(in, b8); 148 157 toSemiMajorAxis = NTV2Util.getDouble(b8, bigEndian); 149 in.read(b8);150 in.read(b8);158 readBytes(in, b8); 159 readBytes(in, b8); 151 160 toSemiMinorAxis = NTV2Util.getDouble(b8, bigEndian); 152 161 … … 166 175 private NTV2SubGrid[] createSubGridTree(NTV2SubGrid[] subGrid) { 167 176 int topLevelCount = 0; 168 HashMap<String, List<NTV2SubGrid>> subGridMap = new HashMap<>();177 Map<String, List<NTV2SubGrid>> subGridMap = new HashMap<>(); 169 178 for (int i = 0; i < subGrid.length; i++) { 170 179 if ("NONE".equalsIgnoreCase(subGrid[i].getParentSubGridName())) { … … 321 330 return toEllipsoid; 322 331 } 323 324 332 } -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
r8308 r8332 75 75 byte[] b4 = new byte[4]; 76 76 byte[] b1 = new byte[1]; 77 in.read(b8);78 in.read(b8);77 readBytes(in, b8); 78 readBytes(in, b8); 79 79 subGridName = new String(b8, StandardCharsets.UTF_8).trim(); 80 in.read(b8);81 in.read(b8);80 readBytes(in, b8); 81 readBytes(in, b8); 82 82 parentSubGridName = new String(b8, StandardCharsets.UTF_8).trim(); 83 in.read(b8);84 in.read(b8);83 readBytes(in, b8); 84 readBytes(in, b8); 85 85 created = new String(b8, StandardCharsets.UTF_8); 86 in.read(b8);87 in.read(b8);86 readBytes(in, b8); 87 readBytes(in, b8); 88 88 updated = new String(b8, StandardCharsets.UTF_8); 89 in.read(b8);90 in.read(b8);89 readBytes(in, b8); 90 readBytes(in, b8); 91 91 minLat = NTV2Util.getDouble(b8, bigEndian); 92 in.read(b8);93 in.read(b8);92 readBytes(in, b8); 93 readBytes(in, b8); 94 94 maxLat = NTV2Util.getDouble(b8, bigEndian); 95 in.read(b8);96 in.read(b8);95 readBytes(in, b8); 96 readBytes(in, b8); 97 97 minLon = NTV2Util.getDouble(b8, bigEndian); 98 in.read(b8);99 in.read(b8);98 readBytes(in, b8); 99 readBytes(in, b8); 100 100 maxLon = NTV2Util.getDouble(b8, bigEndian); 101 in.read(b8);102 in.read(b8);101 readBytes(in, b8); 102 readBytes(in, b8); 103 103 latInterval = NTV2Util.getDouble(b8, bigEndian); 104 in.read(b8);105 in.read(b8);104 readBytes(in, b8); 105 readBytes(in, b8); 106 106 lonInterval = NTV2Util.getDouble(b8, bigEndian); 107 107 lonColumnCount = 1 + (int)((maxLon - minLon) / lonInterval); 108 108 latRowCount = 1 + (int)((maxLat - minLat) / latInterval); 109 in.read(b8);110 in.read(b8);109 readBytes(in, b8); 110 readBytes(in, b8); 111 111 nodeCount = NTV2Util.getInt(b8, bigEndian); 112 112 if (nodeCount != lonColumnCount * latRowCount) … … 123 123 // certain VM which are not able to read byte blocks when the resource file is 124 124 // in a .jar file (Pieren) 125 in.read(b1); b4[0] = b1[0];126 in.read(b1); b4[1] = b1[0];127 in.read(b1); b4[2] = b1[0];128 in.read(b1); b4[3] = b1[0];125 readBytes(in, b1); b4[0] = b1[0]; 126 readBytes(in, b1); b4[1] = b1[0]; 127 readBytes(in, b1); b4[2] = b1[0]; 128 readBytes(in, b1); b4[3] = b1[0]; 129 129 latShift[i] = NTV2Util.getFloat(b4, bigEndian); 130 in.read(b1); b4[0] = b1[0];131 in.read(b1); b4[1] = b1[0];132 in.read(b1); b4[2] = b1[0];133 in.read(b1); b4[3] = b1[0];130 readBytes(in, b1); b4[0] = b1[0]; 131 readBytes(in, b1); b4[1] = b1[0]; 132 readBytes(in, b1); b4[2] = b1[0]; 133 readBytes(in, b1); b4[3] = b1[0]; 134 134 lonShift[i] = NTV2Util.getFloat(b4, bigEndian); 135 in.read(b1); b4[0] = b1[0];136 in.read(b1); b4[1] = b1[0];137 in.read(b1); b4[2] = b1[0];138 in.read(b1); b4[3] = b1[0];135 readBytes(in, b1); b4[0] = b1[0]; 136 readBytes(in, b1); b4[1] = b1[0]; 137 readBytes(in, b1); b4[2] = b1[0]; 138 readBytes(in, b1); b4[3] = b1[0]; 139 139 if (loadAccuracy) { 140 140 latAccuracy[i] = NTV2Util.getFloat(b4, bigEndian); 141 141 } 142 in.read(b1); b4[0] = b1[0];143 in.read(b1); b4[1] = b1[0];144 in.read(b1); b4[2] = b1[0];145 in.read(b1); b4[3] = b1[0];142 readBytes(in, b1); b4[0] = b1[0]; 143 readBytes(in, b1); b4[1] = b1[0]; 144 readBytes(in, b1); b4[2] = b1[0]; 145 readBytes(in, b1); b4[3] = b1[0]; 146 146 if (loadAccuracy) { 147 147 lonAccuracy[i] = NTV2Util.getFloat(b4, bigEndian); 148 148 } 149 } 150 } 151 152 private void readBytes(InputStream in, byte[] b) throws IOException { 153 if (in.read(b) < b.length) { 154 Main.error("Failed to read expected amount of bytes ("+ b.length +") from stream"); 149 155 } 150 156 } … … 194 200 * Bi-Linear interpolation of four nearest node values as described in 195 201 * 'GDAit Software Architecture Manual' produced by the <a 196 * href='http://www. sli.unimelb.edu.au/gda94'>Geomatics197 * Department of the University of Melbourne</a>202 * href='http://www.dtpli.vic.gov.au/property-and-land-titles/geodesy/geocentric-datum-of-australia-1994-gda94/gda94-useful-tools'> 203 * Geomatics Department of the University of Melbourne</a> 198 204 * @param a value at the A node 199 205 * @param b value at the B node 200 206 * @param c value at the C node 201 207 * @param d value at the D node 202 * @param XLongitude factor203 * @param YLatitude factor208 * @param x Longitude factor 209 * @param y Latitude factor 204 210 * @return interpolated value 205 211 */ 206 private final double interpolate(float a, float b, float c, float d, double X, double Y) {207 return a + (((double)b - (double)a) * X) + (((double)c - (double)a) * Y) +208 (((double)a + (double)d - b - c) * X * Y);212 private final double interpolate(float a, float b, float c, float d, double x, double y) { 213 return a + (((double)b - (double)a) * x) + (((double)c - (double)a) * y) + 214 (((double)a + (double)d - b - c) * x * y); 209 215 } 210 216 … … 213 219 * of the GridShiftFile. The algorithm is described in 214 220 * 'GDAit Software Architecture Manual' produced by the <a 215 * href='http://www. sli.unimelb.edu.au/gda94'>Geomatics216 * Department of the University of Melbourne</a>221 * href='http://www.dtpli.vic.gov.au/property-and-land-titles/geodesy/geocentric-datum-of-australia-1994-gda94/gda94-useful-tools'> 222 * Geomatics Department of the University of Melbourne</a> 217 223 * <p>This method is thread safe for both memory based and file based node data. 218 224 * @param gs GridShift object containing the coordinate to shift and the shift values -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java
r8308 r8332 68 68 private JPanel pnlTagResolver; 69 69 70 /** 71 * Constructs a new {@code PasteTagsConflictResolverDialog}. 72 * @param owner parent component 73 */ 70 74 public PasteTagsConflictResolverDialog(Component owner) { 71 75 super(JOptionPane.getFrameForComponent(owner), ModalityType.DOCUMENT_MODAL); … … 114 118 ApplyAction applyAction = new ApplyAction(); 115 119 allPrimitivesResolver.getModel().addPropertyChangeListener(applyAction); 116 for ( OsmPrimitiveType type: resolvers.keySet()) {117 r esolvers.get(type).getModel().addPropertyChangeListener(applyAction);120 for (TagConflictResolver r : resolvers.values()) { 121 r.getModel().addPropertyChangeListener(applyAction); 118 122 } 119 123 pnl.add(new SideButton(applyAction)); … … 266 270 class CancelAction extends AbstractAction { 267 271 268 p ublicCancelAction() {272 private CancelAction() { 269 273 putValue(Action.SHORT_DESCRIPTION, tr("Cancel conflict resolution")); 270 274 putValue(Action.NAME, tr("Cancel")); … … 282 286 class ApplyAction extends AbstractAction implements PropertyChangeListener { 283 287 284 p ublicApplyAction() {288 private ApplyAction() { 285 289 putValue(Action.SHORT_DESCRIPTION, tr("Apply resolved conflicts")); 286 290 putValue(Action.NAME, tr("Apply")); … … 354 358 } 355 359 356 p ublicstatic class StatisticsInfo {360 private static class StatisticsInfo { 357 361 public int numTags; 358 362 public Map<OsmPrimitiveType, Integer> sourceInfo; 359 363 public Map<OsmPrimitiveType, Integer> targetInfo; 360 364 361 p ublicStatisticsInfo() {365 private StatisticsInfo() { 362 366 sourceInfo = new HashMap<>(); 363 367 targetInfo = new HashMap<>(); … … 366 370 367 371 private static class StatisticsTableColumnModel extends DefaultTableColumnModel { 368 p ublicStatisticsTableColumnModel() {372 private StatisticsTableColumnModel() { 369 373 TableCellRenderer renderer = new StatisticsInfoRenderer(); 370 374 TableColumn col = null; … … 397 401 private transient List<StatisticsInfo> data; 398 402 399 p ublicStatisticsTableModel() {403 private StatisticsTableModel() { 400 404 data = new ArrayList<>(); 401 405 } … … 516 520 } 517 521 518 p ublicStatisticsInfoTable(StatisticsTableModel model) {522 private StatisticsInfoTable(StatisticsTableModel model) { 519 523 build(model); 520 524 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
r8285 r8332 9 9 import java.util.Map; 10 10 import java.util.Map.Entry; 11 import java.util.Objects; 11 12 12 13 import org.openstreetmap.josm.data.osm.Relation; … … 121 122 // lookup the entry for editor and remove it 122 123 // 123 for (DialogContext context: openDialogs.keySet()) { 124 if (openDialogs.get(context) == editor) { 125 openDialogs.remove(context); 124 for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext();) { 125 Entry<DialogContext, RelationEditor> entry = it.next(); 126 if (Objects.equals(entry.getValue(), editor)) { 127 it.remove(); 126 128 break; 127 129 } … … 215 217 public void windowClosed(WindowEvent e) { 216 218 RelationEditor editor = (RelationEditor)e.getWindow(); 217 DialogContext context = null; 218 for (DialogContext c : openDialogs.keySet()) { 219 if (editor.equals(openDialogs.get(c))) { 220 context = c; 219 for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext(); ) { 220 if (editor.equals(it.next().getValue())) { 221 it.remove(); 221 222 break; 222 223 } 223 }224 if (context != null) {225 openDialogs.remove(context);226 224 } 227 225 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r8285 r8332 9 9 import java.util.Collection; 10 10 import java.util.HashMap; 11 import java.util.Iterator; 11 12 import java.util.List; 12 13 import java.util.Map; 14 import java.util.Map.Entry; 15 import java.util.Objects; 13 16 14 17 import javax.swing.JOptionPane; … … 105 108 */ 106 109 public void hide(HistoryBrowserDialog dialog) { 107 long id = 0; 108 for (long i: dialogs.keySet()) { 109 if (dialogs.get(i) == dialog) { 110 id = i; 110 for (Iterator<Entry<Long, HistoryBrowserDialog>> it = dialogs.entrySet().iterator(); it.hasNext(); ) { 111 if (Objects.equals(it.next().getValue(), dialog)) { 112 it.remove(); 113 if (dialogs.isEmpty()) { 114 new WindowGeometry(dialog).remember(WINDOW_GEOMETRY_PREF); 115 } 111 116 break; 112 }113 }114 if (id > 0) {115 dialogs.remove(id);116 if (dialogs.isEmpty()) {117 new WindowGeometry(dialog).remember(WINDOW_GEOMETRY_PREF);118 117 } 119 118 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r8323 r8332 11 11 import java.awt.FlowLayout; 12 12 import java.awt.GridBagLayout; 13 import java.awt.Image;14 13 import java.awt.event.ActionEvent; 15 14 import java.awt.event.KeyEvent; … … 28 27 import javax.swing.BorderFactory; 29 28 import javax.swing.Icon; 30 import javax.swing.ImageIcon;31 29 import javax.swing.JButton; 32 30 import javax.swing.JComponent; -
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
r8308 r8332 20 20 import java.util.HashMap; 21 21 import java.util.Map; 22 import java.util.Map.Entry; 22 23 23 24 import javax.swing.BorderFactory; … … 275 276 protected UploadStrategy getUploadStrategy() { 276 277 UploadStrategy strategy = null; 277 for ( UploadStrategy s: rbStrategy.keySet()) {278 if ( rbStrategy.get(s).isSelected()) {279 strategy = s;278 for (Entry<UploadStrategy, JRadioButton> e : rbStrategy.entrySet()) { 279 if (e.getValue().isSelected()) { 280 strategy = e.getKey(); 280 281 break; 281 282 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r8323 r8332 12 12 import java.awt.Graphics2D; 13 13 import java.awt.GridBagLayout; 14 import java.awt.Image;15 14 import java.awt.Point; 16 15 import java.awt.Rectangle; … … 34 33 import javax.swing.Action; 35 34 import javax.swing.Icon; 36 import javax.swing.ImageIcon;37 35 import javax.swing.JLabel; 38 36 import javax.swing.JOptionPane; -
trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
r7864 r8332 7 7 import java.util.List; 8 8 import java.util.Map; 9 import java.util.Map.Entry; 9 10 import java.util.regex.Pattern; 10 11 … … 204 205 public String toString() { 205 206 StringBuilder res = new StringBuilder("Cascade{ "); 206 for ( String key : prop.keySet()) {207 res.append( key+":");208 Object val = prop.get(key);207 for (Entry<String, Object> entry : prop.entrySet()) { 208 res.append(entry.getKey()+":"); 209 Object val = entry.getValue(); 209 210 if (val instanceof float[]) { 210 211 res.append(Arrays.toString((float[]) val)); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r8285 r8332 29 29 import java.util.List; 30 30 import java.util.Map; 31 import java.util.Map.Entry; 31 32 import java.util.TreeSet; 32 33 … … 1123 1124 1124 1125 if (display != null) { 1125 for ( String val : lhm.keySet()) {1126 String k = lhm.get(val).toString();1126 for (Entry<String, PresetListEntry> entry : lhm.entrySet()) { 1127 String k = entry.getValue().toString(); 1127 1128 if (k != null && k.equals(display)) { 1128 value = val;1129 value = entry.getKey(); 1129 1130 break; 1130 1131 } -
trunk/src/org/openstreetmap/josm/io/AbstractReader.java
r8291 r8332 9 9 import java.util.List; 10 10 import java.util.Map; 11 import java.util.Map.Entry; 11 12 12 13 import org.openstreetmap.josm.Main; … … 82 83 */ 83 84 protected void processWaysAfterParsing() throws IllegalDataException{ 84 for (Long externalWayId: ways.keySet()) { 85 for (Entry<Long, Collection<Long>> entry : ways.entrySet()) { 86 Long externalWayId = entry.getKey(); 85 87 Way w = (Way)externalIdMap.get(new SimplePrimitiveId(externalWayId, OsmPrimitiveType.WAY)); 86 88 List<Node> wayNodes = new ArrayList<>(); 87 for (long id : ways.get(externalWayId)) {89 for (long id : entry.getValue()) { 88 90 Node n = (Node)externalIdMap.get(new SimplePrimitiveId(id, OsmPrimitiveType.NODE)); 89 91 if (n == null) { … … 132 134 } 133 135 134 for (Long externalRelationId : relations.keySet()) { 136 for (Entry<Long, Collection<RelationMemberData>> entry : relations.entrySet()) { 137 Long externalRelationId = entry.getKey(); 135 138 Relation relation = (Relation) externalIdMap.get( 136 139 new SimplePrimitiveId(externalRelationId, OsmPrimitiveType.RELATION) 137 140 ); 138 141 List<RelationMember> relationMembers = new ArrayList<>(); 139 for (RelationMemberData rm : relations.get(externalRelationId)) {142 for (RelationMemberData rm : entry.getValue()) { 140 143 OsmPrimitive primitive = null; 141 144 -
trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
r7434 r8332 19 19 * use {@link RuntimeException} if no exception must be handled. 20 20 * @author xeen 21 * 21 * @since 1450 22 22 */ 23 23 public abstract class CacheCustomContent<T extends Throwable> { 24 /** 25 * Common intervals 26 */ 24 25 /** Update interval meaning an update is always needed */ 27 26 public static final int INTERVAL_ALWAYS = -1; 27 /** Update interval meaning an update is needed each hour */ 28 28 public static final int INTERVAL_HOURLY = 60*60; 29 /** Update interval meaning an update is needed each day */ 29 30 public static final int INTERVAL_DAILY = INTERVAL_HOURLY * 24; 31 /** Update interval meaning an update is needed each week */ 30 32 public static final int INTERVAL_WEEKLY = INTERVAL_DAILY * 7; 33 /** Update interval meaning an update is needed each month */ 31 34 public static final int INTERVAL_MONTHLY = INTERVAL_WEEKLY * 4; 35 /** Update interval meaning an update is never needed */ 32 36 public static final int INTERVAL_NEVER = Integer.MAX_VALUE; 33 37 … … 61 65 62 66 /** 63 * This function serves as a comfort hook to perform additional checks if the cache is valid64 * @return True if the cached copy is still valid65 */66 protected boolean isCacheValid() {67 return true;68 }69 70 /**71 67 * Initializes the class. Note that all read data will be stored in memory until it is flushed 72 68 * by flushData(). 73 * @param ident 74 * @param updateInterval 69 * @param ident ident that identifies the stored file. Includes file-ending. 70 * @param updateInterval update interval in seconds. -1 means always 75 71 */ 76 72 public CacheCustomContent(String ident, int updateInterval) { … … 78 74 this.updateInterval = updateInterval; 79 75 this.path = new File(Main.pref.getCacheDirectory(), ident); 76 } 77 78 /** 79 * This function serves as a comfort hook to perform additional checks if the cache is valid 80 * @return True if the cached copy is still valid 81 */ 82 protected boolean isCacheValid() { 83 return true; 80 84 } 81 85 … … 104 108 * Updates data if required 105 109 * @return Returns the data 110 * @throws T if an error occurs 106 111 */ 107 112 public byte[] updateIfRequired() throws T { … … 114 119 * Updates data if required 115 120 * @return Returns the data as string 121 * @throws T if an error occurs 116 122 */ 117 123 public String updateIfRequiredString() throws T { … … 124 130 * Executes an update regardless of updateInterval 125 131 * @return Returns the data 132 * @throws T if an error occurs 126 133 */ 127 134 public byte[] updateForce() throws T { … … 135 142 * Executes an update regardless of updateInterval 136 143 * @return Returns the data as String 144 * @throws T if an error occurs 137 145 */ 138 146 public String updateForceString() throws T { … … 144 152 * Returns the data without performing any updates 145 153 * @return the data 154 * @throws T if an error occurs 146 155 */ 147 156 public byte[] getData() throws T { … … 155 164 * Returns the data without performing any updates 156 165 * @return the data as String 166 * @throws T if an error occurs 157 167 */ 158 168 public String getDataString() throws T { … … 170 180 try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(path))) { 171 181 this.data = new byte[input.available()]; 172 input.read(this.data); 182 if (input.read(this.data) < this.data.length) { 183 Main.error("Failed to read expected contents from "+path); 184 } 173 185 } catch (IOException e) { 174 186 if (!isOffline()) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r8308 r8332 15 15 import java.util.HashSet; 16 16 import java.util.Map; 17 import java.util.Map.Entry; 17 18 import java.util.Set; 18 19 … … 94 95 95 96 private String getToolTip() { 96 StringBuilder sb =new StringBuilder();97 StringBuilder sb = new StringBuilder(); 97 98 sb.append("<html>"); 98 99 sb.append(tr("Old values of")); … … 100 101 sb.append(tag); 101 102 sb.append("</b><br/>"); 102 for ( String k: valueCount.keySet()) {103 for (Entry<String, Integer> e : valueCount.entrySet()) { 103 104 sb.append("<b>"); 104 sb.append( valueCount.get(k));105 sb.append(e.getValue()); 105 106 sb.append(" x </b>"); 106 sb.append( k);107 sb.append(e.getKey()); 107 108 sb.append("<br/>"); 108 109 } 109 110 sb.append("</html>"); 110 111 return sb.toString(); 111 112 112 } 113 113 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r8285 r8332 12 12 import java.util.List; 13 13 import java.util.Map; 14 import java.util.Map.Entry; 14 15 15 16 import org.openstreetmap.josm.Main; … … 119 120 * Find the node with almost the same ccords in dataset or in already added nodes 120 121 * @since 5845 121 * */122 */ 122 123 Node findOrCreateNode(LatLon ll, List<Command> commands) { 123 124 Node nd = null; … … 132 133 133 134 Node prev = null; 134 for (LatLon lOld: addedNodes.keySet()) { 135 for (Entry<LatLon, Node> entry : addedNodes.entrySet()) { 136 LatLon lOld = entry.getKey(); 135 137 if (lOld.greatCircleDistance(ll) < Main.pref.getDouble("remotecontrol.tolerance", 0.1)) { 136 prev = addedNodes.get(lOld);138 prev = entry.getValue(); 137 139 break; 138 140 } -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r7326 r8332 484 484 485 485 layers = new ArrayList<>(); 486 for ( int idx : layersMap.keySet()) {487 Layer layer = layersMap.get(idx);486 for (Entry<Integer, Layer> entry : layersMap.entrySet()) { 487 Layer layer = entry.getValue(); 488 488 if (layer == null) { 489 489 continue; 490 490 } 491 Element el = elems.get( idx);491 Element el = elems.get(entry.getKey()); 492 492 if (el.hasAttribute("visible")) { 493 493 layer.setVisible(Boolean.parseBoolean(el.getAttribute("visible"))); -
trunk/src/org/openstreetmap/josm/tools/MultiMap.java
r7276 r8332 231 231 public String toString() { 232 232 List<String> entries = new ArrayList<>(map.size()); 233 for ( A key : map.keySet()) {234 entries.add( key + "->{" + Utils.join(",", map.get(key)) + "}");233 for (Entry<A, Set<B>> entry : map.entrySet()) { 234 entries.add(entry.getKey() + "->{" + Utils.join(",", entry.getValue()) + "}"); 235 235 } 236 236 return "(" + Utils.join(",", entries) + ")";
Note:
See TracChangeset
for help on using the changeset viewer.