Changeset 608 in josm
- Timestamp:
- 2008-04-17T03:03:28+02:00 (17 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.settings/org.eclipse.jdt.ui.prefs
r444 r608 1 # Thu Nov 01 00:40:04 CET 20071 #Wed Apr 16 17:01:39 CEST 2008 2 2 eclipse.preferences.version=1 3 3 formatter_profile=_josm 4 4 formatter_settings_version=10 5 org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">// License\: GPL. \n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">// License\: GPL. Copyright 2007 by Immanuel Scholz and others\n${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>5 org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">// License\: GPL. \n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">// License\: GPL. For details, see LICENSE file.\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r484 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 // License: GPL. See LICENSE file for details. 2 2 package org.openstreetmap.josm.actions.mapmode; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.AWTEvent; 7 import java.awt.BasicStroke; 8 import java.awt.Color; 6 9 import java.awt.Cursor; 10 import java.awt.Graphics; 11 import java.awt.Graphics2D; 12 import java.awt.Point; 13 import java.awt.Toolkit; 14 import java.awt.event.AWTEventListener; 7 15 import java.awt.event.ActionEvent; 16 import java.awt.event.InputEvent; 8 17 import java.awt.event.KeyEvent; 9 18 import java.awt.event.MouseEvent; 10 import javax.swing.KeyStroke; 11 import javax.swing.JComponent; 19 import java.awt.geom.GeneralPath; 12 20 import java.util.ArrayList; 13 21 import java.util.Collection; … … 16 24 import java.util.HashSet; 17 25 import java.util.Iterator; 26 import java.util.LinkedList; 27 import java.util.List; 18 28 import java.util.Map; 19 29 import java.util.Set; 20 import java.util.LinkedList; 21 import java.util.List; 22 30 31 import javax.swing.JComponent; 23 32 import javax.swing.JOptionPane; 33 import javax.swing.KeyStroke; 24 34 25 35 import org.openstreetmap.josm.Main; … … 28 38 import org.openstreetmap.josm.command.Command; 29 39 import org.openstreetmap.josm.command.SequenceCommand; 40 import org.openstreetmap.josm.data.Preferences; 41 import org.openstreetmap.josm.data.SelectionChangedListener; 30 42 import org.openstreetmap.josm.data.coor.EastNorth; 43 import org.openstreetmap.josm.data.coor.LatLon; 44 import org.openstreetmap.josm.data.osm.DataSet; 31 45 import org.openstreetmap.josm.data.osm.Node; 32 import org.openstreetmap.josm.tools.Pair;33 46 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 47 import org.openstreetmap.josm.data.osm.Way; 35 48 import org.openstreetmap.josm.data.osm.WaySegment; 36 49 import org.openstreetmap.josm.gui.MapFrame; 50 import org.openstreetmap.josm.gui.MapView; 51 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 37 52 import org.openstreetmap.josm.tools.ImageProvider; 53 import org.openstreetmap.josm.tools.Pair; 38 54 39 55 /** 40 56 * 41 */ 42 public class DrawAction extends MapMode { 43 57 */ 58 public class DrawAction extends MapMode implements MapViewPaintable, SelectionChangedListener, AWTEventListener { 59 44 60 private static Node lastUsedNode = null; 45 61 private double PHI=Math.toRadians(90); 62 63 private boolean ctrl; 64 private boolean alt; 65 private boolean shift; 66 private boolean mouseOnExistingNode; 67 private boolean drawHelperLine; 68 private Point mousePos; 69 private Color selectedColor; 70 71 private Node currentBaseNode; 72 private EastNorth currentMouseEastNorth; 73 46 74 public DrawAction(MapFrame mapFrame) { 47 75 super(tr("Draw"), "node/autonode", tr("Draw nodes"), … … 53 81 54 82 //putValue("help", "Action/AddNode/Autnode"); 83 selectedColor = Preferences.getPreferencesColor("selected", Color.YELLOW); 84 85 drawHelperLine = Main.pref.getBoolean("draw.helper-line", true); 55 86 } 56 87 … … 66 97 super.enterMode(); 67 98 Main.map.mapView.addMouseListener(this); 68 } 69 99 Main.map.mapView.addMouseMotionListener(this); 100 Main.map.mapView.addTemporaryLayer(this); 101 DataSet.selListeners.add(this); 102 try { 103 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 104 } catch (SecurityException ex) { 105 } 106 // would like to but haven't got mouse position yet: 107 // computeHelperLine(false, false, false); 108 } 70 109 @Override public void exitMode() { 71 110 super.exitMode(); 72 111 Main.map.mapView.removeMouseListener(this); 112 Main.map.mapView.removeMouseMotionListener(this); 113 Main.map.mapView.removeTemporaryLayer(this); 114 DataSet.selListeners.remove(this); 115 try { 116 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 117 } catch (SecurityException ex) { 118 } 119 } 120 121 /** 122 * redraw to (possibly) get rid of helper line if selection changes. 123 */ 124 public void eventDispatched(AWTEvent event) { 125 InputEvent e = (InputEvent) event; 126 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 127 alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 128 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 129 computeHelperLine(); 130 } 131 /** 132 * redraw to (possibly) get rid of helper line if selection changes. 133 */ 134 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 135 computeHelperLine(); 73 136 } 74 137 … … 80 143 */ 81 144 @Override public void mouseClicked(MouseEvent e) { 145 82 146 if (e.getButton() != MouseEvent.BUTTON1) 83 147 return; 84 148 85 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 86 boolean alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 87 boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 149 // we copy ctrl/alt/shift from the event just in case our global 150 // AWTEvent didn't make it through the security manager. Unclear 151 // if that can ever happen but better be safe. 152 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 153 alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 154 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 155 mousePos = e.getPoint(); 88 156 89 157 Collection<OsmPrimitive> selection = Main.ds.getSelected(); … … 94 162 boolean newNode = false; 95 163 Node n = null; 164 96 165 if (!ctrl) { 97 n = Main.map.mapView.getNearestNode( e.getPoint());166 n = Main.map.mapView.getNearestNode(mousePos); 98 167 } 99 168 … … 256 325 Main.main.undoRedo.add(c); 257 326 lastUsedNode = n; 327 computeHelperLine(); 328 Main.map.mapView.repaint(); 329 } 330 331 @Override public void mouseMoved(MouseEvent e) { 332 333 // we copy ctrl/alt/shift from the event just in case our global 334 // AWTEvent didn't make it through the security manager. Unclear 335 // if that can ever happen but better be safe. 336 337 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 338 alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 339 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 340 mousePos = e.getPoint(); 341 342 computeHelperLine(); 343 } 344 345 /** 346 * This method prepares data required for painting the "helper line" from 347 * the last used position to the mouse cursor. It duplicates some code from 348 * mouseClicked() (FIXME). 349 */ 350 private void computeHelperLine() { 351 352 double distance = -1; 353 double angle = -1; 354 355 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 356 357 Node selectedNode = null; 358 Way selectedWay = null; 359 Node currentMouseNode = null; 360 mouseOnExistingNode = false; 361 362 Main.map.statusLine.setAngle(-1); 363 Main.map.statusLine.setHeading(-1); 364 Main.map.statusLine.setDist(-1); 365 366 if (!ctrl && mousePos != null) { 367 currentMouseNode = Main.map.mapView.getNearestNode(mousePos); 368 } 369 370 if (currentMouseNode != null) { 371 // user clicked on node 372 if (selection.isEmpty()) return; 373 currentMouseEastNorth = currentMouseNode.eastNorth; 374 mouseOnExistingNode = true; 375 } else { 376 // no node found in clicked area 377 currentMouseEastNorth = Main.map.mapView.getEastNorth(mousePos.x, mousePos.y); 378 } 379 380 for (OsmPrimitive p : selection) { 381 if (p instanceof Node) { 382 if (selectedNode != null) return; 383 selectedNode = (Node) p; 384 } else if (p instanceof Way) { 385 if (selectedWay != null) return; 386 selectedWay = (Way) p; 387 } 388 } 389 390 // the node from which we make a connection 391 currentBaseNode = null; 392 Node previousNode = null; 393 394 if (selectedNode == null) { 395 if (selectedWay == null) return; 396 if (lastUsedNode == selectedWay.nodes.get(0) || lastUsedNode == selectedWay.nodes.get(selectedWay.nodes.size()-1)) { 397 currentBaseNode = lastUsedNode; 398 if (lastUsedNode == selectedWay.nodes.get(selectedWay.nodes.size()-1) && selectedWay.nodes.size() > 1) { 399 previousNode = selectedWay.nodes.get(selectedWay.nodes.size()-2); 400 } 401 } 402 } else if (selectedWay == null) { 403 currentBaseNode = selectedNode; 404 } else { 405 if (selectedNode == selectedWay.nodes.get(0) || selectedNode == selectedWay.nodes.get(selectedWay.nodes.size()-1)) { 406 currentBaseNode = selectedNode; 407 } 408 } 409 410 if (currentBaseNode == null || currentBaseNode == currentMouseNode) { 411 return; // Don't create zero length way segments. 412 } 413 414 Main.map.mapView.repaint(); 415 416 // find out the distance, in metres, between the base point and the mouse cursor 417 LatLon mouseLatLon = Main.proj.eastNorth2latlon(currentMouseEastNorth); 418 distance = currentBaseNode.coor.greatCircleDistance(mouseLatLon); 419 double hdg = Math.toDegrees(currentBaseNode.coor.heading(mouseLatLon)); 420 if (previousNode != null) { 421 angle = hdg - Math.toDegrees(previousNode.coor.heading(currentBaseNode.coor)); 422 if (angle < 0) angle += 360; 423 } 424 Main.map.statusLine.setAngle(angle); 425 Main.map.statusLine.setHeading(hdg); 426 Main.map.statusLine.setDist(distance); 427 updateStatusLine(); 428 } 429 430 /** 431 * Repaint on mouse exit so that the helper line goes away. 432 */ 433 @Override public void mouseExited(MouseEvent e) { 434 mousePos = e.getPoint(); 258 435 Main.map.mapView.repaint(); 259 436 } … … 347 524 A = seg.a.eastNorth; 348 525 B = seg.b.eastNorth; 349 double a = P.distance(B); 350 double b = P.distance(A); 351 double c = A.distance(B); 526 double a = P.distanceSq(B); 527 double b = P.distanceSq(A); 528 double c = A.distanceSq(B); 352 529 double q = (a - b + c) / (2*c); 353 530 n.eastNorth = new EastNorth( … … 362 539 return a * d - b * c; 363 540 } 364 541 542 public void paint(Graphics g, MapView mv) { 543 544 // don't draw line if disabled in prefs 545 if (!drawHelperLine) return; 546 547 // sanity checks 548 if (Main.map.mapView == null) return; 549 if (mousePos == null) return; 550 551 // if shift key is held ("no auto-connect"), don't draw a line 552 if (shift) return; 553 554 // don't draw line if we don't know where from or where to 555 if (currentBaseNode == null) return; 556 if (currentMouseEastNorth == null) return; 557 558 // don't draw line if mouse is outside window 559 if (!Main.map.mapView.getBounds().contains(mousePos)) return; 560 561 Graphics2D g2 = (Graphics2D) g; 562 g2.setColor(selectedColor); 563 g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); 564 GeneralPath b = new GeneralPath(); 565 Point p1=mv.getPoint(currentBaseNode.eastNorth); 566 Point p2=mv.getPoint(currentMouseEastNorth); 567 568 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI; 569 570 b.moveTo(p1.x,p1.y); b.lineTo(p2.x, p2.y); 571 572 // if alt key is held ("start new way"), draw a little perpendicular line 573 if (alt) { 574 b.moveTo((int)(p1.x + 8*Math.cos(t+PHI)), (int)(p1.y + 8*Math.sin(t+PHI))); 575 b.lineTo((int)(p1.x + 8*Math.cos(t-PHI)), (int)(p1.y + 8*Math.sin(t-PHI))); 576 } 577 578 g2.draw(b); 579 g2.setStroke(new BasicStroke(1)); 580 581 } 365 582 366 583 @Override public String getModeHelpText() { 367 return tr("Click to add a new node. Ctrl: no node re-use/auto-insert. Shift: no auto-connect. Alt: new way"); 584 String rv; 585 586 if (currentBaseNode != null && !shift) { 587 if (mouseOnExistingNode) { 588 if (alt && /* FIXME: way exists */true) 589 rv = tr("Click to create a new way to the existing node."); 590 else 591 rv =tr("Click to make a connection to the existing node."); 592 } else { 593 if (alt && /* FIXME: way exists */true) 594 rv = tr("Click to insert a nose and create a new way."); 595 else 596 rv = tr("Click to insert a new node and make a connection."); 597 } 598 } 599 else { 600 rv = tr("Click to insert a new node."); 601 } 602 603 //rv.append(tr("Click to add a new node. Ctrl: no node re-use/auto-insert. Shift: no auto-connect. Alt: new way")); 604 //rv.append(tr("Click to add a new node. Ctrl: no node re-use/auto-insert. Shift: no auto-connect. Alt: new way")); 605 return rv.toString(); 368 606 } 369 607 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r373 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 // License: GPL. See LICENSE file for details. 2 2 package org.openstreetmap.josm.actions.mapmode; 3 3 … … 18 18 * is another. 19 19 * 20 * MapModes should register/deregister all necessary listener on the map's view 20 * MapModes should register/deregister all necessary listeners on the map's view 21 21 * control. 22 22 */ … … 57 57 protected void updateStatusLine() { 58 58 Main.map.statusLine.setHelpText(getModeHelpText()); 59 Main.map.statusLine.repaint(); 59 60 } 60 61 -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r486 r608 2 2 package org.openstreetmap.josm.data; 3 3 4 import java.awt.Color; 4 5 import java.io.BufferedReader; 5 6 import java.io.File; … … 18 19 19 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.tools.ColorHelper; 20 22 21 23 … … 259 261 out.close(); 260 262 } 263 264 /** 265 * Convenience method for accessing colour preferences. 266 * 267 * @param colName name of the colour 268 * @param def default value 269 * @return a Color object for the configured colour, or the default value if none configured. 270 */ 271 public static Color getPreferencesColor(String colName, Color def) { 272 String colStr = Main.pref.get("color."+colName); 273 if (colStr.equals("")) { 274 Main.pref.put("color."+colName, ColorHelper.color2html(def)); 275 return def; 276 } 277 return ColorHelper.html2color(colStr); 278 } 261 279 } -
trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java
r486 r608 41 41 * Return the squared distance of the northing/easting values between 42 42 * this and the argument. 43 * 44 * This method does NOT compute a great circle distance between two 45 * locations! 43 46 * 44 47 * @param other The other point to calculate the distance to. … … 46 49 * regarding to the x/y values. 47 50 */ 51 public double distanceSq(Coordinate other) { 52 return (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y); 53 } 54 55 /** 56 * Return the distance of the northing/easting values between this and 57 * the argument. 58 * 59 * This method does NOT compute a great circle distance between two 60 * locations! 61 * 62 * @param other The other point to calculate the distance to. 63 * @return The square of the distance between this and the other point, 64 * regarding to the x/y values. 65 */ 48 66 public double distance(Coordinate other) { 49 return (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y);67 return Math.sqrt(distanceSq(other)); 50 68 } 51 69 -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r589 r608 58 58 * @return distance in metres. 59 59 */ 60 public int distance(LatLon other) {61 return ( int) (Math.acos(60 public double greatCircleDistance(LatLon other) { 61 return (Math.acos( 62 62 Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 63 63 Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) * 64 64 Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135); 65 } 66 67 /** 68 * Returns the heading, in radians, that you have to use to get from 69 * this lat/lon to another. 70 * 71 * @param other the "destination" position 72 * @return heading 73 */ 74 public double heading(LatLon other) { 75 double rv; 76 if (other.lat() == lat()) { 77 rv = (other.lon()>lon() ? Math.PI / 2 : Math.PI * 3 / 2); 78 } else { 79 rv = Math.atan((other.lon()-lon())/(other.lat()-lat())); 80 if (rv < 0) rv += Math.PI; 81 if (other.lon() < lon()) rv += Math.PI; 82 } 83 return rv; 65 84 } 66 85 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r599 r608 18 18 19 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.data.Preferences; 20 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.Node; … … 335 336 } 336 337 } 337 338 public static Color getPreferencesColor(String colName, Color def) {339 String colStr = Main.pref.get("color."+colName);340 if (colStr.equals("")) {341 Main.pref.put("color."+colName, ColorHelper.color2html(def));342 return def;343 }344 return ColorHelper.html2color(colStr);345 }346 338 347 339 // NW 111106 Overridden from SimplePaintVisitor in josm-1.4-nw1 348 340 // Shows areas before non-areas 349 341 public void visitAll(DataSet data) { 350 inactiveColor = getPreferencesColor("inactive", Color.DARK_GRAY); 351 selectedColor = getPreferencesColor("selected", Color.YELLOW); 352 nodeColor = getPreferencesColor("node", Color.RED); 353 dfltWayColor = getPreferencesColor("way", darkblue); 354 incompleteColor = getPreferencesColor("incomplete way", darkerblue); 355 backgroundColor = getPreferencesColor("background", Color.BLACK); 356 untaggedColor = getPreferencesColor("untagged",Color.GRAY); 357 textColor = getPreferencesColor ("text", Color.WHITE); 342 inactiveColor = Preferences.getPreferencesColor("inactive", Color.DARK_GRAY); 343 selectedColor = Preferences.getPreferencesColor("selected", Color.YELLOW); 344 nodeColor = Preferences.getPreferencesColor("node", Color.RED); 345 dfltWayColor = Preferences.getPreferencesColor("way", darkblue); 346 incompleteColor = Preferences.getPreferencesColor("incomplete way", darkerblue); 347 backgroundColor = Preferences.getPreferencesColor("background", Color.BLACK); 348 untaggedColor = Preferences.getPreferencesColor("untagged",Color.GRAY); 349 textColor = Preferences.getPreferencesColor ("text", Color.WHITE); 358 350 showDirectionArrow = Main.pref.getBoolean("draw.segment.direction"); 359 351 showRelevantDirectionsOnly = Main.pref.getBoolean("draw.segment.relevant_directions_only"); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r597 r608 11 11 import java.util.Iterator; 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.Preferences; 13 14 import org.openstreetmap.josm.data.osm.DataSet; 14 15 import org.openstreetmap.josm.data.osm.Relation; … … 68 69 69 70 public void visitAll(DataSet data) { 70 inactiveColor = getPreferencesColor("inactive", Color.DARK_GRAY); 71 selectedColor = getPreferencesColor("selected", Color.WHITE); 72 nodeColor = getPreferencesColor("node", Color.RED); 73 dfltWayColor = getPreferencesColor("way", darkblue); 74 untaggedWayColor = getPreferencesColor("untagged way", darkgreen); 75 incompleteColor = getPreferencesColor("incomplete way", darkerblue); 76 backgroundColor = getPreferencesColor("background", Color.BLACK); 71 inactiveColor = Preferences.getPreferencesColor("inactive", Color.DARK_GRAY); 72 selectedColor = Preferences.getPreferencesColor("selected", Color.WHITE); 73 nodeColor = Preferences.getPreferencesColor("node", Color.RED); 74 dfltWayColor = Preferences.getPreferencesColor("way", darkblue); 75 untaggedWayColor = Preferences.getPreferencesColor("untagged way", darkgreen); 76 incompleteColor = Preferences.getPreferencesColor("incomplete way", darkerblue); 77 backgroundColor = Preferences.getPreferencesColor("background", Color.BLACK); 77 78 showDirectionArrow = Main.pref.getBoolean("draw.segment.direction"); 78 79 showRelevantDirectionsOnly = Main.pref.getBoolean("draw.segment.relevant_directions_only"); … … 226 227 return screen.intersects(bbox); 227 228 } 228 229 public static Color getPreferencesColor(String colName, Color def) {230 String colStr = Main.pref.get("color."+colName);231 if (colStr.equals("")) {232 Main.pref.put("color."+colName, ColorHelper.color2html(def));233 return def;234 }235 return ColorHelper.html2color(colStr);236 }237 229 238 230 public void setGraphics(Graphics g) { -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r582 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 48 49 panel = new JPanel(new GridBagLayout()); 49 50 50 panel.add(new JLabel(tr("<html><h2>You are running the latest JOSM version with built-in mappaint support.</h2>" + 51 "<h3>The mappaint plugin is no longer necessary and has been removed from your configuration<br>" + 52 "file (if it was present). You can now switch between the \"classic\" display and the mappaint<br>" + 53 "style by toggling the \"Wireframe\" option in the \"View\" menu.</h3>" + 54 "<h3>If you have not used new JOSM versions for a while, you will also discover that this JOSM<br>" + 55 "is \"modeless\". It (almost) does away with the old edit modes, like \"add node and connect\" etc.;<br>"+ 56 "instead, there are only four modes: zoom, select, edit, and delete. The edit mode will do what<br>"+ 57 "you want in most cases (also see the mini help about modifier keys at the bottom of the screen)." + 51 panel.add(new JLabel(tr("<html><h2>You are running the latest JOSM version with some geometry extensions.</h2>" + 52 "<h3>New elements in the status bar will inform you about the orientation and size<br>" + 53 "of the object being drawn. There is a new \"extrude\" mode that you can use to create<br>" + 54 "rectangular shapes (see below for a short video on this).</h3>" + 55 "<h3>There is also a new option in the tools menu that will make existing shapes into proper<br>" + 56 "rectangles. Note that all this is dependend on the projection you're using; you must use<br>"+ 57 "a projection in which rectangles look rectangular and not skewed. Try it out.</h3>"+ 58 "<h3>If you dislike the helper line dangling from the mouse cursor, set the \"draw.helper-line\"<br>"+ 59 "preference to \"false\"."+ 58 60 "</h3>")), GBC.eol()); 59 61 60 // remove these two keys from preferences if present 62 /* 61 63 boolean changePrefs = ! ( 62 64 "0.5".equals(Main.pref.get("osm-server.version", "0.5")) && … … 69 71 panel.add(new JLabel(tr("<html><h3>Your preferences have been changed by removing <b>osm-server.version</b> and/or <b>osm-server.additional-versions</b> which were still referring to 0.4.</h3></html>")), GBC.eol()); 70 72 } 73 */ 71 74 72 75 addLine("wiki", tr("Read the [Wiki page on API 0.5]")); 76 addLine("extrudevideo", tr("Short (sound-less) [video] demonstrating the new \"extrude\" feature")); 73 77 74 78 addLine("audio", tr("This version also has built-in support for [Audio Mapping] with continuously recorded sound tracks.")); … … 120 124 else if (e.getActionCommand().equals("mailinglist")) 121 125 OpenBrowser.displayUrl("mailto:newbies-subscribe@openstreetmap.org?subject=subscribe"); 126 else if (e.getActionCommand().equals("extrudevideo")) 127 OpenBrowser.displayUrl("http://josm.openstreetmap.de/download/tutorials/josm-extrude-feature.mpeg"); 122 128 } 123 129 } -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r563 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 14 15 15 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.actions.AlignInRectangleAction; 16 18 import org.openstreetmap.josm.actions.JosmAction; 17 19 import org.openstreetmap.josm.actions.AboutAction; … … 93 95 public final JosmAction alignInCircle = new AlignInCircleAction(); 94 96 public final JosmAction alignInLine = new AlignInLineAction(); 97 public final JosmAction alignInRect = new AlignInRectangleAction(); 95 98 public final JosmAction mergeNodes = new MergeNodesAction(); 96 99 public final JosmAction joinNodeWay = new JoinNodeWayAction(); … … 207 210 current = toolsMenu.add(alignInLine); 208 211 current.setAccelerator(alignInLine.shortCut); 212 current = toolsMenu.add(alignInRect); 213 current.setAccelerator(alignInRect.shortCut); 209 214 toolsMenu.addSeparator(); 210 215 current = toolsMenu.add(mergeNodes); -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r582 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 16 17 import org.openstreetmap.josm.actions.mapmode.DeleteAction; 17 18 import org.openstreetmap.josm.actions.mapmode.DrawAction; 19 import org.openstreetmap.josm.actions.mapmode.ExtrudeAction; 18 20 import org.openstreetmap.josm.actions.mapmode.MapMode; 19 21 import org.openstreetmap.josm.actions.mapmode.SelectAction; … … 81 83 toolBarActions.add(new IconToggleButton(new DrawAction(this))); 82 84 toolBarActions.add(new IconToggleButton(new DeleteAction(this))); 83 85 toolBarActions.add(new IconToggleButton(new ExtrudeAction(this))); 86 84 87 for (Component c : toolBarActions.getComponents()) 85 88 toolGroup.add((AbstractButton)c); -
trunk/src/org/openstreetmap/josm/gui/MapScaler.java
r588 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 28 29 LatLon ll1 = mv.getLatLon(0,0); 29 30 LatLon ll2 = mv.getLatLon(100,0); 30 intdist = ll1.distance(ll2);31 String text = dist > 1000 ? (Math.round(dist/100)/10.0)+"km" : dist+"m";31 double dist = ll1.greatCircleDistance(ll2); 32 String text = dist > 1000 ? (Math.round(dist/100)/10.0)+"km" : Math.round(dist*10)/10+"m"; 32 33 Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g); 33 34 g.setColor(ColorHelper.html2color(Main.pref.get("color.scale", "#ffffff"))); -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r582 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 5 6 6 7 import java.awt.AWTEvent; 8 import java.awt.Color; 7 9 import java.awt.Cursor; 8 10 import java.awt.Dimension; … … 38 40 import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 39 41 import org.openstreetmap.josm.tools.GBC; 42 import org.openstreetmap.josm.tools.ImageProvider; 40 43 41 44 /** … … 47 50 * 48 51 * The background thread does not alter any data of the map (read only thread). 49 * Also it is rather fail safe. In case of some error in the data, it just do 52 * Also it is rather fail safe. In case of some error in the data, it just does 50 53 * nothing instead of whining and complaining. 51 54 * … … 55 58 56 59 /** 57 * The MapView this status belongs. 60 * The MapView this status belongs to. 58 61 */ 59 62 final MapView mv; 60 /**61 * The position of the mouse cursor.62 */63 DecimalFormat latlon = new DecimalFormat("###0.0000000");64 JTextField positionText = new JTextField(25);65 63 66 /** 67 * The field holding the name of the object under the mouse. 68 */ 69 JTextField nameText = new JTextField(30); 70 71 /** 72 * The field holding information about what the user can do. 73 */ 74 JTextField helpText = new JTextField(); 75 64 /** 65 * A small user interface component that consists of an image label and 66 * a fixed text content to the right of the image. 67 */ 68 class ImageLabel extends JPanel { 69 private JLabel tf; 70 private JLabel lbl; 71 private int chars; 72 public ImageLabel(String img, String tooltip, int chars) { 73 super(); 74 setLayout(new GridBagLayout()); 75 setBackground(Color.decode("#b8cfe5")); 76 add(lbl = new JLabel(ImageProvider.get("statusline/"+img+".png")), GBC.std().anchor(GBC.WEST).insets(0,1,1,0)); 77 add(tf = new JLabel(), GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2,1,1,0)); 78 setToolTipText(tooltip); 79 this.chars = chars; 80 } 81 public void setText(String t) { 82 tf.setText(t); 83 } 84 @Override public Dimension getPreferredSize() { 85 return new Dimension(25 + chars*tf.getFontMetrics(tf.getFont()).charWidth('0'), super.getPreferredSize().height); 86 } 87 @Override public Dimension getMinimumSize() { 88 return new Dimension(25 + chars*tf.getFontMetrics(tf.getFont()).charWidth('0'), super.getMinimumSize().height); 89 } 90 } 91 92 DecimalFormat latlon = new DecimalFormat("###0.0000"); 93 ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 8); 94 ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20); 95 JTextField helpText = new JTextField(); 96 ImageLabel latText = new ImageLabel("lat", tr("The geograpgic latitude at the mouse pointer."), 7); 97 ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6); 98 ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6); 99 ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 8); 100 76 101 /** 77 102 * The collector class that waits for notification and then update … … 119 144 continue; 120 145 146 OsmPrimitive osmNearest = null; 147 // Set the text label in the bottom status bar 148 osmNearest = mv.getNearest(ms.mousePos); 149 if (osmNearest != null) { 150 NameVisitor visitor = new NameVisitor(); 151 osmNearest.visit(visitor); 152 nameText.setText(visitor.name); 153 } else 154 nameText.setText("(no object)"); 155 121 156 // This try/catch is a hack to stop the flooding bug reports about this. 122 157 // The exception needed to handle with in the first place, means that this … … 132 167 if (osms != null && osms.equals(osmStatus) && ms.modifiers == oldModifiers) 133 168 continue; 134 /*135 osmStatus = osms;136 oldModifiers = ms.modifiers;137 138 OsmPrimitive osmNearest = null;139 // Set the text label in the bottom status bar140 osmNearest = mv.getNearest(ms.mousePos);141 if (osmNearest != null) {142 NameVisitor visitor = new NameVisitor();143 osmNearest.visit(visitor);144 nameText.setText(visitor.name);145 } else146 nameText.setText("");147 */148 149 169 150 170 if (popup != null) { … … 247 267 if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0) { 248 268 LatLon p = mv.getLatLon(e.getX(),e.getY()); 249 positionText.setText(latlon.format(p.lat())+" "+latlon.format(p.lon())); 269 latText.setText(latlon.format(p.lat())); 270 lonText.setText(latlon.format(p.lon())); 250 271 } 251 272 } 252 273 }); 253 274 254 positionText.setEditable(false);255 nameText.setEditable(false);256 helpText.setEditable(false);257 275 setLayout(new GridBagLayout()); 258 276 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 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)); 277 278 add(latText, GBC.std()); 279 add(lonText, GBC.std().insets(3,0,0,0)); 280 add(headingText, GBC.std().insets(3,0,0,0)); 281 add(angleText, GBC.std().insets(3,0,0,0)); 282 add(distText, GBC.std().insets(3,0,0,0)); 283 284 helpText.setEditable(false); 285 add(nameText, GBC.std().insets(3,0,0,0)); 286 add(helpText, GBC.eol().insets(3,0,0,0).fill(GBC.HORIZONTAL)); 265 287 266 288 // The background thread … … 317 339 public void setHelpText(String t) { 318 340 helpText.setText(t); 319 } 341 helpText.setToolTipText(t); 342 } 343 public void setAngle(double a) { 344 angleText.setText(a < 0 ? "--" : Math.round(a*10)/10.0 + "°"); 345 } 346 public void setHeading(double h) { 347 headingText.setText(h < 0 ? "--" : Math.round(h*10)/10.0 + "°"); 348 } 349 public void setDist(double dist) { 350 String text = dist > 1000 ? (Math.round(dist/100)/10.0)+"km" : Math.round(dist*10)/10 +"m"; 351 distText.setText(dist < 0 ? "--" : text); 352 } 353 320 354 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r582 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 23 24 import org.openstreetmap.josm.actions.MoveAction; 24 25 import org.openstreetmap.josm.data.Bounds; 26 import org.openstreetmap.josm.data.Preferences; 25 27 import org.openstreetmap.josm.data.SelectionChangedListener; 26 28 import org.openstreetmap.josm.data.coor.EastNorth; … … 29 31 import org.openstreetmap.josm.data.osm.OsmPrimitive; 30 32 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 31 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;32 33 import org.openstreetmap.josm.data.projection.Projection; 33 34 import org.openstreetmap.josm.gui.layer.Layer; 35 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 34 36 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 35 37 import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener; … … 79 81 private Layer activeLayer; 80 82 83 private LinkedList<MapViewPaintable> temporaryLayers = new LinkedList<MapViewPaintable>(); 84 81 85 /** 82 86 * The listener of the active layer changes. … … 195 199 if (center == null) 196 200 return; // no data loaded yet. 197 g.setColor( SimplePaintVisitor.getPreferencesColor("background", Color.BLACK));201 g.setColor(Preferences.getPreferencesColor("background", Color.BLACK)); 198 202 g.fillRect(0, 0, getWidth(), getHeight()); 199 203 … … 203 207 l.paint(g, this); 204 208 } 209 205 210 if (getActiveLayer() != null && getActiveLayer().visible) 206 211 getActiveLayer().paint(g, this); 207 212 213 for (MapViewPaintable mvp : temporaryLayers) { 214 mvp.paint(g, this); 215 } 216 208 217 // draw world borders 209 218 g.setColor(Color.WHITE); … … 330 339 firePropertyChange("scale", oldScale, scale); 331 340 } 341 342 public boolean addTemporaryLayer(MapViewPaintable mvp) { 343 if (temporaryLayers.contains(mvp)) return false; 344 return temporaryLayers.add(mvp); 345 } 346 347 public boolean removeTemporaryLayer(MapViewPaintable mvp) { 348 return temporaryLayers.remove(mvp); 349 } 332 350 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r582 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui; 3 4 … … 98 99 */ 99 100 public LatLon getLatLon(int x, int y) { 100 EastNorth eastNorth = new EastNorth( 101 center.east() + (x - getWidth()/2.0)*scale, 102 center.north() - (y - getHeight()/2.0)*scale); 103 return getProjection().eastNorth2latlon(eastNorth); 101 102 return getProjection().eastNorth2latlon(getEastNorth(x, y)); 104 103 } 105 104 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r343 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 // License: GPL. See LICENSE file for details. 2 2 package org.openstreetmap.josm.gui.dialogs; 3 3 … … 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.command.ConflictResolveCommand; 33 import org.openstreetmap.josm.data.Preferences; 33 34 import org.openstreetmap.josm.data.SelectionChangedListener; 34 35 import org.openstreetmap.josm.data.osm.DataSet; … … 38 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; 39 40 import org.openstreetmap.josm.data.osm.Way; 40 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;41 41 import org.openstreetmap.josm.data.osm.visitor.Visitor; 42 42 import org.openstreetmap.josm.gui.ConflictResolver; … … 144 144 */ 145 145 public void paintConflicts(final Graphics g, final NavigatableComponent nc) { 146 Color preferencesColor = SimplePaintVisitor.getPreferencesColor("conflict", Color.gray);146 Color preferencesColor = Preferences.getPreferencesColor("conflict", Color.gray); 147 147 if (preferencesColor.equals(Color.BLACK)) 148 148 return; -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r602 r608 1 //License: GPL. Copyright 2007 by Immanuel Scholz, Raphael Mack and others1 // License: GPL. See LICENSE file for details. 2 2 3 3 package org.openstreetmap.josm.gui.layer; … … 321 321 322 322 // draw line, if no maxLineLength is set or the line is shorter. 323 if (maxLineLength == -1 || trkPnt.latlon. distance(oldWp.latlon) <= maxLineLength){323 if (maxLineLength == -1 || trkPnt.latlon.greatCircleDistance(oldWp.latlon) <= maxLineLength){ 324 324 g.drawLine(old.x, old.y, screen.x, screen.y); 325 325 -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r304 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui.layer; 3 4 … … 29 30 * @author imi 30 31 */ 31 abstract public class Layer implements Destroyable { 32 abstract public class Layer implements Destroyable, MapViewPaintable { 32 33 33 34 /** -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r508 r608 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 1 // License: GPL. See LICENSE file for details. 2 2 3 package org.openstreetmap.josm.gui.layer; 3 4 … … 33 34 import org.openstreetmap.josm.actions.SaveAsAction; 34 35 import org.openstreetmap.josm.command.Command; 36 import org.openstreetmap.josm.data.Preferences; 35 37 import org.openstreetmap.josm.data.coor.EastNorth; 36 38 import org.openstreetmap.josm.data.osm.DataSet; … … 153 155 Point p1 = mv.getPoint(en1); 154 156 Point p2 = mv.getPoint(en2); 155 Color color = inactive ? SimplePaintVisitor.getPreferencesColor("inactive", Color.DARK_GRAY) :156 SimplePaintVisitor.getPreferencesColor("downloaded Area", Color.YELLOW);157 Color color = inactive ? Preferences.getPreferencesColor("inactive", Color.DARK_GRAY) : 158 Preferences.getPreferencesColor("downloaded Area", Color.YELLOW); 157 159 g.setColor(color); 158 160 g.drawRect(Math.min(p1.x,p2.x), Math.min(p1.y, p2.y), Math.abs(p2.x-p1.x), Math.abs(p2.y-p1.y)); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r582 r608 1 // License: GPL. See LICENSE file for details. 2 1 3 package org.openstreetmap.josm.gui.layer.markerlayer; 2 4 … … 226 228 for (Marker m : AudioMarker.recentlyPlayedMarker().parentLayer.data) { 227 229 if (m instanceof AudioMarker) { 228 double distanceSquared = m.eastNorth.distance(en); 230 double distanceSquared = m.eastNorth.distanceSq(en); 229 231 if (distanceSquared < closestAudioMarkerDistanceSquared) { 230 232 ca = (AudioMarker) m;
Note:
See TracChangeset
for help on using the changeset viewer.