Changeset 31159 in osm for applications/editors/josm/plugins
- Timestamp:
- 2015-05-29T14:41:55+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31158 r31159 15 15 public class MapillaryData { 16 16 public volatile static MapillaryData INSTANCE; 17 17 18 18 private final List<MapillaryImage> images; 19 19 private MapillaryImage selectedImage = null; 20 20 private List<MapillaryImage> multiSelectedImages; 21 22 21 23 22 public MapillaryData() { … … 169 168 } 170 169 } 171 170 171 /** 172 * Adds a MapillaryImage object to the list of selected images, (when ctrl + 173 * click) 174 * 175 * @param image The MapillaryImage object to be added. 176 */ 172 177 public void addMultiSelectedImage(MapillaryImage image) { 173 178 this.multiSelectedImages.add(image); 174 179 Main.map.mapView.repaint(); 175 180 } 176 177 public List<MapillaryImage> getMultiSelectedImages() {181 182 public List<MapillaryImage> getMultiSelectedImages() { 178 183 return multiSelectedImages; 179 184 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31158 r31159 1 1 package org.openstreetmap.josm.plugins.mapillary; 2 3 2 4 3 import org.openstreetmap.josm.data.coor.LatLon; … … 61 60 } 62 61 63 64 62 /** 65 63 * Sets the MapillarySequence object which contains the MapillaryImage. … … 71 69 this.sequence = sequence; 72 70 } 73 74 71 75 72 public MapillarySequence getSequence() { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31041 r31159 1 1 package org.openstreetmap.josm.plugins.mapillary; 2 2 3 import javax.swing.ImageIcon; 4 import javax.swing.JMenuItem; 5 6 import org.openstreetmap.josm.gui.MainMenu; 7 import org.openstreetmap.josm.Main; 3 8 import org.openstreetmap.josm.gui.MapFrame; 4 9 import org.openstreetmap.josm.plugins.Plugin; 5 10 import org.openstreetmap.josm.plugins.PluginInformation; 11 import org.openstreetmap.josm.tools.ImageProvider; 6 12 7 13 /** 8 14 * This is the main class for the mapillary plugin. 15 * 16 * @author nokutu 9 17 * 10 18 */ 11 public class MapillaryPlugin extends Plugin {19 public class MapillaryPlugin extends Plugin { 12 20 13 public MapillaryPlugin(PluginInformation info) { 14 super(info); 15 } 21 public static final ImageIcon ICON = new ImageProvider("icon24.png").get(); 22 public static final ImageIcon ICON16 = new ImageProvider("icon16.png").get(); 23 public static final ImageIcon ICON16SELECTED = new ImageProvider("icon16selected.png").get(); 24 public static final int ICON_SIZE = 24; 25 26 MapillaryDownloadAction downloadAction; 27 MapillaryExportAction exportAction; 28 29 public static JMenuItem DOWNLOAD_MENU; 30 public static JMenuItem EXPORT_MENU; 16 31 17 /** 18 * Called when the JOSM map frame is created or destroyed. 19 */ 20 @Override 21 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 22 if (oldFrame == null && newFrame != null) { // map frame added 32 public MapillaryPlugin(PluginInformation info) { 33 super(info); 34 downloadAction = new MapillaryDownloadAction(); 35 exportAction = new MapillaryExportAction(); 23 36 24 } 25 } 37 DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false, 0); 38 EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14); 39 EXPORT_MENU.setEnabled(false); 40 41 } 42 43 /** 44 * Called when the JOSM map frame is created or destroyed. 45 */ 46 @Override 47 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 48 if (oldFrame == null && newFrame != null) { // map frame added 49 MapillaryToggleDialog.deleteInstance (); 50 } 51 } 52 53 public static void setMenuEnabled(JMenuItem menu, boolean value) { 54 menu.setEnabled(value); 55 } 26 56 } 57 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java
r31158 r31159 35 35 * 36 36 */ 37 public class MapillaryToggleDialog extends ToggleDialog implements ICachedLoaderListener{ 37 public class MapillaryToggleDialog extends ToggleDialog implements 38 ICachedLoaderListener { 38 39 39 40 public static MapillaryToggleDialog INSTANCE; … … 65 66 return INSTANCE; 66 67 } 67 68 68 69 public static void deleteInstance() { 69 70 INSTANCE = null; … … 99 100 prev = JCSCacheManager.getCache("mapillary"); 100 101 HashMap<String, String> headers = new HashMap<>(); 101 MapillaryCache cache = new MapillaryCache(image.getKey(), MapillaryCache.Type.FULL_IMAGE, prev, 200000, 200000, headers); 102 MapillaryCache cache = new MapillaryCache(image.getKey(), 103 MapillaryCache.Type.FULL_IMAGE, prev, 200000, 104 200000, headers); 102 105 cache.submit(MapillaryToggleDialog.getInstance(), false); 103 106 } catch (IOException e) { 104 107 // TODO Auto-generated catch block 105 108 e.printStackTrace(); 106 } catch (Exception e) {107 System.out.println("Hello");108 109 } 109 /*if (image.getImage() != null) {110 showImage();111 } else if (image.getThumbnail() != null) {112 showThumbnail();113 }*/114 110 } else 115 111 showDefault(); … … 156 152 public void loadingFinished(CacheEntry data, 157 153 CacheEntryAttributes attributes, LoadResult result) { 158 System.out.println("Listener"); 159 try { 160 BufferedImage img = ImageIO.read(new ByteArrayInputStream(data.getContent())); 161 this.remove(active); 162 JLabel label = new JLabel("", new ImageIcon(img), JLabel.CENTER); 163 active = label; 164 this.add(active); 165 this.updateUI(); 166 } catch (IOException e) { 167 // TODO Auto-generated catch block 168 e.printStackTrace(); 154 if (!SwingUtilities.isEventDispatchThread()) { 155 SwingUtilities.invokeLater(new Runnable() { 156 @Override 157 public void run() { 158 updateImage(); 159 } 160 }); 161 } else { 162 try { 163 BufferedImage img = ImageIO.read(new ByteArrayInputStream(data 164 .getContent())); 165 this.remove(active); 166 JLabel label = new JLabel("", new ImageIcon(img), JLabel.CENTER); 167 active = label; 168 this.add(active); 169 this.updateUI(); 170 } catch (IOException e) { 171 // TODO Auto-generated catch block 172 e.printStackTrace(); 173 } 169 174 } 170 171 172 175 173 176 } 174 177 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java
r31158 r31159 55 55 return new BufferedImageCacheEntry(content); 56 56 } 57 57 58 58 @Override 59 59 protected boolean isObjectLoadable() { 60 60 if (cacheData == null) 61 61 return false; 62 63 64 62 byte[] content = cacheData.getContent(); 63 return content != null && content.length > 0; 64 } 65 65 66 // @Override66 // @Override 67 67 protected boolean handleNotFound() { 68 68 // TODO Auto-generated method stub -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java
r31158 r31159 2 2 3 3 import java.awt.image.BufferedImage; 4 import java.io.ByteArrayInputStream; 4 5 import java.io.IOException; 5 6 import java.net.MalformedURLException; 6 7 import java.net.URL; 8 import java.util.HashMap; 7 9 import java.util.concurrent.ArrayBlockingQueue; 8 10 9 11 import javax.imageio.ImageIO; 10 12 13 import org.apache.commons.jcs.access.CacheAccess; 14 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 15 import org.openstreetmap.josm.data.cache.CacheEntry; 16 import org.openstreetmap.josm.data.cache.CacheEntryAttributes; 17 import org.openstreetmap.josm.data.cache.ICachedLoaderListener; 18 import org.openstreetmap.josm.data.cache.JCSCacheManager; 11 19 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 12 20 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 21 import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache; 13 22 14 public class MapillaryExportDownloadThread implements Runnable { 23 public class MapillaryExportDownloadThread implements Runnable, 24 ICachedLoaderListener { 15 25 16 26 String url; 17 27 ArrayBlockingQueue<BufferedImage> queue; 18 28 ProgressMonitor monitor; 29 MapillaryImage image; 19 30 20 public MapillaryExportDownloadThread(MapillaryImage image, ArrayBlockingQueue<BufferedImage> queue) { 31 public MapillaryExportDownloadThread(MapillaryImage image, 32 ArrayBlockingQueue<BufferedImage> queue) { 21 33 url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey() 22 34 + "/thumb-2048.jpg"; 23 35 this.queue = queue; 36 this.image = image; 24 37 } 25 38 … … 27 40 public void run() { 28 41 try { 42 CacheAccess<String, BufferedImageCacheEntry> prev = JCSCacheManager 43 .getCache("mapillary"); 44 new MapillaryCache(image.getKey(), MapillaryCache.Type.FULL_IMAGE, 45 prev, 200000, 200000, new HashMap<String, String>()) 46 .submit(this, false); 29 47 queue.put(ImageIO.read(new URL(url))); 30 48 } catch (MalformedURLException e) { … … 40 58 } 41 59 60 @Override 61 public void loadingFinished(CacheEntry data, 62 CacheEntryAttributes attributes, LoadResult result) { 63 try { 64 queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent()))); 65 } catch (InterruptedException e) { 66 // TODO Auto-generated catch block 67 e.printStackTrace(); 68 } catch (IOException e) { 69 // TODO Auto-generated catch block 70 e.printStackTrace(); 71 } 72 73 } 74 42 75 }
Note:
See TracChangeset
for help on using the changeset viewer.