- Timestamp:
- 2009-12-07T21:16:15+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2577 r2592 322 322 return; 323 323 } 324 JFileChooser fc = new JFileChooser(Main.pref.get(" tagimages.lastdirectory", Main.pref.get("lastDirectory")));324 JFileChooser fc = new JFileChooser(Main.pref.get("geoimage.lastdirectory", Main.pref.get("lastDirectory"))); 325 325 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 326 326 fc.setMultiSelectionEnabled(true); … … 343 343 LinkedList<File> files = new LinkedList<File>(); 344 344 addRecursiveFiles(files, sel); 345 Main.pref.put(" tagimages.lastdirectory", fc.getCurrentDirectory().getPath());345 Main.pref.put("geoimage.lastdirectory", fc.getCurrentDirectory().getPath()); 346 346 GeoImageLayer.create(files, GpxLayer.this); 347 347 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r2566 r2592 37 37 import javax.swing.ButtonGroup; 38 38 import javax.swing.JButton; 39 import javax.swing.JCheckBox; 39 40 import javax.swing.JComboBox; 40 41 import javax.swing.JFileChooser; … … 149 150 if (!sel.getName().equals(wrapper.name)) { 150 151 JOptionPane.showMessageDialog( 151 152 Main.parent, 152 153 tr("File {0} is loaded yet under the name \"{1}\"", sel.getName(), wrapper.name), 153 154 tr("Error"), … … 173 174 x.printStackTrace(); 174 175 JOptionPane.showMessageDialog( 175 176 177 178 179 176 Main.parent, 177 tr("Error while parsing {0}",sel.getName())+": "+x.getMessage(), 178 tr("Error"), 179 JOptionPane.ERROR_MESSAGE 180 ); 180 181 return; 181 182 } catch (IOException x) { 182 183 x.printStackTrace(); 183 184 JOptionPane.showMessageDialog( 184 185 186 187 188 185 Main.parent, 186 tr("Could not read \"{0}\"",sel.getName())+"\n"+x.getMessage(), 187 tr("Error"), 188 JOptionPane.ERROR_MESSAGE 189 ); 189 190 return; 190 191 } … … 293 294 cbTimezones = new JComboBox(vtTimezones); 294 295 295 String tzId = Main.pref.get(" tagimages.timezoneid", "");296 String tzId = Main.pref.get("geoimage.timezoneid", ""); 296 297 TimeZone defaultTz; 297 298 if (tzId.length() == 0) { … … 351 352 352 353 public void actionPerformed(ActionEvent arg0) { 353 JFileChooser fc = new JFileChooser(Main.pref.get(" tagimages.lastdirectory"));354 JFileChooser fc = new JFileChooser(Main.pref.get("geoimage.lastdirectory")); 354 355 fc.setAcceptAllFileFilterUsed(false); 355 356 fc.setMultiSelectionEnabled(false); … … 387 388 while (! isOk) { 388 389 int answer = JOptionPane.showConfirmDialog( 389 390 391 392 393 390 Main.parent, panel, 391 tr("Synchronize time from a photo of the GPS receiver"), 392 JOptionPane.OK_CANCEL_OPTION, 393 JOptionPane.QUESTION_MESSAGE 394 ); 394 395 if (answer == JOptionPane.CANCEL_OPTION) { 395 396 return; … … 413 414 String tzValue = selectedTz.substring(pos + 1, selectedTz.length() - 1); 414 415 415 Main.pref.put(" tagimages.timezoneid", tzId);416 Main.pref.put("geoimage.timezoneid", tzId); 416 417 tfOffset.setText(Long.toString(delta / 1000)); 417 418 tfTimezone.setText(tzValue); … … 476 477 panelTf.add(new JLabel(tr("Timezone: ")), gc); 477 478 478 float gpstimezone = Float.parseFloat(Main.pref.get(" tagimages.doublegpstimezone", "0.0"));479 float gpstimezone = Float.parseFloat(Main.pref.get("geoimage.doublegpstimezone", "0.0")); 479 480 if (gpstimezone == 0.0) { 480 gpstimezone = - Long.parseLong(Main.pref.get(" tagimages.gpstimezone", "0"));481 gpstimezone = - Long.parseLong(Main.pref.get("geoimage.gpstimezone", "0")); 481 482 } 482 483 tfTimezone = new JTextField(); … … 498 499 panelTf.add(new JLabel(tr("Offset:")), gc); 499 500 500 long delta = Long.parseLong(Main.pref.get(" tagimages.delta", "0")) / 1000;501 long delta = Long.parseLong(Main.pref.get("geoimage.delta", "0")) / 1000; 501 502 tfOffset = new JTextField(); 502 503 tfOffset.setText(Long.toString(delta)); … … 557 558 panelTf.add(rbUntaggedImg, gc); 558 559 560 gc.gridx = 0; 561 gc.gridy = 5; 562 gc.gridwidth = 2; 563 gc.gridheight = 1; 564 gc.fill = GridBagConstraints.NONE; 565 gc.weightx = gc.weighty = 0.0; 566 yLayer.loadThumbs = Main.pref.getBoolean("geoimage.showThumbs", false); 567 JCheckBox cbShowThumbs = new JCheckBox(tr("Show Thumbnail images on the map"), yLayer.loadThumbs); 568 panelTf.add(cbShowThumbs, gc); 569 559 570 ButtonGroup group = new ButtonGroup(); 560 571 group.add(rbAllImg); … … 573 584 GpxDataWrapper selectedGpx = null; 574 585 while (! isOk) { 575 576 586 ExtendedDialog dialog = new ExtendedDialog( 587 Main.parent, 577 588 tr("Correlate images with GPX track"), 578 589 new String[] { tr("Correlate"), tr("Auto-Guess"), tr("Cancel") } 579 580 581 582 583 584 590 ); 591 592 dialog.setContent(panel); 593 dialog.setButtonIcons(new String[] { "ok.png", "dialogs/geoimage/gpx2imgManual.png", "cancel.png" }); 594 dialog.showDialog(); 595 int answer = dialog.getValue(); 585 596 if(answer != 1 && answer != 2) 586 597 return; … … 624 635 } 625 636 626 Main.pref.put("tagimages.doublegpstimezone", Double.toString(gpstimezone)); 627 Main.pref.put("tagimages.gpstimezone", Long.toString(- ((long) gpstimezone))); 628 Main.pref.put("tagimages.delta", Long.toString(delta * 1000)); 629 637 yLayer.loadThumbs = cbShowThumbs.isSelected(); 638 639 Main.pref.put("geoimage.doublegpstimezone", Double.toString(gpstimezone)); 640 Main.pref.put("geoimage.gpstimezone", Long.toString(- ((long) gpstimezone))); 641 Main.pref.put("geoimage.delta", Long.toString(delta * 1000)); 642 Main.pref.put("geoimage.showThumbs", yLayer.loadThumbs); 630 643 isOk = true; 644 645 if (yLayer.loadThumbs) { 646 Thread tl = new Thread(new ThumbsLoader(yLayer.data)); 647 tl.setPriority(Thread.MIN_PRIORITY); 648 tl.start(); 649 } 650 631 651 } 632 652 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r2566 r2592 71 71 public long timeoffset = 0; 72 72 73 boolean loadThumbs; 74 73 75 /* 74 76 * Stores info about each image … … 117 119 118 120 protected void rememberError(String message) { 119 121 this.errorMessages.add(message); 120 122 } 121 123 … … 138 140 if (cancelled) { 139 141 return; 140 } 142 } 141 143 progressMonitor.subTask(tr("Read photos...")); 142 144 progressMonitor.setTicksCount(files.size()); … … 173 175 layer = new GeoImageLayer(data); 174 176 files.clear(); 175 Thread thumbsloader = new Thread(new Thumbsloader());176 thumbsloader.setPriority(Thread.MIN_PRIORITY);177 thumbsloader.start();178 177 } 179 178 … … 216 215 } 217 216 } else { 218 217 rememberError(tr("Error while getting files from directory {0}\n", f.getPath())); 219 218 } 220 219 … … 230 229 231 230 protected String formatErrorMessages() { 232 233 234 235 236 237 238 239 240 241 242 243 244 231 StringBuffer sb = new StringBuffer(); 232 sb.append("<html>"); 233 if (errorMessages.size() == 1) { 234 sb.append(errorMessages.iterator().next()); 235 } else { 236 sb.append("<ul>"); 237 for (String msg: errorMessages) { 238 sb.append("<li>").append(msg).append("</li>"); 239 } 240 sb.append("/ul>"); 241 } 242 sb.append("</html>"); 243 return sb.toString(); 245 244 } 246 245 247 246 @Override protected void finish() { 248 249 250 251 252 253 254 255 247 if (!errorMessages.isEmpty()) { 248 JOptionPane.showMessageDialog( 249 Main.parent, 250 formatErrorMessages(), 251 tr("Error"), 252 JOptionPane.ERROR_MESSAGE 253 ); 254 } 256 255 if (layer != null) { 257 256 Main.main.addLayer(layer); … … 276 275 cancelled = true; 277 276 } 278 279 class Thumbsloader implements Runnable { 280 public void run() { 281 System.err.println("Load Thumbnails"); 282 MediaTracker tracker = new MediaTracker(Main.map.mapView); 283 for (int i = 0; i < layer.data.size(); i++) { 284 System.err.println("getImg "+i); 285 Image img = Toolkit.getDefaultToolkit().createImage(layer.data.get(i).file.getPath()); 286 tracker.addImage(img, 0); 287 try { 288 tracker.waitForID(0); 289 } catch (InterruptedException e) { 290 System.err.println("InterruptedException"); 291 return; // FIXME 292 } 293 BufferedImage scaledBI = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB); 294 Graphics2D g = scaledBI.createGraphics(); 295 while (!g.drawImage(img, 0, 0, 16, 16, null)) 296 { 297 try { 298 Thread.sleep(10); 299 } catch(InterruptedException ie) {} 300 } 301 g.dispose(); 302 tracker.removeImage(img); 303 layer.data.get(i).thumbnail = scaledBI; 304 if (Main.map != null && Main.map.mapView != null) { 305 Main.map.mapView.repaint(); 306 } 307 } 308 309 // boolean error = tracker.isErrorID(1); 310 // if (img != null && (img.getWidth(null) == 0 || img.getHeight(null) == 0)) { 311 // error = true; 312 // } 313 314 315 } 316 } 317 } 318 277 } 278 319 279 private static boolean addedToggleDialog = false; 320 280 … … 424 384 Point p = mv.getPoint(e.pos); 425 385 if (e.thumbnail != null && e.thumbnail.getWidth(null) > 0 && e.thumbnail.getHeight(null) > 0) { 426 g.drawImage(e.thumbnail, 427 p.x - e.thumbnail.getWidth(null) / 2, 386 g.drawImage(e.thumbnail, 387 p.x - e.thumbnail.getWidth(null) / 2, 428 388 p.y - e.thumbnail.getHeight(null) / 2, null); 429 389 } 430 390 else { 431 icon.paintIcon(mv, g, 432 p.x - icon.getIconWidth() / 2, 391 icon.paintIcon(mv, g, 392 p.x - icon.getIconWidth() / 2, 433 393 p.y - icon.getIconHeight() / 2); 434 394 } … … 537 497 Main.main.map.repaint(); 538 498 } 539 499 540 500 public void checkPreviousNextButtons() { 541 501 System.err.println("check: " + currentPhoto); … … 598 558 ImageViewerDialog.showImage(GeoImageLayer.this, e); 599 559 Main.main.map.repaint(); 600 601 602 560 break; 603 561 } … … 628 586 }); 629 587 } 630 631 588 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r2566 r2592 135 135 System.out.println(e); 136 136 if (e.getWhen() - lastTimeForMousePoint > 1500 || mousePointInImg == null) { 137 137 lastTimeForMousePoint = e.getWhen(); 138 138 mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY()); 139 139 }
Note:
See TracChangeset
for help on using the changeset viewer.