- Timestamp:
- 2015-01-07T21:01:44+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r7817 r7935 728 728 729 729 yLayer.useThumbs = cbShowThumbs.isSelected(); 730 yLayer. loadThumbs();730 yLayer.startLoadThumbs(); 731 731 732 732 // Search whether an other layer has yet defined some bounding box. -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r7912 r7935 18 18 import java.awt.event.MouseEvent; 19 19 import java.awt.image.BufferedImage; 20 import java.awt.datatransfer.Clipboard;21 import java.awt.datatransfer.StringSelection;22 import java.awt.Toolkit;23 20 import java.beans.PropertyChangeEvent; 24 21 import java.beans.PropertyChangeListener; … … 38 35 import java.util.Set; 39 36 import java.util.TimeZone; 37 import java.util.concurrent.ExecutorService; 38 import java.util.concurrent.Executors; 40 39 41 40 import javax.swing.Action; … … 78 77 import com.drew.metadata.exif.ExifIFD0Directory; 79 78 import com.drew.metadata.exif.GpsDirectory; 79 import java.util.concurrent.ThreadFactory; 80 80 81 81 /** … … 93 93 94 94 boolean useThumbs = false; 95 ExecutorService thumbusLoaderExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() { 96 @Override 97 public Thread newThread(Runnable r) { 98 Thread t = new Thread(r); 99 t.setPriority(Thread.MIN_PRIORITY); 100 return t; 101 } 102 }); 95 103 ThumbsLoader thumbsloader; 96 boolean thumbsLoaded = false; 104 boolean thumbsLoaderRunning = false; 105 volatile boolean thumbsLoaded = false; 97 106 private BufferedImage offscreenBuffer; 98 107 boolean updateOffscreenBuffer = true; … … 331 340 entries.add(SeparatorLayerAction.INSTANCE); 332 341 entries.add(new CorrelateGpxWithImages(this)); 342 entries.add(new ShowThumbnailAction(this)); 333 343 if (!menuAdditions.isEmpty()) { 334 344 entries.add(SeparatorLayerAction.INSTANCE); … … 372 382 public void mergeFrom(Layer from) { 373 383 GeoImageLayer l = (GeoImageLayer) from; 384 385 // Stop to load thumbnails on both layers. Thumbnail loading will continue the next time 386 // the layer is painted. 387 stopLoadThumbs(); 388 l.stopLoadThumbs(); 374 389 375 390 ImageEntry selected = null; … … 440 455 if (useThumbs) { 441 456 if (!thumbsLoaded) { 442 loadThumbs();457 startLoadThumbs(); 443 458 } 444 459 … … 989 1004 public void layerRemoved(Layer oldLayer) { 990 1005 if (oldLayer == GeoImageLayer.this) { 991 if (thumbsloader != null) { 992 thumbsloader.stop = true; 993 } 1006 stopLoadThumbs(); 994 1007 Main.map.mapView.removeMouseListener(mouseAdapter); 995 1008 MapFrame.removeMapModeChangeListener(mapModeListener); … … 1017 1030 } 1018 1031 1019 public void loadThumbs() { 1020 if (useThumbs && !thumbsLoaded) { 1021 thumbsLoaded = true; 1032 /** 1033 * Start to load thumbnails. 1034 */ 1035 public synchronized void startLoadThumbs() { 1036 if (useThumbs && !thumbsLoaded && !thumbsLoaderRunning) { 1037 stopLoadThumbs(); 1022 1038 thumbsloader = new ThumbsLoader(this); 1023 Thread t = new Thread(thumbsloader); 1024 t.setPriority(Thread.MIN_PRIORITY); 1025 t.start(); 1026 } 1039 thumbusLoaderExecutor.submit(thumbsloader); 1040 thumbsLoaderRunning = true; 1041 } 1042 } 1043 1044 /** 1045 * Stop to load thumbnails. 1046 * 1047 * Can be called at any time to make sure that the 1048 * thumbnail loader is stopped. 1049 */ 1050 public synchronized void stopLoadThumbs() { 1051 if (thumbsloader != null) { 1052 thumbsloader.stop = true; 1053 } 1054 thumbsLoaderRunning = false; 1055 } 1056 1057 /** 1058 * Called to signal that the loading of thumbnails has finished. 1059 * 1060 * Usually called from {@link ThumbsLoader} in another thread. 1061 */ 1062 public void thumbsLoaded() { 1063 thumbsLoaded = true; 1027 1064 } 1028 1065 … … 1076 1113 this.useThumbs = useThumbs; 1077 1114 if (useThumbs && !thumbsLoaded) { 1078 loadThumbs(); 1115 startLoadThumbs(); 1116 } else if (!useThumbs) { 1117 stopLoadThumbs(); 1079 1118 } 1080 1119 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
r7784 r7935 17 17 public static final int maxSize = 120; 18 18 public static final int minSize = 22; 19 volatile boolean stop = false; 19 public volatile boolean stop = false; 20 20 List<ImageEntry> data; 21 21 GeoImageLayer layer; … … 51 51 } 52 52 } 53 layer.thumbsLoaded(); 53 54 layer.updateOffscreenBuffer = true; 54 55 Main.map.mapView.repaint(); -
trunk/src/org/openstreetmap/josm/gui/progress/ProgressMonitorExecutor.java
r4718 r7935 8 8 import org.openstreetmap.josm.Main; 9 9 10 /** 11 * Executor that displays the progress monitor to the user. 12 * 13 * Similar to Executors.newSingleThreadExecutor(), but displays the 14 * progress monitor whenever a new task is executed. 15 */ 10 16 public class ProgressMonitorExecutor extends ThreadPoolExecutor { 11 17
Note:
See TracChangeset
for help on using the changeset viewer.