Changeset 529 in josm
- Timestamp:
- 2008-01-30T18:02:38+01:00 (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r486 r529 45 45 46 46 <target name="compile" depends="init"> 47 <javac srcdir="src" classpathref="classpath" destdir="build" target="1.5" debug="on" /> 47 <javac srcdir="src" classpathref="classpath" destdir="build" target="1.5" debug="on"> 48 <compilerarg value="-Xlint:deprecation"/> 49 </javac> 48 50 </target> 49 51 -
trunk/src/org/openstreetmap/josm/Main.java
r518 r529 122 122 public final MainMenu menu; 123 123 124 /** 125 * Print a debug message if debugging is on. 126 */ 127 static public int debug_level = 1; 128 static public final void debug(String msg) { 129 if (debug_level <= 0) 130 return; 131 System.out.println(msg); 132 } 124 133 125 134 /** -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r469 r529 38 38 import org.openstreetmap.josm.data.osm.Way; 39 39 import org.openstreetmap.josm.data.osm.Node; 40 import org.openstreetmap.josm.data.osm.TigerUtils; 40 41 import org.openstreetmap.josm.tools.Pair; 41 42 import org.openstreetmap.josm.tools.GBC; … … 158 159 JPanel p = new JPanel(new GridBagLayout()); 159 160 for (Entry<String, Set<String>> e : props.entrySet()) { 160 if (e.getValue().size() > 1) { 161 if (TigerUtils.isTigerTag(e.getKey())) { 162 String combined = TigerUtils.combineTags(e.getKey(), e.getValue()); 163 newWay.put(e.getKey(), combined); 164 } else if (e.getValue().size() > 1) { 161 165 JComboBox c = new JComboBox(e.getValue().toArray()); 162 166 c.setEditable(true); … … 219 223 220 224 HashSet<Pair<Node,Node>> chunkSet = new HashSet<Pair<Node,Node>>(); 221 for (Way w : ways) { 222 if (w.nodes.size() == 0) continue; 223 Node lastN = null; 224 for (Node n : w.nodes) { 225 if (lastN == null) { 226 lastN = n; 227 continue; 228 } 229 230 Pair<Node,Node> np = new Pair<Node,Node>(lastN, n); 231 if (ignoreDirection) { 232 Pair.sort(np); 233 } 234 chunkSet.add(np); 235 236 lastN = n; 237 } 238 } 225 for (Way w : ways) 226 chunkSet.addAll(w.getNodePairs(ignoreDirection)); 227 239 228 LinkedList<Pair<Node,Node>> chunks = new LinkedList<Pair<Node,Node>>(chunkSet); 240 229 -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r469 r529 38 38 import org.openstreetmap.josm.data.osm.Way; 39 39 import org.openstreetmap.josm.data.osm.Node; 40 import org.openstreetmap.josm.data.osm.TigerUtils; 40 41 import org.openstreetmap.josm.tools.Pair; 41 42 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; … … 170 171 JPanel p = new JPanel(new GridBagLayout()); 171 172 for (Entry<String, Set<String>> e : props.entrySet()) { 172 if (e.getValue().size() > 1) { 173 if (TigerUtils.isTigerTag(e.getKey())) { 174 String combined = TigerUtils.combineTags(e.getKey(), e.getValue()); 175 newNode.put(e.getKey(), combined); 176 } else if (e.getValue().size() > 1) { 173 177 JComboBox c = new JComboBox(e.getValue().toArray()); 174 178 c.setEditable(true); -
trunk/src/org/openstreetmap/josm/actions/OpenAction.java
r482 r529 10 10 import java.io.FileInputStream; 11 11 import java.io.FileNotFoundException; 12 import java.io.FileReader;13 12 import java.io.IOException; 14 import java.util.Collection;15 import java.util.LinkedList;16 13 import java.util.zip.GZIPInputStream; 17 14 … … 23 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 24 21 import org.openstreetmap.josm.gui.layer.GpxLayer; 25 import org.openstreetmap.josm.gui.layer.markerlayer.Marker;26 22 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 27 23 import org.openstreetmap.josm.io.OsmReader; -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r485 r529 217 217 return; 218 218 } 219 Main.debug("wayChunks.size(): " + wayChunks.size()); 220 Main.debug("way id: " + selectedWay.id); 219 221 220 222 // build a list of commands, and also a new selection list … … 240 242 wayToAdd.nodes.addAll(chunkIt.next()); 241 243 commandList.add(new AddCommand(wayToAdd)); 244 Main.debug("wayToAdd: " + wayToAdd); 242 245 newSelection.add(wayToAdd); 243 246 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r444 r529 5 5 6 6 import java.io.IOException; 7 import java.util.Collection;8 7 9 8 import javax.swing.JCheckBox; -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r501 r529 8 8 import java.awt.event.MouseEvent; 9 9 import java.util.ArrayList; 10 import java.util.Arrays;11 10 import java.util.Collection; 12 11 import java.util.Collections; … … 15 14 import java.util.LinkedList; 16 15 import java.util.List; 17 import java.util.Map.Entry;18 16 19 17 import javax.swing.JOptionPane; 20 18 21 19 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.command.AddCommand; 23 import org.openstreetmap.josm.command.ChangeCommand; 24 import org.openstreetmap.josm.command.Command; 25 import org.openstreetmap.josm.command.DeleteCommand; 26 import org.openstreetmap.josm.command.SequenceCommand; 20 import org.openstreetmap.josm.command.*; 27 21 import org.openstreetmap.josm.data.osm.Node; 28 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 32 26 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 33 27 import org.openstreetmap.josm.gui.MapFrame; 34 import org.openstreetmap.josm.tools. ImageProvider;28 import org.openstreetmap.josm.tools.*; 35 29 36 30 /** -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r298 r529 59 59 max = new LatLon(Math.max(ll.lat(), max.lat()), Math.max(ll.lon(), max.lon())); 60 60 } 61 /** 62 * Is the given point within this bounds? 63 */ 64 public boolean contains(LatLon ll) { 65 if (ll.lat() < min.lat() || ll.lon() < min.lon()) 66 return false; 67 if (ll.lat() > max.lat() || ll.lon() > max.lon()) 68 return false; 69 return true; 70 } 61 71 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r498 r529 4 4 import java.text.ParseException; 5 5 import java.text.SimpleDateFormat; 6 import java.util.ArrayList;7 6 import java.util.Arrays; 8 7 import java.util.Collection; -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r357 r529 7 7 8 8 import org.openstreetmap.josm.data.osm.visitor.Visitor; 9 import org.openstreetmap.josm.tools.Pair; 9 10 10 11 /** … … 19 20 */ 20 21 public final List<Node> nodes = new ArrayList<Node>(); 22 23 public void visitNodes(Visitor v) { 24 for (Node n : this.nodes) 25 v.visit(n); 26 } 27 28 public ArrayList<Pair<Node,Node>> getNodePairs(boolean sort) { 29 ArrayList<Pair<Node,Node>> chunkSet = new ArrayList<Pair<Node,Node>>(); 30 Node lastN = null; 31 for (Node n : this.nodes) { 32 if (lastN == null) { 33 lastN = n; 34 continue; 35 } 36 Pair<Node,Node> np = new Pair<Node,Node>(lastN, n); 37 if (sort) { 38 Pair.sort(np); 39 } 40 chunkSet.add(np); 41 lastN = n; 42 } 43 return chunkSet; 44 } 45 21 46 22 47 @Override public void visit(Visitor visitor) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java
r343 r529 34 34 */ 35 35 public void visit(Way w) { 36 for (Node n : w.nodes) 37 visit(n); 36 w.visitNodes(this); 38 37 } 39 38 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r343 r529 23 23 24 24 public void visit(Way w) { 25 for (Node n : w.nodes) 26 visit(n); 25 w.visitNodes(this); 27 26 } 28 27 -
trunk/src/org/openstreetmap/josm/gui/ConflictResolver.java
r343 r529 23 23 import javax.swing.JButton; 24 24 import javax.swing.JLabel; 25 import javax.swing.JOptionPane;26 25 import javax.swing.JPanel; 27 26 import javax.swing.JScrollPane; … … 35 34 import javax.swing.table.TableModel; 36 35 37 import org.openstreetmap.josm.Main;38 36 import org.openstreetmap.josm.data.conflict.ConflictItem; 39 37 import org.openstreetmap.josm.data.conflict.DeleteConflict; -
trunk/src/org/openstreetmap/josm/gui/MainApplet.java
r431 r529 128 128 applet.setStub(new AppletStub() { 129 129 public void appletResize(int w, int h) { 130 frame. resize(w, h);130 frame.setSize(w, h); 131 131 } 132 132 -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r497 r529 6 6 import java.awt.event.ActionEvent; 7 7 import java.awt.event.ActionListener; 8 import java.awt.event.InputEvent; 9 import java.awt.event.KeyEvent; 10 11 import javax.swing.Action; 8 12 9 import javax.swing.JCheckBoxMenuItem; 13 10 import javax.swing.JMenu; … … 46 43 import org.openstreetmap.josm.actions.search.SearchAction; 47 44 import org.openstreetmap.josm.data.DataSetChecker; 48 import org.openstreetmap.josm.data.Preferences;49 45 50 46 /** -
trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r446 r529 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.awt.CheckboxGroup;8 7 import java.awt.Color; 9 8 import java.awt.Component; … … 14 13 import java.awt.event.ActionListener; 15 14 import java.io.BufferedReader; 16 import java.io.ByteArrayOutputStream;17 15 import java.io.File; 18 import java.io.FileInputStream;19 16 import java.io.InputStreamReader; 20 import java.io.OutputStream;21 import java.net.HttpURLConnection;22 17 import java.net.URL; 23 18 import java.net.URLConnection; 24 19 import java.net.UnknownHostException; 25 20 import java.util.Collection; 26 import java.util.LinkedList;27 21 28 22 import javax.swing.AbstractAction; … … 32 26 import javax.swing.JCheckBox; 33 27 import javax.swing.JColorChooser; 34 import javax.swing.JFileChooser;35 28 import javax.swing.JLabel; 36 29 import javax.swing.JMenuItem; … … 40 33 import javax.swing.JSeparator; 41 34 import javax.swing.JTextField; 42 import javax.swing.filechooser.FileFilter;43 35 44 36 import org.openstreetmap.josm.Main; … … 56 48 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 57 49 import org.openstreetmap.josm.io.MultiPartFormOutputStream; 58 import org.openstreetmap.josm.io.OsmWriter;59 50 import org.openstreetmap.josm.tools.ColorHelper; 60 51 import org.openstreetmap.josm.tools.DontShowAgainInfo; -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r486 r529 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 12 import org.openstreetmap.josm.gui.MapFrame; 13 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;14 13 import org.openstreetmap.josm.gui.layer.Layer; 15 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r343 r529 13 13 import java.net.URL; 14 14 import java.net.UnknownHostException; 15 import java.net.SocketTimeoutException; 15 16 import java.util.Collection; 16 17 import java.util.LinkedList; … … 57 58 * does not want to send the data. 58 59 */ 60 private static final int MSECS_PER_SECOND = 1000; 61 private static final int SECONDS_PER_MINUTE = 60; 62 private static final int MSECS_PER_MINUTE = MSECS_PER_SECOND * SECONDS_PER_MINUTE; 63 64 long uploadStartTime; 65 public String timeLeft(int progress, int list_size) { 66 long now = System.currentTimeMillis(); 67 long elapsed = now - uploadStartTime; 68 if (elapsed == 0) 69 elapsed = 1; 70 float uploads_per_ms = (float)progress / elapsed; 71 float uploads_left = list_size - progress; 72 int ms_left = (int)(uploads_left / uploads_per_ms); 73 int minutes_left = ms_left / MSECS_PER_MINUTE; 74 int seconds_left = (ms_left / MSECS_PER_SECOND) % SECONDS_PER_MINUTE ; 75 String time_left_str = Integer.toString(minutes_left) + ":"; 76 if (seconds_left < 10) 77 time_left_str += "0"; 78 time_left_str += Integer.toString(seconds_left); 79 return time_left_str; 80 } 59 81 public void uploadOsm(Collection<OsmPrimitive> list) throws SAXException { 60 82 processed = new LinkedList<OsmPrimitive>(); … … 66 88 NameVisitor v = new NameVisitor(); 67 89 try { 90 uploadStartTime = System.currentTimeMillis(); 68 91 for (OsmPrimitive osm : list) { 69 92 if (cancel) 70 93 return; 71 94 osm.visit(v); 72 Main.pleaseWaitDlg.currentAction.setText(tr("Upload {0} {1} ({2})...", tr(v.className), v.name, osm.id)); 95 int progress = Main.pleaseWaitDlg.progress.getValue(); 96 String time_left_str = timeLeft(progress, list.size()); 97 Main.pleaseWaitDlg.currentAction.setText(tr("Upload {0} {1} (id: {2}) {3}% {4}/{5} ({6} left)...", 98 tr(v.className), v.name, osm.id, 100.0*progress/list.size(), progress, list.size(), time_left_str)); 73 99 osm.visit(this); 74 100 Main.pleaseWaitDlg.progress.setValue(Main.pleaseWaitDlg.progress.getValue()+1); 101 Main.pleaseWaitDlg.progress.setValue(progress+1); 75 102 } 76 103 } catch (RuntimeException e) { … … 150 177 * <code>false</code>, if only the id is encoded. 151 178 */ 152 private void sendRequest (String requestMethod, String urlSuffix,153 OsmPrimitive osm, boolean addBody ) {179 private void sendRequestRetry(String requestMethod, String urlSuffix, 180 OsmPrimitive osm, boolean addBody, int retries) { 154 181 try { 182 if (cancel) 183 return; // assume cancel 155 184 String version = Main.pref.get("osm-server.version", "0.5"); 156 185 URL url = new URL( … … 159 188 "/" + urlSuffix + 160 189 "/" + (osm.id==0 ? "create" : osm.id)); 161 System.out.print ln("upload to: "+url);190 System.out.print("upload to: "+url+ "..." ); 162 191 activeConnection = (HttpURLConnection)url.openConnection(); 163 192 activeConnection.setConnectTimeout(15000); … … 166 195 activeConnection.setDoOutput(true); 167 196 activeConnection.connect(); 168 197 System.out.println("connected"); 169 198 if (addBody) { 170 199 OutputStream out = activeConnection.getOutputStream(); … … 181 210 if (retCode == 410 && requestMethod.equals("DELETE")) 182 211 return; // everything fine.. was already deleted. 183 if (retCode != 200) { 184 // Look for a detailed error message from the server 185 if (activeConnection.getHeaderField("Error") != null) 186 retMsg += "\n" + activeConnection.getHeaderField("Error"); 187 188 // Report our error 189 ByteArrayOutputStream o = new ByteArrayOutputStream(); 190 OsmWriter.output(o, new OsmWriter.Single(osm, true)); 191 System.out.println(new String(o.toByteArray(), "UTF-8").toString()); 192 throw new RuntimeException(retCode+" "+retMsg); 212 if (retCode != 200 && retCode != 412) { 213 if (retries >= 0) { 214 retries--; 215 System.out.print("backing off for 10 seconds..."); 216 Thread.sleep(10000); 217 System.out.println("retrying ("+retries+" left)"); 218 sendRequestRetry(requestMethod, urlSuffix, osm, addBody, retries); 219 } else { 220 // Look for a detailed error message from the server 221 if (activeConnection.getHeaderField("Error") != null) 222 retMsg += "\n" + activeConnection.getHeaderField("Error"); 223 224 // Report our error 225 ByteArrayOutputStream o = new ByteArrayOutputStream(); 226 OsmWriter.output(o, new OsmWriter.Single(osm, true)); 227 System.out.println(new String(o.toByteArray(), "UTF-8").toString()); 228 throw new RuntimeException(retCode+" "+retMsg); 229 } 193 230 } 194 231 } catch (UnknownHostException e) { 195 232 throw new RuntimeException(tr("Unknown host")+": "+e.getMessage(), e); 233 } catch(SocketTimeoutException e) { 234 System.out.println(" timed out, retries left: " + retries); 235 if (cancel) 236 return; // assume cancel 237 if (retries-- > 0) 238 sendRequestRetry(requestMethod, urlSuffix, osm, addBody, retries); 239 else 240 throw new RuntimeException(e.getMessage()+ " " + e.getClass().getCanonicalName(), e); 196 241 } catch (Exception e) { 197 242 if (cancel) … … 199 244 if (e instanceof RuntimeException) 200 245 throw (RuntimeException)e; 201 throw new RuntimeException(e.getMessage(), e); 202 } 246 throw new RuntimeException(e.getMessage()+ " " + e.getClass().getCanonicalName(), e); 247 } 248 } 249 private void sendRequest(String requestMethod, String urlSuffix, 250 OsmPrimitive osm, boolean addBody) { 251 sendRequestRetry(requestMethod, urlSuffix, osm, addBody, 10); 203 252 } 204 253 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r431 r529 39 39 * The icon cache 40 40 */ 41 private static Map< URL, Image> cache = new HashMap<URL, Image>();41 private static Map<String, Image> cache = new HashMap<String, Image>(); 42 42 43 43 /** … … 75 75 subdir += "/"; 76 76 String ext = name.indexOf('.') != -1 ? "" : ".png"; 77 String full_name = subdir+name+ext; 77 78 78 URL path = getImageUrl(subdir+name+ext); 79 if (path == null) 80 return null; 81 82 Image img = cache.get(path); 79 Image img = cache.get(full_name); 83 80 if (img == null) { 81 // getImageUrl() does a ton of "stat()" calls and gets expensive 82 // and redundant when you have a whole ton of objects. So, 83 // index the cache by the name of the icon we're looking for 84 // and don't bother to create a URL unless we're actually 85 // creating the image. 86 URL path = getImageUrl(full_name); 87 if (path == null) 88 return null; 84 89 img = Toolkit.getDefaultToolkit().createImage(path); 85 cache.put( path, img);90 cache.put(full_name, img); 86 91 } 92 87 93 return new ImageIcon(img); 88 94 }
Note:
See TracChangeset
for help on using the changeset viewer.