Changeset 39 in josm
- Timestamp:
- 2006-01-03T21:32:28+01:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/SaveAction.java
r32 r39 48 48 try { 49 49 FileWriter fileWriter = new FileWriter(file); 50 if (file.getName().endsWith(".gpx")) 50 String fn = file.getName(); 51 if (fn.endsWith(".gpx")) 51 52 new GpxWriter(fileWriter).output(); 52 else 53 else if (fn.endsWith(".xml") || fn.endsWith(".osm")) 53 54 new OsmWriter(fileWriter, Main.main.ds).output(); 55 else if (fn.endsWith(".txt") || fn.endsWith(".csv")) { 56 JOptionPane.showMessageDialog(Main.main, "CSV output not supported yet."); 57 return; 58 } else { 59 JOptionPane.showMessageDialog(Main.main, "Unknown file extension."); 60 return; 61 } 62 54 63 fileWriter.close(); 55 64 } catch (IOException e) { -
src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java
r30 r39 79 79 return; 80 80 81 OsmPrimitive clicked = mv.getNearest(e.getPoint(), false);81 OsmPrimitive clicked = mv.getNearest(e.getPoint(), true); 82 82 if (clicked == null || !(clicked instanceof Node)) 83 83 return; -
src/org/openstreetmap/josm/data/projection/Mercator.java
r36 r39 9 9 * from wikipedia. 10 10 * 11 * The center of the mercator projection is always the 0 °11 * The center of the mercator projection is always the 0 grad 12 12 * coordinate. 13 13 * -
src/org/openstreetmap/josm/gui/MapStatus.java
r36 r39 2 2 3 3 import java.awt.AWTEvent; 4 import java.awt.Cursor; 4 5 import java.awt.Font; 5 6 import java.awt.GridBagLayout; … … 8 9 import java.awt.event.AWTEventListener; 9 10 import java.awt.event.InputEvent; 11 import java.awt.event.MouseAdapter; 10 12 import java.awt.event.MouseEvent; 11 13 import java.awt.event.MouseMotionListener; … … 23 25 import javax.swing.PopupFactory; 24 26 27 import org.openstreetmap.josm.Main; 25 28 import org.openstreetmap.josm.data.GeoPoint; 26 29 import org.openstreetmap.josm.data.osm.Key; … … 120 123 121 124 JPanel c = new JPanel(new GridBagLayout()); 122 for (OsmPrimitive osm : osms) { 125 for (final OsmPrimitive osm : osms) { 123 126 SelectionComponentVisitor visitor = new SelectionComponentVisitor(); 124 127 osm.visit(visitor); 125 StringBuilder text = new StringBuilder( "<html>");128 final StringBuilder text = new StringBuilder(); 126 129 if (osm.id == 0 || osm.modified || osm.modifiedProperties) 127 130 visitor.name = "<i><b>"+visitor.name+"*</b></i>"; … … 132 135 for (Entry<Key, String> e : osm.keys.entrySet()) 133 136 text.append("<br>"+e.getKey().name+"="+e.getValue()); 134 JLabel l = new JLabel(text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL); 137 final JLabel l = new JLabel("<html>"+text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL); 135 138 l.setFont(l.getFont().deriveFont(Font.PLAIN)); 136 139 l.setVerticalTextPosition(JLabel.TOP); 140 l.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 141 l.addMouseListener(new MouseAdapter(){ 142 @Override 143 public void mouseEntered(MouseEvent e) { 144 l.setText("<html><u color='blue'>"+text.toString()+"</u></html>"); 145 } 146 @Override 147 public void mouseExited(MouseEvent e) { 148 l.setText("<html>"+text.toString()+"</html>"); 149 } 150 @Override 151 public void mouseClicked(MouseEvent e) { 152 Main.main.ds.clearSelection(); 153 osm.setSelected(true); 154 mv.repaint(); 155 } 156 }); 137 157 c.add(l, GBC.eol()); 138 158 } -
src/org/openstreetmap/josm/gui/MapView.java
r36 r39 234 234 * If no area is found, return <code>null</code>. 235 235 * 236 * @param p The point on screen. 237 * @param wholeTrackWhetherthe whole track or onlythe line segment238 * should be returned. 236 * @param p The point on screen. 237 * @param lsInsteadTrack Whether the line segment (true) or only the whole 238 * track should be returned. 239 239 * @return The primitive, that is nearest to the point p. 240 240 */ 241 public OsmPrimitive getNearest(Point p, boolean wholeTrack) {241 public OsmPrimitive getNearest(Point p, boolean lsInsteadTrack) { 242 242 double minDistanceSq = Double.MAX_VALUE; 243 243 OsmPrimitive minPrimitive = null; … … 245 245 // nodes 246 246 for (Node n : Main.main.ds.nodes) { 247 if (n.isDeleted()) 248 continue; 247 249 Point sp = getScreenPoint(n.coor); 248 250 double dist = p.distanceSq(sp); … … 257 259 // for whole tracks, try the tracks first 258 260 minDistanceSq = Double.MAX_VALUE; 259 if ( wholeTrack) {261 if (!lsInsteadTrack) { 260 262 for (Track t : Main.main.ds.tracks) { 263 if (t.isDeleted()) 264 continue; 261 265 for (LineSegment ls : t.segments) { 266 if (ls.isDeleted()) 267 continue; 262 268 Point A = getScreenPoint(ls.start.coor); 263 269 Point B = getScreenPoint(ls.end.coor); … … 279 285 // line segments 280 286 for (LineSegment ls : Main.main.ds.lineSegments) { 287 if (ls.isDeleted()) 288 continue; 281 289 Point A = getScreenPoint(ls.start.coor); 282 290 Point B = getScreenPoint(ls.end.coor); … … 313 321 */ 314 322 public Collection<OsmPrimitive> getAllNearest(Point p) { 315 OsmPrimitive osm = getNearest(p, false);323 OsmPrimitive osm = getNearest(p, true); 316 324 if (osm == null) 317 325 return null; … … 321 329 Node node = (Node)osm; 322 330 for (Node n : Main.main.ds.nodes) 323 if (n.coor.equalsLatLon(node.coor)) 331 if (!n.isDeleted() && n.coor.equalsLatLon(node.coor)) 324 332 c.add(n); 325 333 for (LineSegment ls : Main.main.ds.lineSegments) 326 334 // line segments never match nodes, so they are skipped by contains 327 if (c.contains(ls.start) || c.contains(ls.end)) 335 if (!ls.isDeleted() && (c.contains(ls.start) || c.contains(ls.end))) 328 336 c.add(ls); 329 337 } … … 331 339 LineSegment line = (LineSegment)osm; 332 340 for (LineSegment ls : Main.main.ds.lineSegments) 333 if (ls.equalPlace(line)) 341 if (!ls.isDeleted() && ls.equalPlace(line)) 334 342 c.add(ls); 335 343 } 336 344 if (osm instanceof Node || osm instanceof LineSegment) { 337 345 for (Track t : Main.main.ds.tracks) { 346 if (t.isDeleted()) 347 continue; 338 348 for (LineSegment ls : t.segments) { 339 if (c.contains(ls)) { 349 if (!ls.isDeleted() && c.contains(ls)) { 340 350 c.add(t); 341 351 break; -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r33 r39 6 6 import java.awt.event.ActionListener; 7 7 import java.awt.event.KeyEvent; 8 import java.awt.event.MouseAdapter; 9 import java.awt.event.MouseEvent; 8 10 import java.util.Collection; 9 11 … … 48 50 displaylist.setCellRenderer(new OsmPrimitivRenderer()); 49 51 displaylist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 52 displaylist.addMouseListener(new MouseAdapter(){ 53 @Override 54 public void mouseClicked(MouseEvent e) { 55 if (e.getClickCount() < 2) 56 return; 57 updateMap(); 58 } 59 }); 50 60 51 61 add(new JScrollPane(displaylist), BorderLayout.CENTER); -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r35 r39 81 81 osm.visit(visitor); 82 82 for (OsmPrimitive osm : data.nodes) 83 if (!osm.isDeleted()) 84 osm.visit(visitor); 85 for (OsmPrimitive osm : data.getSelected()) 83 86 if (!osm.isDeleted()) 84 87 osm.visit(visitor); -
src/org/openstreetmap/josm/io/OsmReader.java
r35 r39 118 118 } 119 119 } 120 121 // clear all negative ids (new to this file) 122 for (OsmPrimitive osm : data.allPrimitives()) 123 if (osm.id < 0) 124 osm.id = 0; 120 125 121 126 return data; … … 178 183 if (suid != null) 179 184 data.id = Long.parseLong(suid); 180 if (data.id < 0)181 data.id = 0;182 185 183 186 String propStr = e.getAttributeValue("tags");
Note:
See TracChangeset
for help on using the changeset viewer.