- Timestamp:
- 2007-10-13T00:12:31+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r368 r373 83 83 c = deleteWithReferences(Main.ds.getSelected()); 84 84 } else { 85 c = delete(Main.ds.getSelected() );85 c = delete(Main.ds.getSelected(), false); 86 86 } 87 87 if (c != null) { … … 100 100 return; 101 101 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 102 boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 103 boolean alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 104 System.out.println("meta="+alt); 102 105 103 106 OsmPrimitive sel = Main.map.mapView.getNearestNode(e.getPoint()); … … 105 108 if (sel == null) { 106 109 WaySegment ws = Main.map.mapView.getNearestWaySegment(e.getPoint()); 107 if (ws != null) c = deleteWaySegment(ws); 110 if (ws != null) { 111 if (shift) { 112 c = deleteWaySegment(ws); 113 } else if (ctrl) { 114 c = deleteWithReferences(Collections.singleton((OsmPrimitive)ws.way)); 115 } else { 116 c = delete(Collections.singleton((OsmPrimitive)ws.way), alt); 117 } 118 } 108 119 } else if (ctrl) { 109 120 c = deleteWithReferences(Collections.singleton(sel)); 110 121 } else { 111 c = delete(Collections.singleton(sel) );122 c = delete(Collections.singleton(sel), alt); 112 123 } 113 124 if (c != null) { … … 155 166 * 156 167 * @param selection The objects to delete. 168 * @param alsoDeleteNodesInWay true if nodes should be deleted as well 157 169 * @return command A command to perform the deletions, or null of there is 158 170 * nothing to delete. 159 171 */ 160 private Command delete(Collection<OsmPrimitive> selection ) {172 private Command delete(Collection<OsmPrimitive> selection, boolean alsoDeleteNodesInWay) { 161 173 if (selection.isEmpty()) return null; 162 174 163 175 Collection<OsmPrimitive> del = new HashSet<OsmPrimitive>(selection); 164 176 Collection<Way> waysToBeChanged = new HashSet<Way>(); 177 178 // nodes belonging to a way will be deleted if 179 // 1. this has been requested (alt modifier) 180 // 2. the node is not tagged 181 // 3. the node is not used by anybody else (i.e. has only one backref) 182 if (alsoDeleteNodesInWay) { 183 for (OsmPrimitive osm : del) { 184 if (osm instanceof Way) { 185 for (Node n : ((Way)osm).nodes) { 186 if (!n.tagged) { 187 CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(Main.ds, false); 188 n.visit(v); 189 if (v.data.size() == 1) { 190 del.add(n); 191 } else System.out.println("size="+v.data.size()); 192 } 193 else System.out.println("tagged"); 194 } 195 } 196 } 197 } 198 165 199 for (OsmPrimitive osm : del) { 166 200 CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(Main.ds, false); … … 217 251 if (n1.size() < 2 && n2.size() < 2) { 218 252 return new DeleteCommand(Collections.singleton(ws.way)); 219 } else { 220 Way wnew = new Way(ws.way); 221 wnew.nodes.clear(); 222 223 if (n1.size() < 2) { 224 wnew.nodes.addAll(n2); 225 return new ChangeCommand(ws.way, wnew); 226 } else if (n2.size() < 2) { 227 wnew.nodes.addAll(n1); 228 return new ChangeCommand(ws.way, wnew); 229 } else { 230 Collection<Command> cmds = new LinkedList<Command>(); 231 232 wnew.nodes.addAll(n1); 233 cmds.add(new ChangeCommand(ws.way, wnew)); 234 235 Way wnew2 = new Way(); 236 wnew2.nodes.addAll(n2); 237 cmds.add(new AddCommand(wnew2)); 238 239 return new SequenceCommand(tr("Split way segment"), cmds); 240 } 241 } 253 } 254 255 Way wnew = new Way(ws.way); 256 wnew.nodes.clear(); 257 258 if (n1.size() < 2) { 259 wnew.nodes.addAll(n2); 260 return new ChangeCommand(ws.way, wnew); 261 } else if (n2.size() < 2) { 262 wnew.nodes.addAll(n1); 263 return new ChangeCommand(ws.way, wnew); 264 } else { 265 Collection<Command> cmds = new LinkedList<Command>(); 266 267 wnew.nodes.addAll(n1); 268 cmds.add(new ChangeCommand(ws.way, wnew)); 269 270 Way wnew2 = new Way(); 271 wnew2.nodes.addAll(n2); 272 cmds.add(new AddCommand(wnew2)); 273 274 return new SequenceCommand(tr("Split way segment"), cmds); 275 } 276 } 277 278 @Override public String getModeHelpText() { 279 return "Click to delete. Shift: delete way segment. Alt: delete way+nodes. Ctrl: delete referring objects."; 242 280 } 243 281 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r359 r373 5 5 6 6 import java.awt.Cursor; 7 import java.awt.event.ActionEvent; 7 8 import java.awt.event.KeyEvent; 8 9 import java.awt.event.MouseEvent; … … 20 21 import org.openstreetmap.josm.Main; 21 22 import org.openstreetmap.josm.actions.GroupAction; 23 import org.openstreetmap.josm.actions.mapmode.SelectAction.Mode; 22 24 import org.openstreetmap.josm.command.AddCommand; 23 25 import org.openstreetmap.josm.command.ChangeCommand; … … 33 35 34 36 /** 35 * This mode adds a new node to the dataset. The user clicks on a place to add36 * and there is it. Nothing more, nothing less.37 *38 * FIXME: "nothing more, nothing less" is a bit out-of-date39 *40 * Newly created nodes are selected. Shift modifier does not cancel the old41 * selection as usual.42 *43 * @author imi44 37 * 45 38 */ … … 80 73 return; 81 74 75 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 76 boolean alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 77 boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 78 82 79 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 83 80 Collection<Command> cmds = new LinkedList<Command>(); … … 86 83 replacedWays = new ArrayList<Way>(); 87 84 boolean newNode = false; 88 Node n = Main.map.mapView.getNearestNode(e.getPoint()); 85 Node n = null; 86 if (!ctrl) n = Main.map.mapView.getNearestNode(e.getPoint()); 89 87 if (n == null) { 90 88 n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY())); … … 98 96 cmds.add(new AddCommand(n)); 99 97 100 // Insert the node into all the nearby way segments 101 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(e.getPoint()); 102 Map<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); 103 for (WaySegment ws : wss) { 104 List<Integer> is; 105 if (insertPoints.containsKey(ws.way)) { 106 is = insertPoints.get(ws.way); 107 } else { 108 is = new ArrayList<Integer>(); 109 insertPoints.put(ws.way, is); 98 if (!ctrl) { 99 // Insert the node into all the nearby way segments 100 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(e.getPoint()); 101 Map<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); 102 for (WaySegment ws : wss) { 103 List<Integer> is; 104 if (insertPoints.containsKey(ws.way)) { 105 is = insertPoints.get(ws.way); 106 } else { 107 is = new ArrayList<Integer>(); 108 insertPoints.put(ws.way, is); 109 } 110 111 is.add(ws.lowerIndex); 110 112 } 111 112 is.add(ws.lowerIndex); 113 } 114 for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) { 115 Way w = insertPoint.getKey(); 116 List<Integer> is = insertPoint.getValue(); 117 118 Way wnew = new Way(w); 119 120 pruneSuccsAndReverse(is); 121 for (int i : is) wnew.nodes.add(i + 1, n); 122 123 cmds.add(new ChangeCommand(insertPoint.getKey(), wnew)); 124 replacedWays.add(insertPoint.getKey()); 125 reuseWays.add(wnew); 126 } 127 } 128 113 114 for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) { 115 Way w = insertPoint.getKey(); 116 List<Integer> is = insertPoint.getValue(); 117 118 Way wnew = new Way(w); 119 120 pruneSuccsAndReverse(is); 121 for (int i : is) wnew.nodes.add(i + 1, n); 122 123 cmds.add(new ChangeCommand(insertPoint.getKey(), wnew)); 124 replacedWays.add(insertPoint.getKey()); 125 reuseWays.add(wnew); 126 } 127 } 128 } 129 129 boolean extendedWay = false; 130 if ( selection.size() == 1 && selection.iterator().next() instanceof Node) {130 if (!shift && selection.size() == 1 && selection.iterator().next() instanceof Node) { 131 131 Node n0 = (Node) selection.iterator().next(); 132 132 … … 213 213 Collections.reverse(is); 214 214 } 215 216 @Override public String getModeHelpText() { 217 return "Click to add a new node. Ctrl to disable node re-use/auto-insert. Shift to disable auto-connect."; 218 } 215 219 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r343 r373 48 48 oldCursor = Main.map.mapView.getCursor(); 49 49 Main.map.mapView.setCursor(cursor); 50 50 updateStatusLine(); 51 51 } 52 52 public void exitMode() { … … 55 55 } 56 56 57 protected void updateStatusLine() { 58 Main.map.statusLine.setHelpText(getModeHelpText()); 59 } 60 61 public String getModeHelpText() { 62 return ""; 63 } 57 64 /** 58 65 * Call selectMapMode(this) on the parent mapFrame. -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r372 r373 199 199 } 200 200 201 updateStatusLine(); 201 202 Main.map.mapView.repaint(); 202 203 … … 212 213 } 213 214 restoreCursor(); 215 updateStatusLine(); 214 216 mode = null; 217 updateStatusLine(); 215 218 } 216 219 … … 237 240 Main.map.mapView.repaint(); 238 241 } 242 243 @Override public String getModeHelpText() { 244 if (mode == Mode.select) { 245 return "Release the mouse button to select the objects in the rectangle."; 246 } else if (mode == Mode.move) { 247 return "Release the mouse button to stop moving."; 248 } else if (mode == Mode.rotate) { 249 return "Release the mouse button to stop rotating."; 250 } else { 251 return "Move objects by dragging; Shift to add to selection; Shift-Ctrl to rotate selected; or change selection"; 252 } 253 } 239 254 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
r298 r373 70 70 selectionManager.unregister(mv); 71 71 } 72 73 @Override public String getModeHelpText() { 74 return "Zoom in by dragging."; 75 } 72 76 } -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r365 r373 54 54 * The status line below the map 55 55 */ 56 p rivateMapStatus statusLine;56 public MapStatus statusLine; 57 57 58 58 public ConflictDialog conflictDialog; -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r343 r373 6 6 import java.awt.AWTEvent; 7 7 import java.awt.Cursor; 8 import java.awt.Dimension; 8 9 import java.awt.EventQueue; 9 10 import java.awt.Font; … … 17 18 import java.awt.event.MouseMotionListener; 18 19 import java.lang.reflect.InvocationTargetException; 20 import java.text.DecimalFormat; 21 import java.text.NumberFormat; 19 22 import java.util.Collection; 20 23 import java.util.ConcurrentModificationException; … … 58 61 * The position of the mouse cursor. 59 62 */ 60 JTextField positionText = new JTextField("-000.00000000000000 -000.00000000000000".length()); 63 DecimalFormat latlon = new DecimalFormat("###0.0000000"); 64 JTextField positionText = new JTextField(25); 65 61 66 /** 62 67 * The field holding the name of the object under the mouse. … … 64 69 JTextField nameText = new JTextField(30); 65 70 71 /** 72 * The field holding information about what the user can do. 73 */ 74 JTextField helpText = new JTextField(); 75 66 76 /** 67 77 * The collector class that waits for notification and then update … … 114 124 // the data. 115 125 try { 116 Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos); 117 118 if (osms == null && osmStatus == null && ms.modifiers == oldModifiers) 119 continue; 120 if (osms != null && osms.equals(osmStatus) && ms.modifiers == oldModifiers) 121 continue; 122 126 // Popup Information 127 if ((ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0 ) { 128 Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos); 129 130 if (osms == null) 131 continue; 132 if (osms != null && osms.equals(osmStatus) && ms.modifiers == oldModifiers) 133 continue; 134 /* 123 135 osmStatus = osms; 124 136 oldModifiers = ms.modifiers; … … 133 145 } else 134 146 nameText.setText(""); 135 136 // Popup Information137 if ((ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0 && osms != null) { 147 */ 148 149 138 150 if (popup != null) { 139 151 try { … … 235 247 if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0) { 236 248 LatLon p = mv.getLatLon(e.getX(),e.getY()); 237 positionText.setText( p.lat()+" "+p.lon());249 positionText.setText(latlon.format(p.lat())+" "+latlon.format(p.lon())); 238 250 } 239 251 } … … 242 254 positionText.setEditable(false); 243 255 nameText.setEditable(false); 244 setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); 256 helpText.setEditable(false); 257 setLayout(new GridBagLayout()); 245 258 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 246 add(new JLabel(tr("Lat/Lon")+" ")); 247 add(positionText); 248 add(new JLabel(" "+tr("Object")+" ")); 249 add(nameText); 250 259 add(new JLabel(tr("Lat/Lon")+" "), GBC.std()); 260 add(positionText, GBC.std()); 261 //add(new JLabel(" "+tr("Object")+" ")); 262 //add(nameText); 263 add(helpText, GBC.eol().fill(GBC.HORIZONTAL)); 264 positionText.setMinimumSize(new Dimension(positionText.getMinimumSize().height, 200)); 265 251 266 // The background thread 252 267 final Collector collector = new Collector(mapFrame); … … 270 285 return "Statusline"; 271 286 } 287 288 public void setHelpText(String t) { 289 helpText.setText(t); 290 } 272 291 }
Note:
See TracChangeset
for help on using the changeset viewer.