Changeset 32725 in osm for applications/editors/josm/plugins/utilsplugin2/src/org
- Timestamp:
- 2016-07-27T03:10:06+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/CopyTagsAction.java
r32333 r32725 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.Tag; 20 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 20 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 22 import org.openstreetmap.josm.tools.Shortcut; … … 62 63 } 63 64 } 64 if (!values.isEmpty()) Utils.copyToClipboard(Utils.join("\n", values)); 65 if (!values.isEmpty()) 66 ClipboardUtils.copyString(Utils.join("\n", values)); 65 67 } 66 68 … … 83 85 tr("Information"), 84 86 JOptionPane.INFORMATION_MESSAGE 85 );87 ); 86 88 return true; 87 89 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java
r32410 r32725 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.datatransfer.UnsupportedFlavorException; 6 7 import java.awt.event.ActionEvent; 7 8 import java.awt.event.KeyEvent; 9 import java.io.IOException; 8 10 import java.util.ArrayList; 9 11 import java.util.Collection; 12 import java.util.Collections; 10 13 import java.util.HashMap; 11 14 import java.util.List; … … 21 24 import org.openstreetmap.josm.data.osm.Relation; 22 25 import org.openstreetmap.josm.data.osm.RelationMember; 26 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 27 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 23 28 import org.openstreetmap.josm.tools.Shortcut; 24 29 … … 44 49 45 50 Map<Relation, String> relations = new HashMap<>(); 46 for (PrimitiveData pdata : Main.pasteBuffer.getDirectlyAdded()) { 51 Collection<PrimitiveData> data = Collections.emptySet(); 52 try { 53 data = ((PrimitiveTransferData) ClipboardUtils.getClipboard().getData(PrimitiveTransferData.DATA_FLAVOR)).getDirectlyAdded(); 54 } catch (UnsupportedFlavorException | IOException ex) { 55 Main.warn(ex); 56 } 57 for (PrimitiveData pdata : data) { 47 58 OsmPrimitive p = getLayerManager().getEditDataSet().getPrimitiveById(pdata.getUniqueId(), pdata.getType()); 48 59 if (p != null) { … … 98 109 @Override 99 110 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 100 setEnabled(selection != null && !selection.isEmpty() && !Main.pasteBuffer.isEmpty()); 111 setEnabled(selection != null && !selection.isEmpty() 112 && ClipboardUtils.getClipboard().isDataFlavorAvailable(PrimitiveTransferData.DATA_FLAVOR)); 101 113 } 102 114 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagBufferAction.java
r32410 r32725 13 13 import java.util.Map; 14 14 import java.util.Set; 15 import java.util.function.Predicate; 15 16 16 17 import org.openstreetmap.josm.Main; … … 20 21 import org.openstreetmap.josm.command.SequenceCommand; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.tools.Predicate;23 23 import org.openstreetmap.josm.tools.Shortcut; 24 import org.openstreetmap.josm.tools. Utils;24 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 25 25 26 26 /** … … 31 31 public class TagBufferAction extends JosmAction { 32 32 private static final String TITLE = tr("Copy tags from previous selection"); 33 private static final Predicate<OsmPrimitive> IS_TAGGED_PREDICATE = new Predicate<OsmPrimitive>() { 34 @Override 35 public boolean evaluate(OsmPrimitive object) { 36 return object.isTagged(); 37 } 38 }; 33 private static final Predicate<OsmPrimitive> IS_TAGGED_PREDICATE = object -> object.isTagged(); 39 34 private Map<String, String> tags = new HashMap<>(); 40 35 private Map<String, String> currentTags = new HashMap<>(); … … 117 112 private void rememberSelectionTags() { 118 113 // Fix #8350 - only care about tagged objects 119 final Collection<OsmPrimitive> selectedTaggedObjects = Utils.filter(114 final Collection<OsmPrimitive> selectedTaggedObjects = SubclassFilteredCollection.filter( 120 115 getLayerManager().getEditDataSet().getSelected(), IS_TAGGED_PREDICATE); 121 116 if (!selectedTaggedObjects.isEmpty()) { -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/command/ChangeRelationMemberCommand.java
r32410 r32725 6 6 import java.util.Collection; 7 7 import java.util.LinkedList; 8 import java.util.Objects; 8 9 9 10 import org.openstreetmap.josm.command.Command; … … 36 37 LinkedList<RelationMember> newrms = new LinkedList<>(); 37 38 for (RelationMember rm : relation.getMembers()) { 38 if ( rm.getMember() == oldP) {39 if (Objects.equals(rm.getMember(), oldP)) { 39 40 newrms.add(new RelationMember(rm.getRole(), newP)); 40 41 } else { -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CircleArcMaker.java
r32410 r32725 11 11 import java.util.LinkedList; 12 12 import java.util.List; 13 import java.util.Objects; 13 14 import java.util.Set; 14 15 … … 178 179 // We look for the first anchor node. The next should be directly to the left or right. 179 180 // Exception when the way is closed 180 if ( n == anchorNodes[a]) {181 if (Objects.equals(n, anchorNodes[a])) { 181 182 bi = i; 182 183 Node otherAnchor = anchorNodes[a + 1]; 183 if (i > 0 && tw.getNode(i - 1) == otherAnchor) {184 if (i > 0 && Objects.equals(tw.getNode(i - 1), otherAnchor)) { 184 185 ei = i - 1; 185 } else if (i < (tw.getNodesCount() - 1) && tw.getNode(i + 1) == otherAnchor) {186 } else if (i < (tw.getNodesCount() - 1) && Objects.equals(tw.getNode(i + 1), otherAnchor)) { 186 187 ei = i + 1; 187 188 } else { -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/URLList.java
r32410 r32725 4 4 import java.io.BufferedReader; 5 5 import java.io.File; 6 import java.io.FileReader;7 6 import java.io.IOException; 8 7 import java.io.PrintWriter; 8 import java.nio.charset.StandardCharsets; 9 import java.nio.file.Files; 9 10 import java.util.ArrayList; 10 11 import java.util.List; … … 70 71 public static List<String> loadURLList() { 71 72 ArrayList<String> items = new ArrayList<>(); 72 BufferedReader fr = null; 73 try { 74 File f = new File(UtilsPlugin2.getInstance().getPluginDir(), "customurl.txt"); 75 fr = new BufferedReader(new FileReader(f)); 73 File f = new File(UtilsPlugin2.getInstance().getPluginDir(), "customurl.txt"); 74 try (BufferedReader fr = Files.newBufferedReader(f.toPath(), StandardCharsets.UTF_8)) { 76 75 String s; 77 while ((s = fr.readLine()) != null) items.add(s); 76 while ((s = fr.readLine()) != null) { 77 items.add(s); 78 } 78 79 } catch (IOException e) { 79 e.printStackTrace(); 80 } finally { 81 try { 82 if (fr != null) 83 fr.close(); 84 } catch (Exception e) { 85 Main.warn(e); 86 } 80 Main.error(e); 87 81 } 88 82 return items; -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/latlon/LatLonAction.java
r32410 r32725 68 68 } 69 69 70 if ( type == "nodes") {70 if ("nodes".equals(type)) { 71 71 //we dont need to do anything, we already have all the nodes 72 } 73 if (type == "way") { 72 } else if ("way".equals(type)) { 74 73 Way wnew = new Way(); 75 74 wnew.setNodes(nodes); 76 75 cmds.add(new AddCommand(wnew)); 77 } 78 if (type == "area") { 76 } else if ("area".equals(type)) { 79 77 nodes.add(nodes.get(0)); // this is needed to close the way. 80 78 Way wnew = new Way(); -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ParentsMatch.java
r32410 r32725 22 22 @Override 23 23 protected Long getNumber(OsmPrimitive osm) { 24 return new Long(osm.getReferrers().size());24 return Long.valueOf(osm.getReferrers().size()); 25 25 } 26 26 -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/UsedInRelationsMatch.java
r32410 r32725 25 25 } 26 26 27 private class RelationCounter implements Visitor {27 private static class RelationCounter implements Visitor { 28 28 int count; 29 29 @Override … … 54 54 counter.count = 0; 55 55 osm.visitReferrers(counter); 56 return new Long(counter.count);56 return Long.valueOf(counter.count); 57 57 } 58 58 -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/UsedInWaysMatch.java
r32410 r32725 25 25 } 26 26 27 private class WayCounter implements Visitor {27 private static class WayCounter implements Visitor { 28 28 int count; 29 29 @Override … … 54 54 counter.count = 0; 55 55 osm.visitReferrers(counter); 56 return new Long(counter.count);56 return Long.valueOf(counter.count); 57 57 } else return null; 58 58 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java
r32410 r32725 9 9 import java.util.Iterator; 10 10 import java.util.List; 11 import java.util.Objects; 11 12 import java.util.Set; 12 13 … … 107 108 int count = 0; 108 109 for (Way anyway: ways) { 109 if ( anyway == w) continue;110 if (Objects.equals(anyway, w)) continue; 110 111 if (newWays.contains(anyway) || excludeWays.contains(anyway)) continue; 111 112 … … 130 131 int count = 0; 131 132 for (Way anyway: ways) { 132 if ( anyway == w) continue;133 if (Objects.equals(anyway, w)) continue; 133 134 if (newWays.contains(anyway)) continue; 134 135 List<Pair<Node, Node>> nodePairs2 = anyway.getNodePairs(false); … … 291 292 292 293 for (OsmPrimitive ref : curNode.getReferrers()) { 293 if (ref instanceof Way && ref != w&& ref.isSelectable()) {294 if (ref instanceof Way && !Objects.equals(ref, w) && ref.isSelectable()) { 294 295 // 295 296 Way w2 = (Way) ref; … … 298 299 if (w2.getNodesCount() < 2 || w2.isClosed()) continue; 299 300 300 if ( curNode == w2.firstNode()) {301 if (Objects.equals(curNode, w2.firstNode())) { 301 302 nextNode = w2.getNode(1); 302 303 preLast = w2.getNode(w2.getNodesCount()-2); 303 304 endNode = w2.lastNode(); // forward direction 304 } else if ( curNode == w2.lastNode()) {305 } else if (Objects.equals(curNode, w2.lastNode())) { 305 306 nextNode = w2.getNode(w2.getNodesCount()-2); 306 307 preLast = w2.getNode(1); … … 321 322 } 322 323 } 323 if ( firstWay == nextWay) {324 if (Objects.equals(firstWay, nextWay)) { 324 325 //we came to starting way, but not not the right end 325 if ( otherEnd == firstWay.firstNode()) return false;326 if (Objects.equals(otherEnd, firstWay.firstNode())) return false; 326 327 newWays.addAll(newestWays); 327 328 return true; // correct loop found
Note:
See TracChangeset
for help on using the changeset viewer.