- Timestamp:
- 2005-10-09T20:06:06+02:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/OpenGpxAction.java
r17 r18 37 37 38 38 /** 39 * Create an open action. The name is " &Open GPX".39 * Create an open action. The name is "Open GPX". 40 40 */ 41 41 public OpenGpxAction() { -
src/org/openstreetmap/josm/data/GeoPoint.java
r17 r18 58 58 return (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y); 59 59 } 60 60 61 61 /** 62 62 * @return <code>true</code>, if the other GeoPoint has the same lat/lon values. 63 63 */ 64 64 public boolean equalsLatLon(GeoPoint other) { 65 return lat == other.lat && lon == other.lon; 65 return lat == other.lat && lon == other.lon && 66 !Double.isNaN(lat) && !Double.isNaN(lon); 66 67 } 67 68 } -
src/org/openstreetmap/josm/data/Preferences.java
r17 r18 45 45 private boolean drawRawGpsLines = false; 46 46 /** 47 * Force the drawing of lines between raw gps points if there are no 48 * lines in the imported document. 49 */ 50 private boolean forceRawGpsLines = false; 51 /** 47 52 * Whether nodes on the same place should be considered identical. 48 53 */ 49 54 public boolean mergeNodes = true; 50 51 55 56 /** 57 * Base URL to the osm data server 58 */ 59 public String osmDataServer = "http://www.openstreetmap.org/api/0.1"; 60 /** 61 * The username to the osm server 62 */ 63 public String osmDataUsername = ""; 64 /** 65 * The stored password or <code>null</code>, if the password should not be 66 * stored. 67 */ 68 public String osmDataPassword = null; 52 69 53 70 /** … … 105 122 } 106 123 124 Element osmServer = root.getChild("osm-server"); 125 if (osmServer != null) { 126 osmDataServer = osmServer.getChildText("url"); 127 osmDataUsername = osmServer.getChildText("username"); 128 osmDataPassword = osmServer.getChildText("password"); 129 } 107 130 mergeNodes = root.getChild("mergeNodes") != null; 108 131 drawRawGpsLines = root.getChild("drawRawGpsLines") != null; … … 129 152 if (drawRawGpsLines) 130 153 children.add(new Element("drawRawGpsLines")); 154 Element osmServer = new Element("osm-server"); 155 osmServer.getChildren().add(new Element("url").setText(osmDataServer)); 156 osmServer.getChildren().add(new Element("username").setText(osmDataUsername)); 157 osmServer.getChildren().add(new Element("password").setText(osmDataPassword)); 158 children.add(osmServer); 131 159 132 160 try { … … 200 228 return drawRawGpsLines; 201 229 } 230 public void setForceRawGpsLines(boolean forceRawGpsLines) { 231 boolean old = this.forceRawGpsLines; 232 this.forceRawGpsLines = forceRawGpsLines; 233 firePropertyChanged("forceRawGpsLines", old, forceRawGpsLines); 234 } 235 public boolean isForceRawGpsLines() { 236 return forceRawGpsLines; 237 } 202 238 } -
src/org/openstreetmap/josm/data/osm/DataSet.java
r17 r18 3 3 import java.util.Collection; 4 4 import java.util.Collections; 5 import java.util.HashMap; 5 6 import java.util.HashSet; 7 import java.util.Iterator; 6 8 import java.util.LinkedList; 9 import java.util.Map; 10 import java.util.Set; 7 11 8 12 import org.openstreetmap.josm.data.Bounds; … … 196 200 */ 197 201 public void mergeFrom(DataSet ds, boolean mergeEqualNodes) { 202 System.out.println(nodes.size()+" "+pendingLineSegments.size()+" "+tracks.size()); 198 203 if (mergeEqualNodes) { 199 LinkedList<Node> nodesToAdd = new LinkedList<Node>(); 200 for (Node n : ds.nodes) 201 for (Node mynode : nodes) { 202 if (mynode.coor.equalsLatLon(n.coor)) 203 mynode.mergeFrom(n); 204 else 205 nodesToAdd.add(n); 204 Map<Node, Node> mergeMap = new HashMap<Node, Node>(); 205 Set<Node> nodesToAdd = new HashSet<Node>(); 206 for (Node n : nodes) { 207 for (Iterator<Node> it = ds.nodes.iterator(); it.hasNext();) { 208 Node dsn = it.next(); 209 if (n.coor.equalsLatLon(dsn.coor)) { 210 mergeMap.put(dsn, n); 211 n.mergeFrom(dsn); 212 it.remove(); 213 } else { 214 nodesToAdd.add(dsn); 215 } 206 216 } 207 } else 217 } 218 nodes.addAll(nodesToAdd); 219 for (Track t : ds.tracks) { 220 for (LineSegment ls : t.segments()) { 221 Node n = mergeMap.get(ls.getStart()); 222 if (n != null) 223 ls.start = n; 224 n = mergeMap.get(ls.getEnd()); 225 if (n != null) 226 ls.end = n; 227 } 228 } 229 tracks.addAll(ds.tracks); 230 for (LineSegment ls : ds.pendingLineSegments) { 231 Node n = mergeMap.get(ls.getStart()); 232 if (n != null) 233 ls.start = n; 234 n = mergeMap.get(ls.getEnd()); 235 if (n != null) 236 ls.end = n; 237 } 238 pendingLineSegments.addAll(ds.pendingLineSegments); 239 } else { 208 240 nodes.addAll(ds.nodes); 209 tracks.addAll(ds.tracks); 210 pendingLineSegments.addAll(ds.pendingLineSegments); 241 tracks.addAll(ds.tracks); 242 pendingLineSegments.addAll(ds.pendingLineSegments); 243 } 244 System.out.println(nodes.size()+" "+pendingLineSegments.size()+" "+tracks.size()); 211 245 } 212 246 -
src/org/openstreetmap/josm/data/osm/LineSegment.java
r9 r18 18 18 * The starting node of the line segment 19 19 */ 20 privateNode start;20 Node start; 21 21 22 22 /** 23 23 * The ending node of the line segment 24 24 */ 25 privateNode end;25 Node end; 26 26 27 27 /** -
src/org/openstreetmap/josm/gui/Main.java
r17 r18 15 15 import org.openstreetmap.josm.actions.ExitAction; 16 16 import org.openstreetmap.josm.actions.OpenGpxAction; 17 import org.openstreetmap.josm.actions.OpenOsmServerAction; 17 18 import org.openstreetmap.josm.actions.PreferencesAction; 18 19 import org.openstreetmap.josm.actions.SaveGpxAction; … … 63 64 64 65 // creating actions 66 OpenOsmServerAction openServerAction = new OpenOsmServerAction(); 65 67 OpenGpxAction openGpxAction = new OpenGpxAction(); 66 68 SaveGpxAction saveGpxAction = new SaveGpxAction(); … … 80 82 mainMenu.add(fileMenu); 81 83 84 JMenu connectionMenu = new JMenu("Connection"); 85 connectionMenu.setMnemonic('C'); 86 connectionMenu.add(openServerAction); 87 mainMenu.add(connectionMenu); 88 82 89 JMenu editMenu = new JMenu("Edit"); 83 90 editMenu.setMnemonic('E'); … … 88 95 JToolBar toolBar = new JToolBar(); 89 96 toolBar.setFloatable(false); 97 toolBar.add(openServerAction); 90 98 toolBar.add(openGpxAction); 91 99 toolBar.add(saveGpxAction); -
src/org/openstreetmap/josm/gui/MapMover.java
r16 r18 55 55 GeoPoint p = new GeoPoint(); 56 56 p.x = mousePosMove.x + center.x - mouseCenter.x; 57 p.y = mousePosMove.y + center.y - mouseCenter.y; 57 p.y = mousePosMove.y + center.y - mouseCenter.y; 58 58 mv.zoomTo(p, mv.getScale()); 59 59 } else -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r17 r18 21 21 import javax.swing.JOptionPane; 22 22 import javax.swing.JPanel; 23 import javax.swing.JPasswordField; 23 24 import javax.swing.JTabbedPane; 25 import javax.swing.JTextField; 24 26 import javax.swing.ListCellRenderer; 25 27 import javax.swing.UIManager; … … 52 54 Main.pref.setProjection(projection); 53 55 Main.pref.mergeNodes = mergeNodes.isSelected(); 56 Main.pref.osmDataServer = osmDataServer.getText(); 57 Main.pref.osmDataUsername = osmDataUsername.getText(); 58 Main.pref.osmDataPassword = String.valueOf(osmDataPassword.getPassword()); 59 if (Main.pref.osmDataPassword == "") 60 Main.pref.osmDataPassword = null; 54 61 Main.pref.setDrawRawGpsLines(drawRawGpsLines.isSelected()); 62 Main.pref.setForceRawGpsLines(forceRawGpsLines.isSelected()); 55 63 try { 56 64 Main.pref.save(); … … 97 105 98 106 /** 107 * Editfield for the Base url to the REST API from OSM. 108 */ 109 private JTextField osmDataServer = new JTextField(20); 110 /** 111 * Editfield for the username to the OSM account. 112 */ 113 private JTextField osmDataUsername = new JTextField(20); 114 /** 115 * Passwordfield for the userpassword of the REST API. 116 */ 117 private JPasswordField osmDataPassword = new JPasswordField(20); 118 /** 99 119 * The checkbox stating whether nodes should be merged together. 100 120 */ 101 121 private JCheckBox drawRawGpsLines = new JCheckBox("Draw lines between raw gps points."); 122 /** 123 * The checkbox stating whether raw gps lines should be forced. 124 */ 125 private JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported."); 102 126 /** 103 127 * The checkbox stating whether nodes should be merged together. … … 155 179 }); 156 180 181 // drawRawGpsLines 182 drawRawGpsLines.addActionListener(new ActionListener(){ 183 public void actionPerformed(ActionEvent e) { 184 if (!drawRawGpsLines.isSelected()) 185 forceRawGpsLines.setSelected(false); 186 forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected()); 187 } 188 }); 189 190 157 191 // tooltips 192 osmDataServer.setToolTipText("The base URL to the OSM server (REST API)"); 193 osmDataUsername.setToolTipText("Login name (email) to the OSM account."); 194 osmDataPassword.setToolTipText("Login password to the OSM account. Leave blank to not store any password."); 158 195 drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your track."); 159 196 drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines()); 197 forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information."); 198 forceRawGpsLines.setSelected(Main.pref.isForceRawGpsLines()); 160 199 mergeNodes.setToolTipText("When importing GPX data, all nodes with exact the same lat/lon are merged."); 161 200 mergeNodes.setSelected(Main.pref.mergeNodes); 162 201 202 osmDataServer.setText(Main.pref.osmDataServer); 203 osmDataUsername.setText(Main.pref.osmDataUsername); 204 osmDataPassword.setText(Main.pref.osmDataPassword); 205 163 206 // Display tab 164 207 JPanel display = createPreferenceTab("display", "Display Settings", "Various settings that influence the visual representation of the whole program."); … … 167 210 display.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL)); 168 211 display.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0)); 212 display.add(forceRawGpsLines, GBC.eol().insets(40,0,0,0)); 169 213 display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 170 214 215 // Connection tab 216 JPanel con = createPreferenceTab("connection", "Connection Settings", "Connection Settings to the OSM server."); 217 con.add(new JLabel("Base Server URL"), GBC.std()); 218 con.add(osmDataServer, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 219 con.add(new JLabel("OSM username (email)"), GBC.std()); 220 con.add(osmDataUsername, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 221 con.add(new JLabel("OSM password"), GBC.std()); 222 con.add(osmDataPassword, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,0)); 223 JLabel warning = new JLabel("<html>" + 224 "WARNING: The password is stored in plain text in the preferences file.<br>" + 225 "The password is transfered in plain text to the server, encoded in the url.<br>" + 226 "<b>Do not use a valuable Password.</b></html>"); 227 warning.setFont(warning.getFont().deriveFont(Font.ITALIC)); 228 con.add(warning, GBC.eop().fill(GBC.HORIZONTAL)); 229 230 171 231 // Map tab 172 232 JPanel map = createPreferenceTab("map", "Map Settings", "Settings for the map projection and data interpretation."); … … 221 281 222 282 tabPane.addTab(null, ImageProvider.get("preferences", icon), p); 283 tabPane.setToolTipTextAt(tabPane.getTabCount()-1, desc); 223 284 return p; 224 285 } -
src/org/openstreetmap/josm/gui/dialogs/LayerList.java
r17 r18 89 89 icon = ImageProvider.overlay(icon, invisible, ImageProvider.OverlayPosition.SOUTHEAST); 90 90 label.setIcon(icon); 91 92 DataSet ds = layer.getDataSet(); 93 if (ds != null) { 94 label.setToolTipText(ds.nodes.size()+" nodes, "+ 95 ds.tracks().size()+" tracks"); 96 } 91 97 return label; 92 98 } -
src/org/openstreetmap/josm/gui/engine/RawGpsEngine.java
r17 r18 2 2 3 3 import java.awt.Color; 4 import java.awt.Graphics; 4 5 import java.awt.Point; 5 6 import java.beans.PropertyChangeEvent; … … 10 11 import org.openstreetmap.josm.data.osm.Track; 11 12 import org.openstreetmap.josm.gui.Main; 13 import org.openstreetmap.josm.gui.MapView; 12 14 13 15 /** … … 19 21 20 22 /** 23 * Draw a line to this node if forceRawGpsLines is set. 24 */ 25 private Node lastNode; 26 27 /** 21 28 * Create a raw gps engine. The engine will register itself as listener on 22 29 * the main preference settings to capture the drawRawGpsLines changes. … … 24 31 public RawGpsEngine() { 25 32 Main.pref.addPropertyChangeListener(this); 33 } 34 35 36 @Override 37 public void init(Graphics g, MapView mv) { 38 super.init(g, mv); 39 lastNode = null; 26 40 } 27 41 … … 34 48 g.setColor(n.isSelected() ? Color.WHITE : Color.GRAY); 35 49 g.drawRect(p.x, p.y, 0, 0); 50 if (Main.pref.isForceRawGpsLines()) { 51 if (lastNode != null) 52 drawLine(lastNode, n, false, Color.GRAY); 53 lastNode = n; 54 } 36 55 } 37 56 … … 46 65 return; 47 66 for (LineSegment ls : t.segments()) 48 drawLine Segment(ls, t.isSelected() ? Color.WHITE : Color.GRAY);67 drawLine(ls.getStart(), ls.getEnd(), ls.isSelected(), t.isSelected() ? Color.WHITE : Color.GRAY); 49 68 } 50 69 … … 54 73 @Override 55 74 public void drawPendingLineSegment(LineSegment ls) { 56 drawLine Segment(ls, Color.GRAY);75 drawLine(ls.getStart(), ls.getEnd(), ls.isSelected(), Color.GRAY); 57 76 } 58 77 … … 62 81 * @param color The color, the line segment should be drawn in. 63 82 */ 64 private void drawLine Segment(LineSegment ls, Color color) {65 g.setColor( ls.isSelected()? Color.WHITE : color);66 Point p1 = mv.getScreenPoint( ls.getStart().coor);67 Point p2 = mv.getScreenPoint( ls.getEnd().coor);83 private void drawLine(Node start, Node end, boolean isSelected, Color color) { 84 g.setColor(isSelected ? Color.WHITE : color); 85 Point p1 = mv.getScreenPoint(start.coor); 86 Point p2 = mv.getScreenPoint(end.coor); 68 87 g.drawLine(p1.x, p1.y, p2.x, p2.y); 69 88 } … … 74 93 */ 75 94 public void propertyChange(PropertyChangeEvent e) { 76 if (e.getPropertyName().equals("drawRawGpsLines") )95 if (e.getPropertyName().equals("drawRawGpsLines") || e.getPropertyName().equals("forceRawGpsLines")) 77 96 mv.repaint(); 78 97 }
Note:
See TracChangeset
for help on using the changeset viewer.