Changeset 319 in josm for src/org/openstreetmap/josm
- Timestamp:
- 2007-09-04T10:21:49+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 13 edited
-
actions/ReorderAction.java (modified) (8 diffs)
-
actions/SaveActionBase.java (modified) (6 diffs)
-
actions/search/SearchCompiler.java (modified) (1 diff)
-
data/osm/visitor/SimplePaintVisitor.java (modified) (1 diff)
-
gui/layer/GeoImageLayer.java (modified) (9 diffs)
-
gui/preferences/CsvPreference.java (modified) (2 diffs)
-
gui/preferences/FilePreferences.java (added)
-
gui/preferences/PreferenceDialog.java (modified) (1 diff)
-
io/IncompleteDownloader.java (modified) (4 diffs)
-
io/OsmIdReader.java (modified) (3 diffs)
-
io/OsmReader.java (modified) (4 diffs)
-
io/RawGpsReader.java (modified) (4 diffs)
-
plugins/PluginDownloader.java (modified) (2 diffs)
-
tools/XmlObjectParser.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/ReorderAction.java
r301 r319 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.actions; 3 3 … … 10 10 import java.util.Iterator; 11 11 import java.util.LinkedList; 12 import java.util.HashMap; 12 13 13 14 import javax.swing.JOptionPane; … … 27 28 public ReorderAction() { 28 29 super(tr("Reorder Segments"), "reorder", tr("Try to reorder segments of a way so that they are in a line. May try to flip segments around to match a line."), KeyEvent.VK_R, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK, true); 29 }30 30 } 31 31 32 /** 32 33 * This method first sorts all the segments in a way, then makes sure that all … … 38 39 if (osm instanceof Way) 39 40 ways.add((Way)osm); 40 41 41 42 if (ways.size() < 1) { 42 43 JOptionPane.showMessageDialog(Main.parent, tr("Please select at least one way.")); 43 44 return; 44 45 } 45 46 46 47 if (ways.size() > 1) { 47 48 int answer = JOptionPane.showConfirmDialog(Main.parent, 48 trn(null, "You selected more than one way. Reorder the segments of {0} ways?", ways.size(), ways.size()), 49 tr("Reorder segments"), JOptionPane.OK_CANCEL_OPTION); 49 trn(null, "You selected more than one way. Reorder the segments of {0} ways?", ways.size(), ways.size()), 50 tr("Reorder segments"), JOptionPane.OK_CANCEL_OPTION); 50 51 if (answer != JOptionPane.OK_OPTION) 51 52 return; … … 75 76 * the segments are facing the same direction as the first one. 76 77 * @param way The way to reorder 77 * @return The command needed to reorder the way78 */79 public static Command reorderWay(Way way) {80 final LinkedList<Segment> sel = new LinkedList<Segment>(sortSegments(new LinkedList<Segment>(way.segments), false));81 82 Collection<Command> c = new LinkedList<Command>();83 84 boolean direction = false;85 // work out the "average" direction of the way, we use this to direct the rest of the segments86 int dirCounter = 0;87 for(int i = 0; i < sel.size() - 1; i++)88 {89 Segment firstSegment = sel.get(i);90 Segment secondSegment = sel.get(i+1);91 if ( firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to ) // direction = true when 'from' is the first node in the Way92 dirCounter++;93 else94 dirCounter--;95 }96 if ( dirCounter <= 0 )97 direction = false;98 else99 direction = true;100 101 Node lastNode = null;102 103 // we need to calculate what the first node in the way is, we work from there104 Segment firstSegment = sel.getFirst();105 Segment secondSegment = sel.get(1);106 if (firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to)107 lastNode = firstSegment.from;108 else109 lastNode = firstSegment.to;110 111 // go through each segment and flip them if required112 for (Segment s : sel) {113 Segment snew = new Segment(s);114 boolean segDirection = s.from == lastNode;115 // segDirection = true when the 'from' node occurs before the 'to' node in the Way116 if (direction != segDirection)117 {118 // reverse the segment's direction119 Node n = snew.from;120 snew.from = snew.to;121 snew.to = n;122 c.add(new ChangeCommand(s, snew));123 }124 125 if (direction) // if its facing forwards,126 lastNode = snew.to; // our next node is the 'to' one127 else128 lastNode = snew.from; // otherwise its the 'from' one129 }130 131 LinkedList<Segment> segments = new LinkedList<Segment>();132 133 // Now we recreate the segment list, in the correct order of the direction134 for (Segment s : sel)135 if (!direction)136 segments.addFirst(s);137 else138 segments.addLast(s);139 140 // Check if the new segment list is actually different from the old one141 // before we go and add a change command for it142 for(int i = 0; i < segments.size(); i++)143 if (way.segments.get(i) != segments.get(i))144 {145 Way newWay = new Way(way);146 newWay.segments.clear();147 newWay.segments.addAll(segments);148 c.add(new ChangeCommand(way, newWay));149 break;150 }151 152 // Check we've got some change commands before we add a sequence command78 * @return The command needed to reorder the way 79 */ 80 public static Command reorderWay(Way way) { 81 final LinkedList<Segment> sel = new LinkedList<Segment>(sortSegments(new LinkedList<Segment>(way.segments), false)); 82 83 Collection<Command> c = new LinkedList<Command>(); 84 85 boolean direction = false; 86 // work out the "average" direction of the way, we use this to direct the rest of the segments 87 int dirCounter = 0; 88 for(int i = 0; i < sel.size() - 1; i++) 89 { 90 Segment firstSegment = sel.get(i); 91 Segment secondSegment = sel.get(i+1); 92 if ( firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to ) // direction = true when 'from' is the first node in the Way 93 dirCounter++; 94 else 95 dirCounter--; 96 } 97 if ( dirCounter <= 0 ) 98 direction = false; 99 else 100 direction = true; 101 102 Node lastNode = null; 103 104 // we need to calculate what the first node in the way is, we work from there 105 Segment firstSegment = sel.getFirst(); 106 Segment secondSegment = sel.get(1); 107 if (firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to) 108 lastNode = firstSegment.from; 109 else 110 lastNode = firstSegment.to; 111 112 // go through each segment and flip them if required 113 for (Segment s : sel) { 114 Segment snew = new Segment(s); 115 boolean segDirection = s.from == lastNode; 116 // segDirection = true when the 'from' node occurs before the 'to' node in the Way 117 if (direction != segDirection) 118 { 119 // reverse the segment's direction 120 Node n = snew.from; 121 snew.from = snew.to; 122 snew.to = n; 123 c.add(new ChangeCommand(s, snew)); 124 } 125 126 if (direction) // if its facing forwards, 127 lastNode = snew.to; // our next node is the 'to' one 128 else 129 lastNode = snew.from; // otherwise its the 'from' one 130 } 131 132 LinkedList<Segment> segments = new LinkedList<Segment>(); 133 134 // Now we recreate the segment list, in the correct order of the direction 135 for (Segment s : sel) 136 if (!direction) 137 segments.addFirst(s); 138 else 139 segments.addLast(s); 140 141 // Check if the new segment list is actually different from the old one 142 // before we go and add a change command for it 143 for(int i = 0; i < segments.size(); i++) 144 if (way.segments.get(i) != segments.get(i)) 145 { 146 Way newWay = new Way(way); 147 newWay.segments.clear(); 148 newWay.segments.addAll(segments); 149 c.add(new ChangeCommand(way, newWay)); 150 break; 151 } 152 153 // Check we've got some change commands before we add a sequence command 153 154 if (c.size() != 0) { 154 155 NameVisitor v = new NameVisitor(); … … 157 158 } 158 159 return null; 159 }160 } 160 161 161 162 /** … … 168 169 */ 169 170 public static LinkedList<Segment> sortSegments(LinkedList<Segment> segments, boolean strict) { 170 171 171 172 LinkedList<Segment> sortedSegments = new LinkedList<Segment>(); 172 173 173 174 while (!segments.isEmpty()) { 174 175 LinkedList<Segment> pivotList = new LinkedList<Segment>(); 175 pivotList.add(segments .getFirst());176 segments.remove First();176 pivotList.add(firstSegment(segments)); 177 segments.remove(pivotList.getLast()); 177 178 boolean found; 178 179 do { 179 180 found = false; 181 //try working forwards first 180 182 for (Iterator<Segment> it = segments.iterator(); it.hasNext();) { 181 183 Segment ls = it.next(); 182 184 if (ls.incomplete) 183 185 continue; // incomplete segments are never added to a new way 184 if (ls.from == pivotList.getLast().to || (!strict && (ls.to == pivotList.getLast().to || ls.from == pivotList.getLast().from || ls.to == pivotList.getLast().from))) {186 if (ls.from == pivotList.getLast().to) { 185 187 pivotList.addLast(ls); 186 188 it.remove(); 187 189 found = true; 188 } else if (ls.to == pivotList.getFirst().from || (!strict && (ls.from == pivotList.getFirst().from || ls.to == pivotList.getFirst().to || ls.from == pivotList.getFirst().to))) { 189 pivotList.addFirst(ls); 190 it.remove(); 191 found = true; 190 } 191 } 192 if(!found){ 193 for (Iterator<Segment> it = segments.iterator(); it.hasNext();) { 194 Segment ls = it.next(); 195 if (ls.incomplete) 196 continue; // incomplete segments are never added to a new way 197 if (ls.from == pivotList.getLast().to || (!strict && (ls.to == pivotList.getLast().to || ls.from == pivotList.getLast().from || ls.to == pivotList.getLast().from))) { 198 pivotList.addLast(ls); 199 it.remove(); 200 found = true; 201 } else if (ls.to == pivotList.getFirst().from || (!strict && (ls.from == pivotList.getFirst().from || ls.to == pivotList.getFirst().to || ls.from == pivotList.getFirst().to))) { 202 pivotList.addFirst(ls); 203 it.remove(); 204 found = true; 205 } 192 206 } 193 207 } … … 195 209 sortedSegments.addAll(pivotList); 196 210 } 197 return sortedSegments; 198 } 211 return sortedSegments; 212 } 213 214 /** 215 * This method searches for a good segment to start a reorder from. 216 * In most cases this will be a segment with a start node that occurs only 217 * once in the way. In cases with loops, this could be any odd number. If no nodes 218 * are referenced an odd number of times, then any segment is a good start point. 219 */ 220 public static Segment firstSegment(Collection<Segment> segments) { 221 HashMap<Node, Integer> refCount = new HashMap<Node, Integer>(segments.size()*2); 222 //loop through all segments and count up how many times each node is referenced 223 for (Segment seg : segments) { 224 if (!refCount.containsKey(seg.from)) 225 refCount.put(seg.from, 0); 226 refCount.put(seg.from,refCount.get(seg.from)+1); 227 228 if (!refCount.containsKey(seg.to)) 229 refCount.put(seg.to, 0); 230 refCount.put(seg.to,refCount.get(seg.to)+1); 231 } 232 233 //now look for start nodes that are referenced only once 234 for (Segment seg : segments) 235 if (refCount.get(seg.from) == 1) 236 return seg; 237 //now look for start nodes that are referenced only (2n+1) 238 for (Segment seg : segments) 239 if (refCount.get(seg.from) % 2 == 1) 240 return seg; 241 //now look for end nodes that are referenced only once 242 for (Segment seg : segments) 243 if (refCount.get(seg.to) == 1) 244 return seg; 245 //now look for end nodes that are referenced only (2n+1) 246 for (Segment seg : segments) 247 if (refCount.get(seg.to) % 2 == 1) 248 return seg; 249 250 return segments.iterator().next(); 251 } 199 252 } -
src/org/openstreetmap/josm/actions/SaveActionBase.java
r299 r319 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.actions; 3 3 … … 7 7 import java.io.File; 8 8 import java.io.FileOutputStream; 9 import java.io.FileInputStream; 10 import java.io.FileNotFoundException; 9 11 import java.io.IOException; 10 12 … … 37 39 return; 38 40 39 41 40 42 File file = getFile(layer); 41 43 if (file == null) … … 48 50 Main.parent.repaint(); 49 51 } 50 52 51 53 protected abstract File getFile(OsmDataLayer layer); 52 54 … … 57 59 */ 58 60 public boolean checkSaveConditions(OsmDataLayer layer) { 59 if (Main.map == null) {60 JOptionPane.showMessageDialog(Main.parent, tr("No document open so nothing to save."));61 return false;62 }63 if (isDataSetEmpty(layer) && JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(Main.parent,tr("The document contains no data. Save anyway?"), tr("Empty document"), JOptionPane.YES_NO_OPTION))64 return false;65 if (!Main.map.conflictDialog.conflicts.isEmpty()) {66 int answer = JOptionPane.showConfirmDialog(Main.parent,67 tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?"),tr("Conflicts"), JOptionPane.YES_NO_OPTION);68 if (answer != JOptionPane.YES_OPTION)69 return false;70 }71 return true;72 }61 if (Main.map == null) { 62 JOptionPane.showMessageDialog(Main.parent, tr("No document open so nothing to save.")); 63 return false; 64 } 65 if (isDataSetEmpty(layer) && JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(Main.parent,tr("The document contains no data. Save anyway?"), tr("Empty document"), JOptionPane.YES_NO_OPTION)) 66 return false; 67 if (!Main.map.conflictDialog.conflicts.isEmpty()) { 68 int answer = JOptionPane.showConfirmDialog(Main.parent, 69 tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?"),tr("Conflicts"), JOptionPane.YES_NO_OPTION); 70 if (answer != JOptionPane.YES_OPTION) 71 return false; 72 } 73 return true; 74 } 73 75 74 76 public static File openFileDialog() { 75 JFileChooser fc = createAndOpenFileChooser(false, false); 76 if (fc == null) 77 return null; 78 79 File file = fc.getSelectedFile(); 80 81 String fn = file.getPath(); 82 if (fn.indexOf('.') == -1) { 83 FileFilter ff = fc.getFileFilter(); 84 if (ff instanceof ExtensionFileFilter) 85 fn = "." + ((ExtensionFileFilter)ff).defaultExtension; 86 else 87 fn += ".osm"; 88 file = new File(fn); 89 } 90 return file; 91 } 92 77 JFileChooser fc = createAndOpenFileChooser(false, false); 78 if (fc == null) 79 return null; 80 81 File file = fc.getSelectedFile(); 82 83 String fn = file.getPath(); 84 if (fn.indexOf('.') == -1) { 85 FileFilter ff = fc.getFileFilter(); 86 if (ff instanceof ExtensionFileFilter) 87 fn = "." + ((ExtensionFileFilter)ff).defaultExtension; 88 else 89 fn += ".osm"; 90 file = new File(fn); 91 } 92 return file; 93 } 94 95 private static void copy(File src, File dst) throws IOException { 96 FileInputStream srcStream; 97 FileOutputStream dstStream; 98 try { 99 srcStream = new FileInputStream(src); 100 dstStream = new FileOutputStream(dst); 101 } catch (FileNotFoundException e) { 102 JOptionPane.showMessageDialog(Main.parent, tr("Could not back up file.")+"\n"+e.getMessage()); 103 return; 104 } 105 byte buf[] = new byte[1<<16]; 106 int len; 107 while ((len = srcStream.read(buf)) != -1) { 108 dstStream.write(buf, 0, len); 109 } 110 srcStream.close(); 111 dstStream.close(); 112 } 113 93 114 public static void save(File file, OsmDataLayer layer) { 94 try { 115 File tmpFile = null; 116 try { 95 117 if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(file.getPath())) { 96 118 GpxExportAction.exportGpx(file, layer); 97 119 } else if (ExtensionFileFilter.filters[ExtensionFileFilter.OSM].acceptName(file.getPath())) { 120 // use a tmp file because if something errors out in the 121 // process of writing the file, we might just end up with 122 // a truncated file. That can destroy lots of work. 123 if (file.exists()) { 124 tmpFile = new File(file.getPath() + "~"); 125 copy(file, tmpFile); 126 } 98 127 OsmWriter.output(new FileOutputStream(file), new OsmWriter.All(layer.data, false)); 128 if (!Main.pref.getBoolean("save.keepbackup")) 129 tmpFile.delete(); 99 130 } else if (ExtensionFileFilter.filters[ExtensionFileFilter.CSV].acceptName(file.getPath())) { 100 131 JOptionPane.showMessageDialog(Main.parent, tr("CSV output not supported yet.")); … … 109 140 JOptionPane.showMessageDialog(Main.parent, tr("An error occurred while saving.")+"\n"+e.getMessage()); 110 141 } 111 } 112 142 try { 143 // if the file save failed, then the tempfile will not 144 // be deleted. So, restore the backup if we made one. 145 if (tmpFile != null && tmpFile.exists()) { 146 copy(tmpFile, file); 147 } 148 } catch (IOException e) { 149 e.printStackTrace(); 150 JOptionPane.showMessageDialog(Main.parent, tr("An error occurred while restoring backup file.")+"\n"+e.getMessage()); 151 } 152 } 153 113 154 /** 114 155 * Check the data set if it would be empty on save. It is empty, if it contains -
src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r298 r319 94 94 if (osm.keys == null) 95 95 return s.equals(""); 96 String search = caseSensitive ? s : s.toLowerCase(); 96 97 for (Entry<String, String> e : osm.keys.entrySet()) { 97 98 String key = caseSensitive ? e.getKey() : e.getKey().toLowerCase(); 98 99 String value = caseSensitive ? e.getValue() : e.getValue().toLowerCase(); 99 String search = caseSensitive ? s : s.toLowerCase();100 100 if (key.indexOf(search) != -1 || value.indexOf(search) != -1) 101 return true; 102 } 103 if (osm.user != null) { 104 String name = osm.user.name; 105 if (!caseSensitive) 106 name = name.toLowerCase(); 107 if (name.indexOf(search) != -1) 101 108 return true; 102 109 } -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r315 r319 6 6 import java.awt.Graphics2D; 7 7 import java.awt.Point; 8 import java.awt.Polygon;9 8 import java.awt.Rectangle; 10 9 import java.awt.geom.GeneralPath; -
src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
r317 r319 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.gui.layer; 3 3 … … 104 104 throw new IOException(tr("No time for point {0} x {1}",p.latlon.lat(),p.latlon.lon())); 105 105 Date d = null; 106 try {107 d = DateParser.parse(p.time);108 } catch (ParseException e) {109 throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.time,p.latlon.lat(),p.latlon.lon()));110 }106 try { 107 d = DateParser.parse(p.time); 108 } catch (ParseException e) { 109 throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.time,p.latlon.lat(),p.latlon.lon())); 110 } 111 111 gps.add(new TimedPoint(d, p.eastNorth)); 112 112 } … … 130 130 ImageEntry e = new ImageEntry(); 131 131 try { 132 e.time = ExifReader.readTime(f);133 } catch (ParseException e1) {134 continue;135 }132 e.time = ExifReader.readTime(f); 133 } catch (ParseException e1) { 134 continue; 135 } 136 136 if (e.time == null) 137 137 continue; … … 163 163 private static final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); 164 164 private MouseAdapter mouseAdapter; 165 private int currentImage;166 165 private int currentImage; 166 167 167 public static final class GpsTimeIncorrect extends Exception { 168 168 public GpsTimeIncorrect(String message, Throwable cause) { … … 218 218 Rectangle r = new Rectangle(p.x-e.icon.getIconWidth()/2, p.y-e.icon.getIconHeight()/2, e.icon.getIconWidth(), e.icon.getIconHeight()); 219 219 if (r.contains(ev.getPoint())) { 220 // showImage(e); 221 showImage(i-1); 220 showImage(i-1); 222 221 break; 223 222 } … … 236 235 } 237 236 238 // private void showImage(final ImageEntry e) {239 237 private void showImage(int i) { 240 currentImage = i;238 currentImage = i; 241 239 final JPanel p = new JPanel(new BorderLayout()); 242 240 final ImageEntry e = data.get(currentImage); … … 273 271 cent.addActionListener(new ActionListener(){ 274 272 public void actionPerformed(ActionEvent ev) { 275 final ImageEntry e = data.get(currentImage);276 if (cent.getModel().isSelected())277 Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale()); 278 } 279 });273 final ImageEntry e = data.get(currentImage); 274 if (cent.getModel().isSelected()) 275 Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale()); 276 } 277 }); 280 278 281 279 ActionListener nextprevAction = new ActionListener(){ 282 280 public void actionPerformed(ActionEvent ev) { 283 p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));284 if (ev.getActionCommand().equals("Next")) {285 currentImage++; 286 if(currentImage>=data.size()-1) next.setEnabled(false); 287 prev.setEnabled(true); 288 } else {289 currentImage--; 290 if(currentImage<=0) prev.setEnabled(false); 291 next.setEnabled(true); 292 }293 294 final ImageEntry e = data.get(currentImage);295 if (scale.getModel().isSelected())296 ((JLabel)vp.getView()).setIcon(loadScaledImage(e.image, Math.max(vp.getWidth(), vp.getHeight()))); 297 else298 ((JLabel)vp.getView()).setIcon(new ImageIcon(e.image.getPath())); 299 dlg.setTitle(e.image+" ("+e.coor.toDisplayString()+")");300 if (cent.getModel().isSelected())301 Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale()); 302 p.setCursor(Cursor.getDefaultCursor());303 } 304 };281 p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 282 if (ev.getActionCommand().equals("Next")) { 283 currentImage++; 284 if(currentImage>=data.size()-1) next.setEnabled(false); 285 prev.setEnabled(true); 286 } else { 287 currentImage--; 288 if(currentImage<=0) prev.setEnabled(false); 289 next.setEnabled(true); 290 } 291 292 final ImageEntry e = data.get(currentImage); 293 if (scale.getModel().isSelected()) 294 ((JLabel)vp.getView()).setIcon(loadScaledImage(e.image, Math.max(vp.getWidth(), vp.getHeight()))); 295 else 296 ((JLabel)vp.getView()).setIcon(new ImageIcon(e.image.getPath())); 297 dlg.setTitle(e.image+" ("+e.coor.toDisplayString()+")"); 298 if (cent.getModel().isSelected()) 299 Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale()); 300 p.setCursor(Cursor.getDefaultCursor()); 301 } 302 }; 305 303 next.setActionCommand("Next"); 306 304 prev.setActionCommand("Previous"); … … 453 451 private void sync(File f) { 454 452 Date exifDate; 455 try {456 exifDate = ExifReader.readTime(f);457 } catch (ParseException e) {458 JOptionPane.showMessageDialog(Main.parent, tr("The date in file \"{0}\" could not be parsed.", f.getName()));459 return;460 }453 try { 454 exifDate = ExifReader.readTime(f); 455 } catch (ParseException e) { 456 JOptionPane.showMessageDialog(Main.parent, tr("The date in file \"{0}\" could not be parsed.", f.getName())); 457 return; 458 } 461 459 if (exifDate == null) { 462 460 JOptionPane.showMessageDialog(Main.parent, tr("There is no EXIF time within the file \"{0}\".", f.getName())); … … 489 487 gpstimezone = Long.valueOf(time)*60*60*1000; 490 488 Main.pref.put("tagimages.delta", ""+delta); 491 Main.pref.put("tagimages.gpstimezone", time);489 Main.pref.put("tagimages.gpstimezone", time); 492 490 calculatePosition(); 493 491 return; -
src/org/openstreetmap/josm/gui/preferences/CsvPreference.java
r298 r319 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import javax.swing.Box;7 6 import javax.swing.JLabel; 8 7 import javax.swing.JTextField; … … 31 30 gui.connection.add(new JLabel(tr("CSV import specification (empty: read from first line in data)")), GBC.eol()); 32 31 gui.connection.add(csvImportString, GBC.eop().fill(GBC.HORIZONTAL)); 33 gui.connection.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));34 32 } 35 33 -
src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r298 r319 103 103 settings.add(new ServerAccessPreference()); 104 104 settings.add(new CsvPreference()); 105 settings.add(new FilePreferences()); 105 106 settings.add(new ProjectionPreference()); 106 107 settings.add(new TaggingPresetPreference()); -
src/org/openstreetmap/josm/io/IncompleteDownloader.java
r301 r319 10 10 import java.io.InputStreamReader; 11 11 import java.io.StringReader; 12 import java.util.ArrayList; 12 13 import java.util.Collection; 13 import java.util.ArrayList; 14 15 import javax.swing.JOptionPane; 16 import javax.xml.parsers.ParserConfigurationException; 17 import javax.xml.parsers.SAXParserFactory; 14 18 15 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.command.ChangeCommand; 21 import org.openstreetmap.josm.command.Command; 22 import org.openstreetmap.josm.command.SequenceCommand; 16 23 import org.openstreetmap.josm.data.osm.DataSet; 17 24 import org.openstreetmap.josm.data.osm.Node; … … 20 27 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 21 28 import org.xml.sax.Attributes; 29 import org.xml.sax.InputSource; 22 30 import org.xml.sax.SAXException; 23 24 import javax.swing.JOptionPane; 25 import org.openstreetmap.josm.command.ChangeCommand; 26 import org.openstreetmap.josm.command.Command; 27 import org.openstreetmap.josm.command.SequenceCommand; 28 29 import uk.co.wilson.xml.MinML2; 31 import org.xml.sax.helpers.DefaultHandler; 30 32 31 33 /** … … 80 82 } 81 83 82 private static class SegmentParser extends MinML2{84 private static class SegmentParser extends DefaultHandler { 83 85 public long from, to; 84 86 @Override public void startElement(String ns, String lname, String qname, Attributes a) { … … 133 135 segBuilder.append(line+"\n"); 134 136 SegmentParser segmentParser = new SegmentParser(); 135 segmentParser.parse(new StringReader(segBuilder.toString())); 137 try { 138 SAXParserFactory.newInstance().newSAXParser().parse(new InputSource(new StringReader(segBuilder.toString())), segmentParser); 139 } catch (ParserConfigurationException e1) { 140 e1.printStackTrace(); // broken SAXException chaining 141 throw new SAXException(e1); 142 } 136 143 if (segmentParser.from == 0 || segmentParser.to == 0) 137 144 throw new SAXException("Invalid segment response."); -
src/org/openstreetmap/josm/io/OsmIdReader.java
r298 r319 11 11 import java.util.Map; 12 12 13 import javax.xml.parsers.ParserConfigurationException; 14 import javax.xml.parsers.SAXParserFactory; 15 13 16 import org.xml.sax.Attributes; 17 import org.xml.sax.InputSource; 14 18 import org.xml.sax.SAXException; 15 16 import uk.co.wilson.xml.MinML2; 19 import org.xml.sax.helpers.DefaultHandler; 17 20 18 21 /** … … 21 24 * @author Imi 22 25 */ 23 public class OsmIdReader extends MinML2{26 public class OsmIdReader extends DefaultHandler { 24 27 25 28 private boolean cancel; … … 41 44 this.in = new InputStreamReader(in, "UTF-8"); 42 45 try { 43 parse(this.in); 46 SAXParserFactory.newInstance().newSAXParser().parse(new InputSource(this.in), this); 47 } catch (ParserConfigurationException e) { 48 if (!cancel) { 49 e.printStackTrace(); // broken SAXException chaining 50 throw new SAXException(e); 51 } 44 52 } catch (SAXException e) { 45 53 if (!cancel) -
src/org/openstreetmap/josm/io/OsmReader.java
r298 r319 15 15 import java.util.Map; 16 16 import java.util.Map.Entry; 17 18 import javax.xml.parsers.ParserConfigurationException; 19 import javax.xml.parsers.SAXParserFactory; 17 20 18 21 import org.openstreetmap.josm.Main; … … 31 34 import org.openstreetmap.josm.tools.DateParser; 32 35 import org.xml.sax.Attributes; 36 import org.xml.sax.InputSource; 33 37 import org.xml.sax.SAXException; 34 35 import uk.co.wilson.xml.MinML2; 38 import org.xml.sax.helpers.DefaultHandler; 36 39 37 40 /** … … 103 106 private HashSet<String> allowedVersions = new HashSet<String>(); 104 107 105 private class Parser extends MinML2{108 private class Parser extends DefaultHandler { 106 109 /** 107 110 * The current osm primitive to be read. … … 296 299 297 300 // phase 1: Parse nodes and read in raw segments and ways 298 osm.new Parser().parse(new InputStreamReader(source, "UTF-8")); 301 InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8")); 302 try { 303 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, osm.new Parser()); 304 } catch (ParserConfigurationException e1) { 305 e1.printStackTrace(); // broken SAXException chaining 306 throw new SAXException(e1); 307 } 299 308 if (pleaseWaitDlg != null) { 300 309 pleaseWaitDlg.progress.setValue(0); -
src/org/openstreetmap/josm/io/RawGpsReader.java
r298 r319 14 14 import java.util.Stack; 15 15 16 import javax.xml.parsers.ParserConfigurationException; 17 import javax.xml.parsers.SAXParserFactory; 18 16 19 import org.openstreetmap.josm.data.coor.LatLon; 17 20 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; … … 19 22 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerProducers; 20 23 import org.xml.sax.Attributes; 24 import org.xml.sax.InputSource; 21 25 import org.xml.sax.SAXException; 22 23 import uk.co.wilson.xml.MinML2; 26 import org.xml.sax.helpers.DefaultHandler; 24 27 25 28 /** … … 46 49 public Collection<Marker> markerData = new ArrayList<Marker>(); 47 50 48 private class Parser extends MinML2{51 private class Parser extends DefaultHandler { 49 52 /** 50 53 * Current track to be read. The last entry is the current trkpt. … … 127 130 this.relativeMarkerPath = relativeMarkerPath; 128 131 Parser parser = new Parser(); 129 parser.parse(new InputStreamReader(source, "UTF-8")); 132 InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8")); 133 try { 134 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, parser); 135 } catch (ParserConfigurationException e) { 136 e.printStackTrace(); // broken SAXException chaining 137 throw new SAXException(e); 138 } 130 139 } 131 140 } -
src/org/openstreetmap/josm/plugins/PluginDownloader.java
r300 r319 65 65 } 66 66 67 private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td> [^<]*</td><td>([^<]*)</td><td>(.*)");67 private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td>([^<]*)</td><td>([^<].*)</td><td>(.*)"); 68 68 69 69 public static int downloadDescription() { … … 109 109 b.append(" <name>"+escape(m.group(2))+"</name>\n"); 110 110 b.append(" <resource>"+escape(m.group(1))+"</resource>\n"); 111 b.append(" <description>"+escape(m.group(3))+"</description>\n"); 112 b.append(" <version>"+escape(m.group(4))+"</version>\n"); 111 b.append(" <author>"+escape(m.group(3))+"</author>\n"); 112 b.append(" <description>"+escape(m.group(4))+"</description>\n"); 113 b.append(" <version>"+escape(m.group(5))+"</version>\n"); 113 114 b.append(" </plugin>\n"); 114 115 } -
src/org/openstreetmap/josm/tools/XmlObjectParser.java
r298 r319 14 14 import java.util.concurrent.BlockingQueue; 15 15 16 import javax.xml.parsers.SAXParserFactory; 17 16 18 import org.xml.sax.Attributes; 19 import org.xml.sax.InputSource; 17 20 import org.xml.sax.SAXException; 18 19 import uk.co.wilson.xml.MinML2; 21 import org.xml.sax.helpers.DefaultHandler; 20 22 21 23 /** … … 47 49 } 48 50 49 private class Parser extends MinML2{51 private class Parser extends DefaultHandler { 50 52 Stack<Object> current = new Stack<Object>(); 51 53 String characters = ""; … … 169 171 @Override public void run() { 170 172 try { 171 parser.parse(in);173 SAXParserFactory.newInstance().newSAXParser().parse(new InputSource(in), parser); 172 174 } catch (Exception e) { 173 175 try {
Note:
See TracChangeset
for help on using the changeset viewer.
