Changeset 768 in josm for trunk/src/org
- Timestamp:
- 2008-08-11T20:59:42+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UnselectAllAction.java
r627 r768 14 14 15 15 public UnselectAllAction() { 16 super(tr("Unselect All"),"unselectall", tr("Unselect all objects."), KeyEvent.VK_U, 0, true); 16 super(tr("Unselect All"), "unselectall", tr("Unselect all objects."), 17 KeyEvent.VK_U, 0, true); 17 18 18 19 // Add extra shortcut C-S-a 19 20 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 20 KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK), tr("Unselect All")); 21 } 21 KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK 22 | KeyEvent.SHIFT_DOWN_MASK), tr("Unselect All")); 23 24 // Add extra shortcut ESCAPE 25 /* 26 * FIXME: this isn't optimal. In a better world the mapmode actions 27 * would be able to capture keyboard events and react accordingly. But 28 * for now this is a reasonable approximation. 29 */ 30 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 31 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), 32 tr("Unselect All")); 33 } 22 34 23 35 public void actionPerformed(ActionEvent e) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r674 r768 54 54 */ 55 55 public DeleteAction(MapFrame mapFrame) { 56 super(tr("Delete "),56 super(tr("DeleteMode"), 57 57 "delete", 58 58 tr("Delete nodes or ways."), … … 75 75 @Override public void actionPerformed(ActionEvent e) { 76 76 super.actionPerformed(e); 77 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 77 doActionPerformed(e); 78 } 79 80 public void doActionPerformed(ActionEvent e) { 81 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 78 82 boolean alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 79 83 … … 89 93 90 94 Main.map.repaint(); 91 95 } 92 96 93 97 /** -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r655 r768 277 277 return ColorHelper.html2color(colStr); 278 278 } 279 280 public int getInteger(String key, int def) { 281 String v = get(key); 282 if(null == v) 283 return def; 284 285 try { 286 return Integer.parseInt(v); 287 } catch(NumberFormatException e) { 288 // fall out 289 } 290 291 return def; 292 } 279 293 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r757 r768 9 9 import java.awt.Point; 10 10 import java.awt.Polygon; 11 import java.awt.RenderingHints; 11 12 import java.awt.Stroke; 12 13 import java.awt.geom.GeneralPath; … … 17 18 18 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.actions.UnselectAllAction; 19 21 import org.openstreetmap.josm.data.Preferences; 20 22 import org.openstreetmap.josm.data.osm.DataSet; … … 77 79 protected boolean showOrderNumber; 78 80 81 private boolean fillSelectedNode; 82 83 private boolean fillUnselectedNode; 84 85 private int selectedNodeRadius; 86 87 private int unselectedNodeRadius; 88 89 private int selectedNodeSize; 90 91 private int unselectedNodeSize; 92 93 private int defaultSegmentWidth = 2; 94 79 95 public final static Color darkerblue = new Color(0,0,96); 80 96 public final static Color darkblue = new Color(0,0,128); … … 126 142 } 127 143 } else { 128 drawNode(n, n.selected ? selectedColor : nodeColor); 144 if (n.selected) 145 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 146 else 147 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 129 148 } 130 149 } … … 143 162 144 163 Color colour = untaggedColor; 145 int width = 2;164 int width = defaultSegmentWidth; 146 165 int realWidth = 0; //the real width of the element in meters 147 166 boolean dashed = false; … … 326 345 * @param color The color of the node. 327 346 */ 328 public void drawNode(Node n, Color color) { 329 if(isZoomOk(null)) { 330 Point p = nc.getPoint(n.eastNorth); 331 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 332 g.setColor(color); 333 g.drawRect(p.x-1, p.y-1, 2, 2); 334 } 335 } 347 public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 348 if (isZoomOk(null) && size > 1) { 349 Point p = nc.getPoint(n.eastNorth); 350 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) 351 || (p.y > nc.getHeight())) 352 return; 353 g.setColor(color); 354 if (fill) 355 g.fillRect(p.x - radius, p.y - radius, size, size); 356 else 357 g.drawRect(p.x - radius, p.y - radius, size, size); 358 } 359 } 336 360 337 361 // NW 111106 Overridden from SimplePaintVisitor in josm-1.4-nw1 … … 353 377 fillAreas = Main.pref.getBoolean("mappaint.fillareas", true); 354 378 355 /* XXX - there must be a better way to get a bounded Integer pref! */ 356 try { 357 fillAlpha = Integer.valueOf(Main.pref.get("mappaint.fillalpha", "50")); 358 if (fillAlpha < 0) { 359 fillAlpha = 0; 360 } 361 if (fillAlpha > 255) { 362 fillAlpha = 255; 363 } 364 } catch (NumberFormatException nfe) { 365 fillAlpha = 50; 366 } 379 selectedNodeRadius = Main.pref.getInteger("mappaint.node.selected-size", 380 5) / 2; 381 selectedNodeSize = selectedNodeRadius * 2; 382 unselectedNodeRadius = Main.pref.getInteger( 383 "mappaint.node.unselected-size", 3) / 2; 384 unselectedNodeSize = unselectedNodeRadius * 2; 385 386 defaultSegmentWidth = Main.pref.getInteger( 387 "mappaint.segment.default-width", 2); 388 389 fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", 390 true); 391 fillUnselectedNode = Main.pref.getBoolean( 392 "mappaint.node.fill-unselected", false); 393 394 ((Graphics2D)g) 395 .setRenderingHint( 396 RenderingHints.KEY_ANTIALIASING, 397 Main.pref.getBoolean("mappaint.use-antialiasing", true) ? RenderingHints.VALUE_ANTIALIAS_ON 398 : RenderingHints.VALUE_ANTIALIAS_OFF); 399 400 fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref 401 .getInteger("mappaint.fillalpha", 50)))); 367 402 368 403 Collection<Way> noAreaWays = new LinkedList<Way>(); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r759 r768 8 8 import java.awt.Point; 9 9 import java.awt.Rectangle; 10 import java.awt.RenderingHints; 10 11 import java.awt.Stroke; 11 12 import java.awt.geom.GeneralPath; 12 13 13 import java.util.Iterator; 14 14 15 import org.openstreetmap.josm.Main; 15 16 import org.openstreetmap.josm.data.Preferences; 16 17 import org.openstreetmap.josm.data.osm.DataSet; 17 import org.openstreetmap.josm.data.osm.Relation;18 18 import org.openstreetmap.josm.data.osm.RelationMember; 19 19 import org.openstreetmap.josm.data.osm.Node; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.data.osm.Relation; 22 import org.openstreetmap.josm.data.osm.RelationMember; 21 23 import org.openstreetmap.josm.data.osm.Way; 22 24 import org.openstreetmap.josm.gui.NavigatableComponent; 23 import org.openstreetmap.josm.tools.ColorHelper;24 25 25 26 /** … … 64 65 protected boolean showOrderNumber; 65 66 67 private boolean fillSelectedNode; 68 69 private boolean fillUnselectedNode; 70 71 private int selectedNodeRadius; 72 73 private int unselectedNodeRadius; 74 75 private int selectedNodeSize; 76 77 private int unselectedNodeSize; 78 79 private int defaultSegmentWidth = 2; 80 66 81 /** 67 82 * Draw subsequent segments of same color as one Path … … 85 100 showOrderNumber = Main.pref.getBoolean("draw.segment.order_number"); 86 101 102 selectedNodeRadius = Main.pref.getInteger("mappaint.node.selected-size", 103 5) / 2; 104 selectedNodeSize = selectedNodeRadius * 2; 105 unselectedNodeRadius = Main.pref.getInteger( 106 "mappaint.node.unselected-size", 3) / 2; 107 unselectedNodeSize = unselectedNodeRadius * 2; 108 109 defaultSegmentWidth = Main.pref.getInteger( 110 "mappaint.segment.default-width", 2); 111 112 fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", 113 true); 114 fillUnselectedNode = Main.pref.getBoolean( 115 "mappaint.node.fill-unselected", false); 116 117 ((Graphics2D)g) 118 .setRenderingHint( 119 RenderingHints.KEY_ANTIALIASING, 120 Main.pref.getBoolean("mappaint.use-antialiasing", true) ? RenderingHints.VALUE_ANTIALIAS_ON 121 : RenderingHints.VALUE_ANTIALIAS_OFF); 122 87 123 // draw tagged ways first, then untagged ways. takes 88 124 // time to iterate through list twice, OTOH does not … … 121 157 if (n.incomplete) return; 122 158 123 Color color = null;124 159 if (inactive) 125 color = inactiveColor;160 drawNode(n, inactiveColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 126 161 else if (n.selected) 127 color = selectedColor;162 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 128 163 else 129 color = nodeColor; 130 drawNode(n, color); 164 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 131 165 } 132 166 … … 235 269 * @param color The color of the node. 236 270 */ 237 public void drawNode(Node n, Color color ) {238 Point p = nc.getPoint(n.eastNorth);239 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;240 241 g.setColor(color); 242 243 if (n.tagged) { 244 g.drawRect(p.x, p.y, 0, 0); 245 g.drawRect(p.x-2, p.y-2, 4, 4);246 } else { 247 g.drawRect(p.x-1, p.y-1, 2, 2);248 271 public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 272 if (size > 1) { 273 Point p = nc.getPoint(n.eastNorth); 274 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) 275 || (p.y > nc.getHeight())) 276 return; 277 g.setColor(color); 278 if (fill) 279 g.fillRect(p.x - radius, p.y - radius, size, size); 280 else 281 g.drawRect(p.x - radius, p.y - radius, size, size); 282 } 249 283 } 250 284 -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r627 r768 15 15 16 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.actions.AlignInRectangleAction;18 import org.openstreetmap.josm.actions.JosmAction;19 17 import org.openstreetmap.josm.actions.AboutAction; 20 18 import org.openstreetmap.josm.actions.AlignInCircleAction; 21 19 import org.openstreetmap.josm.actions.AlignInLineAction; 20 import org.openstreetmap.josm.actions.AlignInRectangleAction; 22 21 import org.openstreetmap.josm.actions.AutoScaleAction; 23 22 import org.openstreetmap.josm.actions.CombineWayAction; 24 23 import org.openstreetmap.josm.actions.CopyAction; 24 import org.openstreetmap.josm.actions.DeleteAction; 25 25 import org.openstreetmap.josm.actions.DownloadAction; 26 26 import org.openstreetmap.josm.actions.DuplicateAction; … … 29 29 import org.openstreetmap.josm.actions.HelpAction; 30 30 import org.openstreetmap.josm.actions.JoinNodeWayAction; 31 import org.openstreetmap.josm.actions.JosmAction; 31 32 import org.openstreetmap.josm.actions.MergeNodesAction; 32 33 import org.openstreetmap.josm.actions.NewAction; … … 44 45 import org.openstreetmap.josm.actions.UnselectAllAction; 45 46 import org.openstreetmap.josm.actions.UploadAction; 47 import org.openstreetmap.josm.actions.ZoomInAction; 48 import org.openstreetmap.josm.actions.ZoomOutAction; 46 49 import org.openstreetmap.josm.actions.audio.AudioBackAction; 50 import org.openstreetmap.josm.actions.audio.AudioFasterAction; 47 51 import org.openstreetmap.josm.actions.audio.AudioFwdAction; 48 52 import org.openstreetmap.josm.actions.audio.AudioNextAction; 49 53 import org.openstreetmap.josm.actions.audio.AudioPlayPauseAction; 50 54 import org.openstreetmap.josm.actions.audio.AudioPrevAction; 51 import org.openstreetmap.josm.actions.audio.AudioFasterAction;52 55 import org.openstreetmap.josm.actions.audio.AudioSlowerAction; 53 56 import org.openstreetmap.josm.actions.search.SearchAction; … … 79 82 public final JosmAction copy = new CopyAction(); 80 83 public final JosmAction paste = new PasteAction(); 84 public final JosmAction delete = new DeleteAction(); 81 85 public final JosmAction pasteTags = new PasteTagsAction(copy); 82 86 public final JosmAction duplicate = new DuplicateAction(); … … 154 158 current = editMenu.add(copy); 155 159 current.setAccelerator(copy.shortCut); 160 current = editMenu.add(delete); 161 current.setAccelerator(delete.shortCut); 156 162 current = editMenu.add(paste); 157 163 current.setAccelerator(paste.shortCut); … … 180 186 } 181 187 viewMenu.addSeparator(); 182 183 // TODO move code to an "action" like the others? 188 JosmAction a = new ZoomOutAction(); 189 viewMenu.add(a).setAccelerator(a.shortCut); 190 a = new ZoomInAction(); 191 viewMenu.add(a).setAccelerator(a.shortCut); 192 193 viewMenu.addSeparator(); 194 195 // TODO move code to an "action" like the others? 184 196 final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(tr("Wireframe view")); 185 197 wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", true)); -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r655 r768 110 110 */ 111 111 public Point getPoint(EastNorth p) { 112 if(null == p) 113 return new Point(); 112 114 double x = (p.east()-center.east())/scale + getWidth()/2; 113 115 double y = (center.north()-p.north())/scale + getHeight()/2; -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r743 r768 187 187 } 188 188 }); 189 fc.showOpenDialog(Main.parent); 190 File sel = fc.getSelectedFile(); 191 if (!fc.getCurrentDirectory().getAbsolutePath().equals(dir)) 192 Main.pref.put("markers.lastaudiodirectory", fc.getCurrentDirectory().getAbsolutePath()); 193 if (sel == null) 194 return; 195 importAudio(sel); 196 Main.map.repaint(); 189 fc.setMultiSelectionEnabled(true); 190 if(fc.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) { 191 if (!fc.getCurrentDirectory().getAbsolutePath().equals(dir)) 192 Main.pref.put("markers.lastaudiodirectory", fc 193 .getCurrentDirectory().getAbsolutePath()); 194 195 // FIXME: properly support multi-selection here. 196 // Calling importAudio several times just creates N maker layers, which 197 // is sub-optimal. 198 File sel[] = fc.getSelectedFiles(); 199 if(sel != null) 200 for (int i = 0; i < sel.length; i++) 201 importAudio(sel[i]); 202 203 Main.map.repaint(); 204 } 197 205 } 198 206 });
Note:
See TracChangeset
for help on using the changeset viewer.