Changeset 1865 in josm for trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
- Timestamp:
- 2009-07-28T19:48:39+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
r1863 r1865 70 70 import org.openstreetmap.josm.gui.MapFrame; 71 71 import org.openstreetmap.josm.gui.MapView; 72 import org.openstreetmap.josm.gui.OptionPaneUtil; 72 73 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 73 74 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 125 126 if (cachedImageRef != null) { 126 127 Image cachedImage = cachedImageRef.get(); 127 if (cachedImage != null) {128 if (cachedImage != null) 128 129 return cachedImage; 129 }130 130 } 131 131 return Toolkit.getDefaultToolkit().createImage(currentEntry.file.getAbsolutePath()); … … 147 147 } 148 148 private void loadImage() { 149 if (currentEntry != null) {149 if (currentEntry != null) 150 150 return; 151 }152 151 while (!queue.isEmpty()) { 153 152 currentEntry = queue.get(0); … … 217 216 218 217 while (true) { 219 if (entry.scaledImage != null) {218 if (entry.scaledImage != null) 220 219 return entry.scaledImage; 221 }222 220 try { 223 221 wait(); … … 259 257 260 258 public Image getIcon() { 261 if (icon.scaledImage == null) {259 if (icon.scaledImage == null) 262 260 return EMPTY_IMAGE; 263 } else {261 else 264 262 return icon.scaledImage; 265 }266 263 } 267 264 … … 330 327 ArrayList<ImageEntry> data = new ArrayList<ImageEntry>(files.size()); 331 328 for (File f : files) { 332 if (progressMonitor.isCancelled()) 329 if (progressMonitor.isCancelled()) { 333 330 break; 331 } 334 332 progressMonitor.subTask(tr("Reading {0}...",f.getName())); 335 333 … … 341 339 continue; 342 340 } 343 if (e.time == null) 341 if (e.time == null) { 344 342 continue; 343 } 345 344 346 345 data.add(e); … … 350 349 } 351 350 @Override protected void finish() { 352 if (layer != null) 351 if (layer != null) { 353 352 Main.main.addLayer(layer); 353 } 354 354 } 355 355 @Override … … 412 412 return; 413 413 mousePressed = true; 414 if (visible) 414 if (visible) { 415 415 Main.map.mapView.repaint(); 416 } 416 417 } 417 418 @Override public void mouseReleased(MouseEvent ev) { … … 423 424 for (int i = data.size(); i > 0; --i) { 424 425 ImageEntry e = data.get(i-1); 425 if (e.pos == null) 426 if (e.pos == null) { 426 427 continue; 428 } 427 429 Point p = Main.map.mapView.getPoint(e.pos); 428 430 Rectangle r = new Rectangle(p.x-ICON_SIZE/2, p.y-ICON_SIZE/2, ICON_SIZE, ICON_SIZE); … … 440 442 public void layerAdded(Layer newLayer) {} 441 443 public void layerRemoved(Layer oldLayer) { 442 if (oldLayer == self) 444 if (oldLayer == self) { 443 445 Main.map.mapView.removeMouseListener(mouseAdapter); 446 } 444 447 } 445 448 }); … … 550 553 nextButton.setEnabled(currentImage < data.size() - 1); 551 554 552 if (scaleToggle.getModel().isSelected()) 555 if (scaleToggle.getModel().isSelected()) { 553 556 imageLabel.setIcon(new ImageIcon(imageLoader.waitForImage(currentImageEntry.image, 554 557 Math.max(imageViewport.getWidth(), imageViewport.getHeight())))); 555 else558 } else { 556 559 imageLabel.setIcon(new ImageIcon(imageLoader.waitForImage(currentImageEntry.image))); 557 558 if (centerToggle.getModel().isSelected()) 560 } 561 562 if (centerToggle.getModel().isSelected()) { 559 563 Main.map.mapView.zoomTo(currentImageEntry.pos); 564 } 560 565 561 566 dlg.setTitle(currentImageEntry.image + … … 594 599 setIcon(new ImageIcon(e.getIcon())); 595 600 setText(e.image.getName()+" ("+dateFormat.format(new Date(e.time.getTime()+(delta+gpstimezone)))+")"); 596 if (e.pos == null) 601 if (e.pos == null) { 597 602 setForeground(Color.red); 603 } 598 604 return this; 599 605 } … … 607 613 int i = 0; 608 614 for (ImageEntry e : data) 609 if (e.pos != null) 615 if (e.pos != null) { 610 616 i++; 617 } 611 618 return data.size()+" "+trn("image","images",data.size())+". "+tr("{0} within the track.",i); 612 619 } … … 662 669 663 670 @Override public void visitBoundingBox(BoundingXYVisitor v) { 664 for (ImageEntry e : data) 671 for (ImageEntry e : data) { 665 672 v.visit(e.pos); 673 } 666 674 } 667 675 … … 723 731 exifDate = ExifReader.readTime(f); 724 732 } catch (ParseException e) { 725 JOptionPane.showMessageDialog(Main.parent, tr("The date in file \"{0}\" could not be parsed.", f.getName())); 733 OptionPaneUtil.showMessageDialog( 734 Main.parent, 735 tr("The date in file \"{0}\" could not be parsed.", f.getName()), 736 tr("Error"), 737 JOptionPane.ERROR_MESSAGE 738 ); 726 739 return; 727 740 } 728 741 if (exifDate == null) { 729 JOptionPane.showMessageDialog(Main.parent, tr("There is no EXIF time within the file \"{0}\".", f.getName())); 742 OptionPaneUtil.showMessageDialog( 743 Main.parent, 744 tr("There is no EXIF time within the file \"{0}\".", f.getName()), 745 tr("Error"), 746 JOptionPane.ERROR_MESSAGE 747 ); 730 748 return; 731 749 } … … 738 756 p.add(new JLabel(tr("GPS unit timezone (difference to photo)")), GBC.eol()); 739 757 String t = Main.pref.get("tagimages.gpstimezone", "0"); 740 if (t.charAt(0) != '-') 758 if (t.charAt(0) != '-') { 741 759 t = "+"+t; 760 } 742 761 JTextField gpsTimezone = new JTextField(t); 743 762 p.add(gpsTimezone, GBC.eol().fill(GBC.HORIZONTAL)); 744 763 745 764 while (true) { 746 int answer = JOptionPane.showConfirmDialog(Main.parent, p, tr("Synchronize Time with GPS Unit"), JOptionPane.OK_CANCEL_OPTION); 765 int answer = OptionPaneUtil.showConfirmationDialog( 766 Main.parent, 767 p, 768 tr("Synchronize Time with GPS Unit"), 769 JOptionPane.OK_CANCEL_OPTION, 770 JOptionPane.QUESTION_MESSAGE 771 ); 747 772 if (answer != JOptionPane.OK_OPTION || gpsText.getText().equals("")) 748 773 return; … … 750 775 delta = DateParser.parse(gpsText.getText()).getTime() - exifDate.getTime(); 751 776 String time = gpsTimezone.getText(); 752 if (!time.equals("") && time.charAt(0) == '+') 777 if (!time.equals("") && time.charAt(0) == '+') { 753 778 time = time.substring(1); 754 if (time.equals("")) 779 } 780 if (time.equals("")) { 755 781 time = "0"; 782 } 756 783 gpstimezone = Long.valueOf(time)*60*60*1000; 757 784 Main.pref.put("tagimages.delta", ""+delta); … … 760 787 return; 761 788 } catch (NumberFormatException x) { 762 JOptionPane.showMessageDialog(Main.parent, tr("Time entered could not be parsed.")); 789 OptionPaneUtil.showMessageDialog( 790 Main.parent, 791 tr("Time entered could not be parsed."), 792 tr("Error"), 793 JOptionPane.ERROR_MESSAGE 794 ); 763 795 } catch (ParseException x) { 764 JOptionPane.showMessageDialog(Main.parent, tr("Time entered could not be parsed.")); 796 OptionPaneUtil.showMessageDialog( 797 Main.parent, 798 tr("Time entered could not be parsed."), 799 tr("Error"), 800 JOptionPane.ERROR_MESSAGE 801 ); 765 802 } 766 803 }
Note:
See TracChangeset
for help on using the changeset viewer.