Changeset 8443 in josm
- Timestamp:
- 2015-06-02T16:40:38+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 57 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r8412 r8443 505 505 Main.map = map; 506 506 507 for (MapFrameListener listener : mapFrameListeners 507 for (MapFrameListener listener : mapFrameListeners) { 508 508 listener.mapFrameInitialized(old, map); 509 509 } -
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r7771 r8443 93 93 // 94 94 int max = Math.min(10, primitivesToShow.size()); 95 if (primitivesToShow.size() > max && ! 95 if (primitivesToShow.size() > max && !confirmLaunchMultiple(primitivesToShow.size())) 96 96 return; 97 97 for(int i = 0; i < max; i++) { -
trunk/src/org/openstreetmap/josm/actions/AbstractMergeAction.java
r7017 r8443 68 68 ExtendedDialog ed = new ExtendedDialog(Main.parent, 69 69 tr("Select target layer"), 70 new String[] { tr("Merge"), tr("Cancel")});71 ed.setButtonIcons(new String[] { "dialogs/mergedown", "cancel"});70 new String[] {tr("Merge"), tr("Cancel")}); 71 ed.setButtonIcons(new String[] {"dialogs/mergedown", "cancel"}); 72 72 ed.setContent(pnl); 73 73 ed.showDialog(); -
trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
r8393 r8443 127 127 } 128 128 129 return new Node[] { nodea, nodeb};129 return new Node[] {nodea, nodeb}; 130 130 } 131 131 … … 155 155 } 156 156 157 return new Node[] { node1, node2};157 return new Node[] {node1, node2}; 158 158 } 159 159 -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r8440 r8443 511 511 512 512 for (NodePair pair: edges) { 513 if (!undirectedEdges.contains(pair) && ! 513 if (!undirectedEdges.contains(pair) && !undirectedEdges.contains(pair.swap())) { 514 514 undirectedEdges.add(pair); 515 515 } … … 616 616 while(!nextPairs.isEmpty()) { 617 617 NodePair cur= nextPairs.pop(); 618 if (! path.contains(cur) && !path.contains(cur.swap())) {618 if (!path.contains(cur) && !path.contains(cur.swap())) { 619 619 while(!path.isEmpty() && !path.peek().isPredecessorOf(cur)) { 620 620 path.pop(); -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r8419 r8443 348 348 Set<String> conflictingKeys = new TreeSet<>(); 349 349 350 for ( RelationMember m : relation.getMembers()) {351 352 if ( m.hasRole() && "inner".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys()) {350 for (RelationMember m : relation.getMembers()) { 351 352 if (m.hasRole() && "inner".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys()) { 353 353 innerWays.add(m.getWay()); 354 354 } 355 355 356 if ( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys()) {356 if (m.hasRole() && "outer".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys()) { 357 357 Way way = m.getWay(); 358 358 outerWays.add(way); … … 403 403 if (moveTags) { 404 404 // remove duplicated tags from outer ways 405 for ( Way way : outerWays) {406 if ( way.hasKey(key)) {405 for (Way way : outerWays) { 406 if (way.hasKey(key)) { 407 407 affectedWays.add(way); 408 408 } … … 422 422 for (Entry<String, String> entry : values.entrySet()) { 423 423 String key = entry.getKey(); 424 if (!r2.hasKey(key) && !"area".equals(key) 424 if (!r2.hasKey(key) && !"area".equals(key)) { 425 425 if (relation.isNew()) 426 426 relation.put(key, entry.getValue()); -
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r7722 r8443 42 42 dialog.restoreSettings(); 43 43 dialog.setVisible(true); 44 if (! 44 if (!dialog.isCanceled()) { 45 45 dialog.rememberSettings(); 46 46 Bounds area = dialog.getSelectedDownloadArea(); -
trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java
r8291 r8443 79 79 public void export(Layer layer) { 80 80 CheckParameterUtil.ensureParameterNotNull(layer, "layer"); 81 if (! (layer instanceof OsmDataLayer) && !(layer instanceof GpxLayer))81 if (!(layer instanceof OsmDataLayer) && !(layer instanceof GpxLayer)) 82 82 throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer or GpxLayer. Got ''{0}''.", layer.getClass().getName())); 83 83 -
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r8441 r8443 194 194 super(Main.parent, 195 195 tr("Adjust imagery offset"), 196 new String[] { tr("OK"),tr("Cancel")},196 new String[] {tr("OK"),tr("Cancel")}, 197 197 false); 198 setButtonIcons(new String[] { "ok", "cancel"});198 setButtonIcons(new String[] {"ok", "cancel"}); 199 199 contentInsets = new Insets(10, 15, 5, 15); 200 200 JPanel pnl = new JPanel(new GridBagLayout()); … … 229 229 String ostr = tOffset.getText(); 230 230 int semicolon = ostr.indexOf(';'); 231 if ( semicolon >= 0 && semicolon + 1 < ostr.length()) {231 if (semicolon >= 0 && semicolon + 1 < ostr.length()) { 232 232 try { 233 233 // here we assume that Double.parseDouble() needs '.' as a decimal separator -
trunk/src/org/openstreetmap/josm/actions/JumpToAction.java
r7812 r8443 109 109 p.add(url, GBC.eol().fill(GBC.HORIZONTAL)); 110 110 111 Object[] buttons = { tr("Jump there"), tr("Cancel")};111 Object[] buttons = {tr("Jump there"), tr("Cancel")}; 112 112 LatLon ll = null; 113 113 double zoomLvl = 100; -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r8378 r8443 198 198 List<Node> newNodes = new ArrayList<>(w.getNodesCount()); 199 199 for (Node n: w.getNodes()) { 200 if (! 200 if (!nodesToDelete.contains(n) && !n.equals(targetNode)) { 201 201 newNodes.add(n); 202 202 } else if (newNodes.isEmpty()) { -
trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
r7859 r8443 67 67 return; 68 68 } 69 if ((selection.size()) == 1 && (selection.toArray()[0] instanceof Node) 69 if ((selection.size()) == 1 && (selection.toArray()[0] instanceof Node)) { 70 70 setEnabled(true); 71 71 } else { -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r8378 r8443 101 101 try { 102 102 for (OsmPrimitive p : sel) { 103 if (! 103 if (!(p instanceof Node)) throw new InvalidUserInputException(); 104 104 Node n = (Node) p; 105 105 if (rememberMovements.containsKey(n)) { 106 106 EastNorth tmp = rememberMovements.get(n); 107 commands.add(new MoveCommand(n, - tmp.east(), -tmp.north()));107 commands.add(new MoveCommand(n, -tmp.east(), -tmp.north())); 108 108 rememberMovements.remove(n); 109 109 } … … 299 299 // rotate 300 300 for (Node n: allNodes) { 301 EastNorth tmp = EN.rotateCC(pivot, n.getEastNorth(), - 301 EastNorth tmp = EN.rotateCC(pivot, n.getEastNorth(), -headingAll); 302 302 nX.put(n, tmp.east()); 303 303 nY.put(n, tmp.north()); … … 328 328 Node n2 = w.way.getNodes().get(i+1); 329 329 if (Arrays.asList(orientation).contains(w.segDirections[i])) { 330 if (cs.contains(n1) && ! 330 if (cs.contains(n1) && !cs.contains(n2)) { 331 331 cs.add(n2); 332 332 somethingHappened = true; 333 333 } 334 if (cs.contains(n2) && ! 334 if (cs.contains(n2) && !cs.contains(n1)) { 335 335 cs.add(n1); 336 336 somethingHappened = true; … … 468 468 } 469 469 // rotate the vertical vector by 90 degrees (clockwise) and add it to the horizontal vector 470 segSum = EN.sum(h, new EastNorth(v.north(), - 470 segSum = EN.sum(h, new EastNorth(v.north(), -v.east())); 471 471 // if (EN.abs(segSum) < lh) throw new AssertionError(); 472 472 this.heading = EN.polar(new EastNorth(0.,0.), segSum); … … 505 505 a -= 2 * Math.PI; 506 506 } 507 while (a <= - 507 while (a <= -Math.PI) { 508 508 a += 2 * Math.PI; 509 509 } -
trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r8388 r8443 109 109 */ 110 110 protected <T extends OsmPrimitive> boolean hasSourceTagsByType(OsmPrimitiveType type) { 111 return ! 111 return !getSourceTagsByType(type).isEmpty(); 112 112 } 113 113 … … 196 196 if (hasTargetPrimitives(type.getOsmClass())) { 197 197 TagCollection tc = TagCollection.unionOfAllPrimitives(getSourcePrimitivesByType(type)); 198 if (!tc.isEmpty() && ! 198 if (!tc.isEmpty() && !tc.isApplicableToPrimitive()) 199 199 return false; 200 200 } -
trunk/src/org/openstreetmap/josm/actions/PreferencesAction.java
r7022 r8443 107 107 if (tab != null) { 108 108 p.selectPreferencesTabByClass(tab); 109 } else if (subTab != null) {109 } else if (subTab != null) { 110 110 p.selectSubPreferencesTabByClass(subTab); 111 111 } -
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r7005 r8443 74 74 @Override 75 75 public void actionPerformed(ActionEvent e) { 76 if (! 76 if (!isEnabled()) 77 77 return; 78 78 if (getCurrentDataSet() == null) -
trunk/src/org/openstreetmap/josm/actions/SaveAction.java
r8061 r8443 37 37 @Override public File getFile(Layer layer) { 38 38 File f = layer.getAssociatedFile(); 39 if (f != null && !f.exists()) {39 if (f != null && !f.exists()) { 40 40 f=null; 41 41 } -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r8338 r8443 139 139 protected boolean isRequiredNode(Way way, Node node) { 140 140 boolean isRequired = Collections.frequency(way.getNodes(), node) > 1; 141 if (! 141 if (!isRequired) { 142 142 List<OsmPrimitive> parents = new LinkedList<>(); 143 143 parents.addAll(node.getReferrers()); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r8276 r8443 126 126 List<Way> selectedWays = OsmPrimitive.getFilteredList(selection, Way.class); 127 127 List<Relation> selectedRelations = 128 OsmPrimitive.getFilteredList( 128 OsmPrimitive.getFilteredList(selection, Relation.class); 129 129 List<Way> applicableWays = getApplicableWays(selectedWays, selectedNodes); 130 130 -
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r7575 r8443 45 45 @Override 46 46 public void actionPerformed(ActionEvent e) { 47 if (! 47 if (!isEnabled()) 48 48 return; 49 49 if (getEditLayer() == null) -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r8291 r8443 126 126 @Override 127 127 public void actionPerformed(ActionEvent e) { 128 if (! 128 if (!isEnabled()) 129 129 return; 130 130 Collection<OsmPrimitive> toUpdate = getData(); -
trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java
r7937 r8443 24 24 25 25 private final OsmPrimitivesTable table; 26 26 27 27 private final String descriptionNominal; 28 28 private final String descriptionInactiveLayer; 29 29 private final String descriptionNoSelection; 30 30 31 31 public ZoomToAction(OsmPrimitivesTable table, String descriptionNominal, String descriptionInactiveLayer, String descriptionNoSelection) { 32 32 CheckParameterUtil.ensureParameterNotNull(table); … … 39 39 updateEnabledState(); 40 40 } 41 41 42 42 public ZoomToAction(MemberTable table) { 43 this(table, 43 this(table, 44 44 tr("Zoom to the object the first selected member refers to"), 45 45 tr("Zooming disabled because layer of this relation is not active"), 46 46 tr("Zooming disabled because there is no selected member")); 47 47 } 48 48 49 49 public ZoomToAction(RelationMemberTable table) { 50 this(table, 50 this(table, 51 51 tr("Zoom to the object the first selected member refers to"), 52 52 tr("Zooming disabled because layer of this relation is not active"), 53 53 tr("Zooming disabled because there is no selected member")); 54 54 } 55 55 56 56 public ZoomToAction(NodeListTable table) { 57 this(table, 57 this(table, 58 58 tr("Zoom to the first selected node"), 59 59 tr("Zooming disabled because layer of this way is not active"), … … 63 63 @Override 64 64 public void actionPerformed(ActionEvent e) { 65 if (! 65 if (!isEnabled()) 66 66 return; 67 67 int[] rows = this.table.getSelectedRows(); -
trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java
r8378 r8443 82 82 @Override 83 83 public String getDescriptionText() { 84 String text = tr( 84 String text = tr("Replace \"{0}\" by \"{1}\" for", key, newKey); 85 85 if (objects.size() == 1) { 86 86 NameVisitor v = new NameVisitor(); -
trunk/src/org/openstreetmap/josm/command/RotateCommand.java
r8392 r8443 50 50 **/ 51 51 protected final double getAngle(EastNorth currentEN) { 52 if ( pivot == null)52 if (pivot == null) 53 53 return 0.0; // should never happen by contract 54 54 return Math.atan2(currentEN.east()-pivot.east(), currentEN.north()-pivot.north()); -
trunk/src/org/openstreetmap/josm/command/TransformNodesCommand.java
r8285 r8443 133 133 EastNorth sum = new EastNorth(0,0); 134 134 135 for (Node n : nodes 135 for (Node n : nodes) { 136 136 EastNorth en = n.getEastNorth(); 137 137 sum = sum.add(en.east(), en.north()); -
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r8404 r8443 233 233 Collection<OsmPrimitive> referrers = oldway.getReferrers(); 234 234 for (OsmPrimitive referrer: referrers) { 235 if (! 235 if (!(referrer instanceof Relation)) { 236 236 continue; 237 237 } -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r8357 r8443 59 59 public class AutosaveTask extends TimerTask implements LayerChangeListener, Listener { 60 60 61 private static final char[] ILLEGAL_CHARACTERS = { '/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'};61 private static final char[] ILLEGAL_CHARACTERS = {'/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'}; 62 62 private static final String AUTOSAVE_DIR = "autosave"; 63 63 private static final String DELETED_LAYERS_DIR = "autosave/deleted_layers"; -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r8291 r8443 143 143 } 144 144 145 public Bounds(double 145 public Bounds(double[] coords) { 146 146 this(coords, true); 147 147 } 148 148 149 public Bounds(double 149 public Bounds(double[] coords, boolean roundToOsmPrecision) { 150 150 CheckParameterUtil.ensureParameterNotNull(coords, "coords"); 151 151 if (coords.length != 4) -
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r8419 r8443 412 412 tmp.settingsMap.putAll(pref.settingsMap); 413 413 tmp.defaultsMap.putAll(pref.defaultsMap); 414 tmp.colornames.putAll( pref.colornames);414 tmp.colornames.putAll(pref.colornames); 415 415 416 416 return tmp; 417 417 } 418 419 418 420 419 public static class XMLCommandProcessor { -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r8395 r8443 879 879 } 880 880 } else { 881 if (! 881 if (!prefDir.mkdirs()) { 882 882 Main.warn(tr("Failed to initialize preferences. Failed to create missing preference directory: {0}", prefDir.getAbsoluteFile())); 883 883 JOptionPane.showMessageDialog( -
trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
r8345 r8443 113 113 * @return the option selected by user. {@link JOptionPane#CLOSED_OPTION} if the dialog was closed. 114 114 */ 115 public static int showOptionDialog(String preferenceKey, Component parent, Object message, String title, int optionType, int messageType, Object [] options, Object defaultOption) throws HeadlessException { 115 public static int showOptionDialog(String preferenceKey, Component parent, Object message, String title, int optionType, 116 int messageType, Object[] options, Object defaultOption) throws HeadlessException { 116 117 int ret = getDialogReturnValue(preferenceKey); 117 118 if (isYesOrNo(ret)) -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r8395 r8443 618 618 int nodesNo = way.isClosed() ? way.getNumNodes() -1 : way.getNumNodes(); 619 619 String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo); 620 if (sb.length() == 0) {620 if (sb.length() == 0) { 621 621 sb.append(way.getId()); 622 622 } -
trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r8419 r8443 34 34 import org.openstreetmap.josm.Main; 35 35 import org.openstreetmap.josm.actions.OpenFileAction; 36 import org.openstreetmap.josm.gui.FileDrop.TransferableObject;37 36 38 37 /** … … 85 84 86 85 // Default border color 87 private static Color defaultBorderColor = new Color( 0f, 0f, 1f, 0.25f);86 private static Color defaultBorderColor = new Color(0f, 0f, 1f, 0.25f); 88 87 89 88 /** … … 91 90 * @param c The drop target 92 91 */ 93 public FileDrop(final Component c) {92 public FileDrop(final Component c) { 94 93 this( 95 94 c, // Drop target 96 BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor), // Drag border95 BorderFactory.createMatteBorder(2, 2, 2, 2, defaultBorderColor), // Drag border 97 96 true, // Recursive 98 new FileDrop.Listener() {97 new FileDrop.Listener() { 99 98 @Override 100 public void filesDropped( File[] files){99 public void filesDropped(File[] files){ 101 100 // start asynchronous loading of files 102 101 OpenFileAction.OpenFileTask task = new OpenFileAction.OpenFileTask(Arrays.asList(files), null); … … 126 125 final Listener listener) { 127 126 128 if ( supportsDnD()) {127 if (supportsDnD()) { 129 128 // Make a drop listener 130 129 dropListener = new DropTargetListener() { 131 130 @Override 132 public void dragEnter( DropTargetDragEvent evt) {131 public void dragEnter(DropTargetDragEvent evt) { 133 132 Main.trace("FileDrop: dragEnter event." ); 134 133 135 134 // Is this an acceptable drag event? 136 if ( isDragOk( evt) ) {135 if (isDragOk(evt) ) { 137 136 // If it's a Swing component, set its border 138 if ( c instanceof JComponent) {137 if (c instanceof JComponent) { 139 138 JComponent jc = (JComponent) c; 140 139 normalBorder = jc.getBorder(); 141 Main.trace("FileDrop: normal border saved." 142 jc.setBorder( dragBorder);143 Main.trace("FileDrop: drag border set." 140 Main.trace("FileDrop: normal border saved."); 141 jc.setBorder(dragBorder); 142 Main.trace("FileDrop: drag border set."); 144 143 } 145 144 146 145 // Acknowledge that it's okay to enter 147 evt.acceptDrag( DnDConstants.ACTION_COPY 148 Main.trace("FileDrop: event accepted." 146 evt.acceptDrag( DnDConstants.ACTION_COPY); 147 Main.trace("FileDrop: event accepted."); 149 148 } else { 150 149 // Reject the drag event 151 150 evt.rejectDrag(); 152 Main.trace("FileDrop: event rejected." 151 Main.trace("FileDrop: event rejected."); 153 152 } 154 153 } 155 154 156 155 @Override 157 public void dragOver( DropTargetDragEvent evt) {156 public void dragOver(DropTargetDragEvent evt) { 158 157 // This is called continually as long as the mouse is over the drag target. 159 158 } 160 159 161 160 @Override 162 public void drop( DropTargetDropEvent evt) {163 Main.trace("FileDrop: drop event." 161 public void drop(DropTargetDropEvent evt) { 162 Main.trace("FileDrop: drop event."); 164 163 try { 165 164 // Get whatever was dropped … … 180 179 181 180 // Alert listener to drop. 182 if ( listener != null) {181 if (listener != null) { 183 182 listener.filesDropped(files); 184 183 } … … 214 213 } 215 214 } 216 if (!handled){217 Main.trace("FileDrop: not a file list or reader - abort." 215 if (!handled) { 216 Main.trace("FileDrop: not a file list or reader - abort."); 218 217 evt.rejectDrop(); 219 218 } … … 221 220 } 222 221 } catch (IOException | UnsupportedFlavorException e) { 223 Main.warn("FileDrop: "+e.getClass().getSimpleName()+" - abort:" 222 Main.warn("FileDrop: "+e.getClass().getSimpleName()+" - abort:"); 224 223 Main.error(e); 225 224 try { … … 231 230 } finally { 232 231 // If it's a Swing component, reset its border 233 if ( c instanceof JComponent) {232 if (c instanceof JComponent) { 234 233 JComponent jc = (JComponent) c; 235 jc.setBorder( normalBorder);236 Main.debug("FileDrop: normal border restored." 234 jc.setBorder(normalBorder); 235 Main.debug("FileDrop: normal border restored."); 237 236 } 238 237 } … … 240 239 241 240 @Override 242 public void dragExit( DropTargetEvent evt) {243 Main.debug("FileDrop: dragExit event." 241 public void dragExit(DropTargetEvent evt) { 242 Main.debug("FileDrop: dragExit event."); 244 243 // If it's a Swing component, reset its border 245 if ( c instanceof JComponent) {246 JComponent jc = (JComponent) c;247 jc.setBorder( normalBorder);248 Main.debug("FileDrop: normal border restored." 244 if (c instanceof JComponent) { 245 JComponent jc = (JComponent) c; 246 jc.setBorder(normalBorder); 247 Main.debug("FileDrop: normal border restored."); 249 248 } 250 249 } 251 250 252 251 @Override 253 public void dropActionChanged( DropTargetDragEvent evt) {254 Main.debug("FileDrop: dropActionChanged event." 252 public void dropActionChanged(DropTargetDragEvent evt) { 253 Main.debug("FileDrop: dropActionChanged event."); 255 254 // Is this an acceptable drag event? 256 if ( isDragOk( evt) ) {257 evt.acceptDrag( DnDConstants.ACTION_COPY 258 Main.debug("FileDrop: event accepted." 255 if (isDragOk(evt) ) { 256 evt.acceptDrag( DnDConstants.ACTION_COPY); 257 Main.debug("FileDrop: event accepted."); 259 258 } else { 260 259 evt.rejectDrag(); 261 Main.debug("FileDrop: event rejected." 260 Main.debug("FileDrop: event rejected."); 262 261 } 263 262 } … … 265 264 266 265 // Make the component (and possibly children) drop targets 267 makeDropTarget( c, recursive);266 makeDropTarget(c, recursive); 268 267 } else { 269 Main.info("FileDrop: Drag and drop is not supported with this JVM" 268 Main.info("FileDrop: Drag and drop is not supported with this JVM"); 270 269 } 271 270 } 272 271 273 272 private static synchronized boolean supportsDnD() { 274 if ( supportsDnD == null) {273 if (supportsDnD == null) { 275 274 boolean support = false; 276 275 try { 277 Class.forName( "java.awt.dnd.DnDConstants");276 Class.forName("java.awt.dnd.DnDConstants"); 278 277 support = true; 279 } catch( Exception e) {278 } catch(Exception e) { 280 279 support = false; 281 280 } … … 313 312 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 314 313 315 private void makeDropTarget( final Component c, boolean recursive) {314 private void makeDropTarget(final Component c, boolean recursive) { 316 315 // Make drop target 317 316 final DropTarget dt = new DropTarget(); 318 317 try { 319 dt.addDropTargetListener( dropListener);320 } catch( TooManyListenersException e) {318 dt.addDropTargetListener(dropListener); 319 } catch(TooManyListenersException e) { 321 320 Main.error(e); 322 Main.warn("FileDrop: Drop will not work due to previous error. Do you have another listener attached?" 321 Main.warn("FileDrop: Drop will not work due to previous error. Do you have another listener attached?"); 323 322 } 324 323 325 324 // Listen for hierarchy changes and remove the drop target when the parent gets cleared out. 326 c.addHierarchyListener( 325 c.addHierarchyListener(new HierarchyListener() { 327 326 @Override 328 public void hierarchyChanged( HierarchyEvent evt) {329 Main.trace("FileDrop: Hierarchy changed." 327 public void hierarchyChanged(HierarchyEvent evt) { 328 Main.trace("FileDrop: Hierarchy changed."); 330 329 Component parent = c.getParent(); 331 if ( parent == null) {332 c.setDropTarget( null);333 Main.trace("FileDrop: Drop target cleared from component." 330 if (parent == null) { 331 c.setDropTarget(null); 332 Main.trace("FileDrop: Drop target cleared from component."); 334 333 } else { 335 334 new DropTarget(c, dropListener); 336 Main.trace("FileDrop: Drop target added to component." 335 Main.trace("FileDrop: Drop target added to component."); 337 336 } 338 337 } 339 338 }); 340 if ( c.getParent() != null) {339 if (c.getParent() != null) { 341 340 new DropTarget(c, dropListener); 342 341 } 343 342 344 if ( recursive && (c instanceof Container )) {343 if (recursive && (c instanceof Container)) { 345 344 // Get the container 346 345 Container cont = (Container) c; … … 351 350 // Set it's components as listeners also 352 351 for (Component comp : comps) { 353 makeDropTarget( 352 makeDropTarget(comp, recursive); 354 353 } 355 354 } … … 357 356 358 357 /** Determine if the dragged data is a file list. */ 359 private boolean isDragOk( final DropTargetDragEvent evt) {358 private boolean isDragOk(final DropTargetDragEvent evt) { 360 359 boolean ok = false; 361 360 … … 365 364 // See if any of the flavors are a file list 366 365 int i = 0; 367 while( !ok && i < flavors.length) {366 while(!ok && i < flavors.length) { 368 367 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 369 368 // Is the flavor a file list? 370 369 final DataFlavor curFlavor = flavors[i]; 371 if (curFlavor.equals( DataFlavor.javaFileListFlavor ) ||370 if (curFlavor.equals( DataFlavor.javaFileListFlavor ) || 372 371 curFlavor.isRepresentationClassReader()){ 373 372 ok = true; … … 378 377 379 378 // show data flavors 380 if ( flavors.length == 0) {381 Main.trace("FileDrop: no data flavors." 382 } 383 for ( i = 0; i < flavors.length; i++) {384 Main.trace(flavors[i].toString() 379 if (flavors.length == 0) { 380 Main.trace("FileDrop: no data flavors."); 381 } 382 for (i = 0; i < flavors.length; i++) { 383 Main.trace(flavors[i].toString()); 385 384 } 386 385 … … 398 397 * @return {@code true} if at least one item has been removed, {@code false} otherwise 399 398 */ 400 public static boolean remove( 401 return remove( c, true);399 public static boolean remove(Component c) { 400 return remove(c, true); 402 401 } 403 402 … … 411 410 * @return {@code true} if at least one item has been removed, {@code false} otherwise 412 411 */ 413 public static boolean remove( Component c, boolean recursive) {412 public static boolean remove(Component c, boolean recursive) { 414 413 // Make sure we support dnd. 415 414 if (supportsDnD()) { … … 449 448 * @param files An array of <tt>File</tt>s that were dropped. 450 449 */ 451 public abstract void filesDropped( File[] files);450 public abstract void filesDropped(File[] files); 452 451 } 453 452 … … 512 511 */ 513 512 public static final DataFlavor DATA_FLAVOR = 514 new DataFlavor( FileDrop.TransferableObject.class, MIME_TYPE);513 new DataFlavor(FileDrop.TransferableObject.class, MIME_TYPE); 515 514 516 515 private Fetcher fetcher; … … 528 527 * @param data The data to transfer 529 528 */ 530 public TransferableObject( Object data) {529 public TransferableObject(Object data) { 531 530 this.data = data; 532 this.customFlavor = new DataFlavor( data.getClass(), MIME_TYPE);531 this.customFlavor = new DataFlavor(data.getClass(), MIME_TYPE); 533 532 } 534 533 … … 542 541 * @param fetcher The {@link Fetcher} that will return the data object 543 542 */ 544 public TransferableObject( Fetcher fetcher) {543 public TransferableObject(Fetcher fetcher) { 545 544 this.fetcher = fetcher; 546 545 } … … 558 557 * @see Fetcher 559 558 */ 560 public TransferableObject(Class<?> dataClass, Fetcher fetcher 559 public TransferableObject(Class<?> dataClass, Fetcher fetcher) { 561 560 this.fetcher = fetcher; 562 this.customFlavor = new DataFlavor( dataClass, MIME_TYPE);561 this.customFlavor = new DataFlavor(dataClass, MIME_TYPE); 563 562 } 564 563 … … 587 586 @Override 588 587 public DataFlavor[] getTransferDataFlavors() { 589 if ( customFlavor != null)588 if (customFlavor != null) 590 589 return new DataFlavor[] { 591 590 customFlavor, … … 609 608 */ 610 609 @Override 611 public Object getTransferData( DataFlavor flavor)610 public Object getTransferData(DataFlavor flavor) 612 611 throws UnsupportedFlavorException, IOException { 613 612 // Native object 614 if ( flavor.equals( DATA_FLAVOR ))613 if (flavor.equals(DATA_FLAVOR)) 615 614 return fetcher == null ? data : fetcher.getObject(); 616 615 617 616 // String 618 if ( flavor.equals( DataFlavor.stringFlavor ))617 if (flavor.equals(DataFlavor.stringFlavor)) 619 618 return fetcher == null ? data.toString() : fetcher.getObject().toString(); 620 619 … … 631 630 */ 632 631 @Override 633 public boolean isDataFlavorSupported( DataFlavor flavor) {632 public boolean isDataFlavorSupported(DataFlavor flavor) { 634 633 // Native object 635 if ( flavor.equals( DATA_FLAVOR ))634 if (flavor.equals(DATA_FLAVOR)) 636 635 return true; 637 636 638 637 // String 639 if ( flavor.equals( DataFlavor.stringFlavor ))638 if (flavor.equals( DataFlavor.stringFlavor)) 640 639 return true; 641 640 -
trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java
r8308 r8443 112 112 hiddenFlag = Boolean.parseBoolean(hiddenFlagStr); 113 113 } 114 setVisible( !hiddenFlag); // show or hide, do what preferences say114 setVisible(!hiddenFlag); // show or hide, do what preferences say 115 115 } 116 116 } -
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r8404 r8443 285 285 286 286 private void addDynamic(Action a) { 287 dynamicItems.add( this.add(a));287 dynamicItems.add(this.add(a)); 288 288 } 289 289 290 290 private void addDynamic(JMenuItem it) { 291 dynamicItems.add( this.add(it));291 dynamicItems.add(this.add(it)); 292 292 } 293 293 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r8415 r8443 242 242 243 243 int c; 244 while ((c = g.getopt()) != -1 244 while ((c = g.getopt()) != -1) { 245 245 Option opt = null; 246 246 switch (c) { -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r8419 r8443 938 938 */ 939 939 double perDistSq = Double.longBitsToDouble( 940 Double.doubleToLongBits( a - (a - b + c) * (a - b + c) / 4 / c)940 Double.doubleToLongBits(a - (a - b + c) * (a - b + c) / 4 / c) 941 941 >> 32 << 32); // resolution in numbers with large exponent not needed here.. 942 942 … … 1319 1319 double r = ( 1320 1320 (pt.getX()-a.getX())*(b.getX()-a.getX()) + 1321 (pt.getY()-a.getY())*(b.getY()-a.getY()) 1321 (pt.getY()-a.getY())*(b.getY()-a.getY())) 1322 1322 / a.distanceSq(b); 1323 1323 return project(r, a, b); -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r8401 r8443 364 364 localFile = null; 365 365 } else { 366 if ( 366 if (maxAge == DEFAULT_MAXTIME 367 367 || maxAge <= 0 // arbitrary value <= 0 is deprecated 368 368 ) { -
trunk/src/org/openstreetmap/josm/io/Capabilities.java
r8390 r8443 70 70 */ 71 71 public boolean isDefined(String element, String attribute) { 72 if (! 72 if (!capabilities.containsKey(element)) return false; 73 73 Map<String, String> e = capabilities.get(element); 74 74 if (e == null) return false; … … 84 84 */ 85 85 public String get(String element, String attribute) { 86 if (! 86 if (!capabilities.containsKey(element)) return null; 87 87 Map<String, String> e = capabilities.get(element); 88 88 if (e == null) return null; … … 131 131 } 132 132 } else { 133 if (! 133 if (!capabilities.containsKey(element)) { 134 134 Map<String,String> h = new HashMap<>(); 135 135 capabilities.put(element, h); -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r8415 r8443 193 193 * @throws IllegalArgumentException if createdBefore is null 194 194 */ 195 public ChangesetQuery closedAfterAndCreatedBefore(Date closedAfter, Date createdBefore 195 public ChangesetQuery closedAfterAndCreatedBefore(Date closedAfter, Date createdBefore) { 196 196 CheckParameterUtil.ensureParameterNotNull(closedAfter, "closedAfter"); 197 197 CheckParameterUtil.ensureParameterNotNull(createdBefore, "createdBefore"); -
trunk/src/org/openstreetmap/josm/io/GpxExporter.java
r8426 r8443 135 135 ExtendedDialog ed = new ExtendedDialog(Main.parent, 136 136 tr("Export options"), 137 new String[] { tr("Export and Save"), tr("Cancel")});138 ed.setButtonIcons(new String[] { "exportgpx", "cancel"});137 new String[] {tr("Export and Save"), tr("Cancel")}); 138 ed.setButtonIcons(new String[] {"exportgpx", "cancel"}); 139 139 ed.setContent(p); 140 140 ed.showDialog(); -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r8291 r8443 119 119 OAuthConsumer consumer = oauthParameters.buildConsumer(); 120 120 OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance(); 121 if (! 121 if (!holder.containsAccessToken()) 122 122 throw new MissingOAuthAccessTokenException(); 123 123 consumer.setTokenWithSecret(holder.getAccessTokenKey(), holder.getAccessTokenSecret()); -
trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java
r8390 r8443 120 120 .append('/') 121 121 .append(id.getUniqueId()); 122 if (full && ! 122 if (full && !id.getType().equals(OsmPrimitiveType.NODE)) { 123 123 sb.append("/full"); 124 124 } else if (version > 0) { -
trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
r8394 r8443 42 42 UserInfo userInfo = new UserInfo(); 43 43 Node xmlNode = (Node)xpath.compile("/osm/user[1]").evaluate(document, XPathConstants.NODE); 44 if ( xmlNode== null)44 if (xmlNode == null) 45 45 throw new XmlParsingException(tr("XML tag <user> is missing.")); 46 46 -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r8345 r8443 315 315 } 316 316 if (this.changeset != null && this.changeset.getId() != 0) { 317 out.print(" changeset='"+this.changeset.getId()+"'" 317 out.print(" changeset='"+this.changeset.getId()+"'"); 318 318 } else if (osm.getChangesetId() > 0 && !osm.isNew()) { 319 out.print(" changeset='"+osm.getChangesetId()+"'" 319 out.print(" changeset='"+osm.getChangesetId()+"'"); 320 320 } 321 321 } -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r8394 r8443 111 111 ); 112 112 dialog.setContent(tr("JOSM version {0} required for plugin {1}.", pi.mainversion, pi.name)); 113 dialog.setButtonIcons(new String[] { "download", "cancel"});113 dialog.setButtonIcons(new String[] {"download", "cancel"}); 114 114 dialog.showDialog(); 115 115 int answer = dialog.getValue(); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r8404 r8443 208 208 * List of unmaintained plugins. Not really up-to-date as the vast majority of plugins are not maintained after a few months, sadly... 209 209 */ 210 private static final String 210 private static final String[] UNMAINTAINED_PLUGINS = new String[] {"gpsbabelgui", "Intersect_way"}; 211 211 212 212 /** … … 360 360 if (message == null) return false; 361 361 362 ButtonSpec 362 ButtonSpec[] options = new ButtonSpec[] { 363 363 new ButtonSpec( 364 364 tr("Update plugins"), … … 984 984 // notify user if downloading a locally installed plugin failed 985 985 // 986 if (! 986 if (!pluginDownloadTask.getFailedPlugins().isEmpty()) { 987 987 alertFailedPluginUpdate(parent, pluginDownloadTask.getFailedPlugins()); 988 988 return plugins; … … 1010 1010 */ 1011 1011 public static boolean confirmDisablePlugin(Component parent, String reason, String name) { 1012 ButtonSpec 1012 ButtonSpec[] options = new ButtonSpec[] { 1013 1013 new ButtonSpec( 1014 1014 tr("Disable plugin"), … … 1075 1075 public static void installDownloadedPlugins(boolean dowarn) { 1076 1076 File pluginDir = Main.pref.getPluginsDirectory(); 1077 if (! pluginDir.exists() || ! pluginDir.isDirectory() || !pluginDir.canWrite())1077 if (!pluginDir.exists() || !pluginDir.isDirectory() || !pluginDir.canWrite()) 1078 1078 return; 1079 1079 … … 1276 1276 ); 1277 1277 final PluginInformation pluginInfo = plugin.getPluginInformation(); 1278 if (! 1278 if (!plugins.contains(pluginInfo.name)) 1279 1279 // plugin not activated ? strange in this context but anyway, don't bother 1280 1280 // the user with dialogs, skip conditional deactivation -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r8390 r8443 317 317 List<File> siteCacheFiles = new LinkedList<>(); 318 318 for (String location : PluginInformation.getPluginLocations()) { 319 File 319 File[] f = new File(location).listFiles( 320 320 new FilenameFilter() { 321 321 @Override -
trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
r8291 r8443 111 111 public static void ensureValidNodeId(PrimitiveId id, String parameterName) throws IllegalArgumentException { 112 112 ensureParameterNotNull(id, parameterName); 113 if (! 113 if (!id.getType().equals(OsmPrimitiveType.NODE)) 114 114 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' of type node expected, got ''{1}''", parameterName, id.getType().getAPIName())); 115 115 } -
trunk/src/org/openstreetmap/josm/tools/ColorScale.java
r8419 r8443 38 38 ColorScale sc = new ColorScale(); 39 39 // red yellow green blue red 40 int[] h = new int[] { 41 int[] s = new int[] { 100, 84, 99, 100};42 int[] b = new int[] { 90, 93, 74, 83};40 int[] h = new int[] {0, 59, 127, 244, 360}; 41 int[] s = new int[] {100, 84, 99, 100}; 42 int[] b = new int[] {90, 93, 74, 83}; 43 43 44 44 sc.colors = new Color[count]; -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r8419 r8443 97 97 public Diff(Object[] a, Object[] b) { 98 98 Map<Object,Integer> h = new HashMap<>(a.length + b.length); 99 filevec = new FileData[] { new FileData(a,h),new FileData(b,h)};99 filevec = new FileData[] {new FileData(a,h), new FileData(b,h)}; 100 100 } 101 101 -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r8419 r8443 298 298 if (Math.abs(det) > 1e-12 * mag) { 299 299 double u = uu/det, v = vv/det; 300 if (u>-1e-8 && u < 1+1e-8 && v>-1e-8 && v < 1+1e-8 300 if (u>-1e-8 && u < 1+1e-8 && v>-1e-8 && v < 1+1e-8) { 301 301 if (u<0) u=0; 302 302 if (u>1) u=1.0; … … 355 355 return null; // Lines are parallel 356 356 357 return new EastNorth(b1 * c2 / det + p1.getX(), -a1 * c2 / det + p1.getY());357 return new EastNorth(b1 * c2 / det + p1.getX(), -a1 * c2 / det + p1.getY()); 358 358 } 359 359 -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r8419 r8443 721 721 String[] extensions; 722 722 if (name.indexOf('.') != -1) { 723 extensions = new String[] { ""};723 extensions = new String[] {""}; 724 724 } else { 725 extensions = new String[] { 725 extensions = new String[] {".png", ".svg"}; 726 726 } 727 727 final int ARCHIVE = 0, LOCAL = 1; 728 for (int place : new Integer[] { ARCHIVE, LOCAL}) {728 for (int place : new Integer[] {ARCHIVE, LOCAL}) { 729 729 for (String ext : extensions) { 730 730 -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r8419 r8443 415 415 // Try to reassign Meta to Ctrl 416 416 int newmodifier = findNewOsxModifier(requestedGroup); 417 if ( findShortcut(requestedKey, newmodifier) == null) {417 if (findShortcut(requestedKey, newmodifier) == null) { 418 418 return reassignShortcut(shortText, longText, requestedKey, conflict, requestedGroup, requestedKey, newmodifier); 419 419 } … … 422 422 for (int k : keys) { 423 423 int newmodifier = getGroupModifier(m); 424 if ( findShortcut(k, newmodifier) == null) {424 if (findShortcut(k, newmodifier) == null) { 425 425 return reassignShortcut(shortText, longText, requestedKey, conflict, m, k, newmodifier); 426 426 } -
trunk/src/org/openstreetmap/josm/tools/TextTagParser.java
r8375 r8443 132 132 while (pos < n) { 133 133 c = data.charAt(pos); 134 if (c == '\t' || c == '\n' || c == '\r' || c == ' ' 134 if (c == '\t' || c == '\n' || c == '\r' || c == ' ') { 135 135 pos++; 136 136 } else { … … 142 142 143 143 protected static String unescape(String k) { 144 if (! (k.startsWith("\"") && k.endsWith("\""))) {144 if (!(k.startsWith("\"") && k.endsWith("\""))) { 145 145 if (k.contains("=")) { 146 146 // '=' not in quotes will be treated as an error! … … 220 220 String bufJson = buf.trim(); 221 221 // trim { }, if there are any 222 if (bufJson.startsWith("{") && bufJson.endsWith("}") ) bufJson = bufJson.substring(1,bufJson.length()-1); 222 if (bufJson.startsWith("{") && bufJson.endsWith("}")) 223 bufJson = bufJson.substring(1, bufJson.length()-1); 223 224 tags = readTagsByRegexp(bufJson, "[\\s]*,[\\s]*", 224 225 "[\\s]*(\\\".*?[^\\\\]\\\")"+"[\\s]*:[\\s]*"+"(\\\".*?[^\\\\]\\\")[\\s]*", true); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r8435 r8443 421 421 */ 422 422 public static boolean deleteDirectory(File path) { 423 if ( path.exists()) {423 if (path.exists()) { 424 424 File[] files = path.listFiles(); 425 425 if (files != null) { -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r8394 r8443 68 68 public static WindowGeometry centerInWindow(Component reference, Dimension extent) { 69 69 Window parentWindow = null; 70 while (reference != null && ! (reference instanceof Window)) {70 while (reference != null && !(reference instanceof Window)) { 71 71 reference = reference.getParent(); 72 72 }
Note:
See TracChangeset
for help on using the changeset viewer.