Changeset 31166 in osm for applications/editors/josm
- Timestamp:
- 2015-05-31T20:55:36+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31164 r31166 20 20 * 21 21 * @author nokutu 22 * @see MapillaryImage 23 * @see MapillarySequence 22 24 * 23 25 */ … … 178 180 e.printStackTrace(); 179 181 } 180 if (image.next() != null) 182 if (image.next() != null) { 181 183 new MapillaryCache(image.next().getKey(), 182 MapillaryCache.Type. FULL_IMAGE, prev, 200000, 200000,184 MapillaryCache.Type.THUMBNAIL, prev, 200000, 200000, 183 185 new HashMap<String, String>()).submit(this, false); 184 if (image.previous() != null) 186 if (image.next().next() != null) 187 new MapillaryCache(image.next().next().getKey(), 188 MapillaryCache.Type.THUMBNAIL, prev, 200000, 189 200000, new HashMap<String, String>()).submit(this, 190 false); 191 } 192 if (image.previous() != null) { 185 193 new MapillaryCache(image.previous().getKey(), 186 MapillaryCache.Type. FULL_IMAGE, prev, 200000, 200000,194 MapillaryCache.Type.THUMBNAIL, prev, 200000, 200000, 187 195 new HashMap<String, String>()).submit(this, false); 196 if (image.previous().previous() != null) 197 new MapillaryCache(image.previous().previous().getKey(), 198 MapillaryCache.Type.THUMBNAIL, prev, 200000, 199 200000, new HashMap<String, String>()).submit(this, 200 false); 201 } 188 202 } 189 203 if (Main.map != null) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDownloadAction.java
r31164 r31166 27 27 tr("Create Mapillary layer."), Shortcut.registerShortcut( 28 28 "menu:Mapillary", tr("Menu: {0}", tr("Mapillary")), 29 KeyEvent.VK_M, Shortcut.ALT_ SHIFT), false);29 KeyEvent.VK_M, Shortcut.ALT_CTRL_SHIFT), false); 30 30 } 31 31 … … 44 44 for (Layer layer : Main.map.mapView.getAllLayers()) { 45 45 if (layer instanceof MapillaryLayer) { 46 System.out.println("Tuturu");47 46 this.layer = (MapillaryLayer) layer; 48 47 } … … 51 50 if (this.layer == null) 52 51 layer = new MapillaryLayer(); 53 else 52 else { 54 53 this.layer.download(); 54 if (Main.map.mapView.getActiveLayer() != layer) 55 Main.map.mapView.setActiveLayer(layer); 56 else 57 Main.map.mapView.setActiveLayer(Main.map.mapView.getEditLayer()); 58 } 55 59 } 56 60 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31164 r31166 7 7 * 8 8 * @author nokutu 9 * 9 * @see MapillarySequence 10 * @see MapillaryData 10 11 */ 11 12 public class MapillaryImage { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImageDisplay.java
r31164 r31166 32 32 33 33 /** The image currently displayed */ 34 private transient Image image = null;34 private transient BufferedImage image = null; 35 35 36 36 /** … … 319 319 } 320 320 repaint(); 321 } 322 323 public BufferedImage getImage() { 324 return this.image; 321 325 } 322 326 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31164 r31166 43 43 MouseListener, DataSetListener, EditLayerChangeListener { 44 44 45 public static Boolean INSTANCED = false; 46 public static CacheAccess<String, BufferedImageCacheEntry> CACHE; 47 45 48 private final MapillaryData mapillaryData; 46 49 private List<Bounds> bounds; 47 50 private MapillaryToggleDialog tgd; 48 public static Boolean INSTANCED = false;49 public static CacheAccess<String, BufferedImageCacheEntry> CACHE;50 51 51 52 public MapillaryLayer() { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31164 r31166 20 20 21 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(); 22 public static final ImageIcon ICON16 = new ImageProvider("icon16.png") 23 .get(); 24 public static final ImageIcon ICON16SELECTED = new ImageProvider( 25 "icon16selected.png").get(); 24 26 public static final int ICON_SIZE = 24; 25 27 26 28 MapillaryDownloadAction downloadAction; 27 29 MapillaryExportAction exportAction; 28 30 29 31 public static JMenuItem DOWNLOAD_MENU; 30 32 public static JMenuItem EXPORT_MENU; … … 35 37 exportAction = new MapillaryExportAction(); 36 38 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 DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, 40 downloadAction, false, 0); 41 EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, 42 false, 14); 39 43 EXPORT_MENU.setEnabled(false); 40 44 … … 47 51 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 48 52 if (oldFrame == null && newFrame != null) { // map frame added 49 MapillaryToggleDialog.deleteInstance ();50 53 } 51 if (oldFrame != null && newFrame == null) { // map frame added52 System.out.println("Mapframe destroyed");54 if (oldFrame != null && newFrame == null) { // map frame destroyed 55 MapillaryToggleDialog.deleteInstance(); 53 56 } 54 57 } 55 58 56 59 public static void setMenuEnabled(JMenuItem menu, boolean value) { 57 60 menu.setEnabled(value); 58 61 } 59 62 } 60 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java
r31164 r31166 8 8 * 9 9 * @author nokutu 10 * @see MapillaryImage 10 11 * 11 12 */ -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java
r31164 r31166 46 46 public MapillaryImageDisplay mapillaryImageDisplay; 47 47 48 private MapillaryCache imageCache; 49 private MapillaryCache thumbnailCache; 50 48 51 final JPanel buttons; 49 52 … … 90 93 CacheAccess<String, BufferedImageCacheEntry> prev; 91 94 try { 95 this.mapillaryImageDisplay.setImage(null); 92 96 prev = JCSCacheManager.getCache("mapillary"); 93 MapillaryCache cache = new MapillaryCache(image.getKey(), 97 if (thumbnailCache != null) 98 thumbnailCache.cancelOutstandingTasks(); 99 thumbnailCache = new MapillaryCache(image.getKey(), 100 MapillaryCache.Type.THUMBNAIL, prev, 200000, 101 200000, new HashMap<String, String>()); 102 thumbnailCache.submit(this, false); 103 104 if (imageCache != null) 105 imageCache.cancelOutstandingTasks(); 106 imageCache = new MapillaryCache(image.getKey(), 94 107 MapillaryCache.Type.FULL_IMAGE, prev, 200000, 95 108 200000, new HashMap<String, String>()); 96 cache.submit(this, false);109 imageCache.submit(this, false); 97 110 } catch (IOException e) { 98 111 // TODO Auto-generated catch block … … 181 194 } 182 195 }); 183 } else {196 } else if (data != null){ 184 197 try { 185 198 BufferedImage img = ImageIO.read(new ByteArrayInputStream(data 186 199 .getContent())); 187 mapillaryImageDisplay.setImage(img); 200 if (this.mapillaryImageDisplay.getImage() == null) 201 mapillaryImageDisplay.setImage(img); 202 else if (img.getHeight() > this.mapillaryImageDisplay 203 .getImage().getHeight()) { 204 mapillaryImageDisplay.setImage(img); 205 } 188 206 } catch (IOException e) { 189 207 // TODO Auto-generated catch block -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java
r31163 r31166 20 20 import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache; 21 21 22 23 22 /** 23 * This is the thread that downloads one of the images that are going to be 24 * exported and writes them in a {@link ArrayBlockQueue}. 25 * 26 * @author nokutu 27 * @see MapillaryExportManager 28 */ 24 29 public class MapillaryExportDownloadThread implements Runnable, 25 30 ICachedLoaderListener { … … 33 38 34 39 public MapillaryExportDownloadThread(MapillaryImage image, 35 ArrayBlockingQueue<BufferedImage> queue, ArrayBlockingQueue<MapillaryImage> queueImages) { 40 ArrayBlockingQueue<BufferedImage> queue, 41 ArrayBlockingQueue<MapillaryImage> queueImages) { 36 42 url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey() 37 43 + "/thumb-2048.jpg"; … … 64 70 queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent()))); 65 71 queueImages.put(image); 66 72 67 73 } catch (InterruptedException e) { 68 74 // TODO Auto-generated catch block … … 72 78 e.printStackTrace(); 73 79 } 74 75 80 } 76 77 81 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java
r31163 r31166 14 14 import org.xml.sax.SAXException; 15 15 16 /** 17 * Export main thread. Exportation works by creating a 18 * {@link MapillaryWriterThread} and several 19 * {@link MapillaryExportDownloadThread}. The second ones download every single 20 * image that is going to be exported and stores them in an 21 * {@link ArrayBlockingQueue}. Then it is picked by the first one and written on 22 * the selected folder. Each image will be named by its key. 23 * 24 * @author nokutu 25 * 26 */ 16 27 public class MapillaryExportManager extends PleaseWaitRunnable { 17 28 18 29 ArrayBlockingQueue<BufferedImage> queue; 19 30 ArrayBlockingQueue<MapillaryImage> queueImages; 20 31 21 32 List<MapillaryImage> images; 22 33 String path; … … 43 54 protected void realRun() throws SAXException, IOException, 44 55 OsmTransferException { 45 Thread writer = new Thread(new MapillaryExportWriterThread(path, queue, queueImages,46 images.size(), this.getProgressMonitor()));56 Thread writer = new Thread(new MapillaryExportWriterThread(path, queue, 57 queueImages, images.size(), this.getProgressMonitor())); 47 58 writer.start(); 48 59 ThreadPoolExecutor ex = new ThreadPoolExecutor(20, 35, 25, … … 50 61 for (MapillaryImage image : images) { 51 62 try { 52 ex.execute(new MapillaryExportDownloadThread(image, queue, queueImages)); 63 ex.execute(new MapillaryExportDownloadThread(image, queue, 64 queueImages)); 53 65 } catch (Exception e) { 54 66 System.out.println("Exception"); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java
r31163 r31166 12 12 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 13 13 14 14 /** 15 * Writes the images from the queue in the HD. 16 * 17 * @author nokutu 18 * @see MapillaryExportManager 19 */ 15 20 public class MapillaryExportWriterThread implements Runnable { 16 21 … … 20 25 private int amount; 21 26 private ProgressMonitor monitor; 22 27 23 28 public MapillaryExportWriterThread(String path, 24 ArrayBlockingQueue<BufferedImage> queue,ArrayBlockingQueue<MapillaryImage> queueImages, int amount, ProgressMonitor monitor) { 29 ArrayBlockingQueue<BufferedImage> queue, 30 ArrayBlockingQueue<MapillaryImage> queueImages, int amount, 31 ProgressMonitor monitor) { 25 32 this.path = path; 26 33 this.queue = queue; … … 51 58 e.printStackTrace(); 52 59 } 53 60 54 61 monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / amount); 55 62 monitor.setCustomText("Downloaded " + (i + 1) + "/" + amount); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31165 r31166 20 20 21 21 /** 22 * This Class downloads all the pictures in a given sequence and creates the 23 * needed MapillaryImage and MapillarySequence objects 22 * This thread downloads all the pictures in a given sequence and creates the 23 * needed MapillaryImage and MapillarySequence objects. It just stores the ones 24 * in the given area. 24 25 * 25 26 * @author nokutu 26 * 27 * @see MapillarySquareDownloadManagarThread 27 28 */ 28 29 public class MapillarySequenceDownloadThread implements Runnable { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31165 r31166 14 14 * 15 15 * @author nokutu 16 * 16 * 17 * @see MapillaryDownloader 17 18 */ 18 19 public class MapillarySquareDownloadManagerThread implements Runnable { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadThread.java
r31165 r31166 15 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 16 16 17 /** 18 * This thread downloads one of the images in a given area. 19 * 20 * @author nokutu 21 * @see MapillarySqueareDownloadManagerThread 22 */ 17 23 public class MapillarySquareDownloadThread implements Runnable { 18 24 String url; … … 32 38 br = new BufferedReader(new InputStreamReader( 33 39 new URL(url).openStream())); 34 /* String jsonLine = "";35 while (br.ready()) {36 jsonLine += br.readLine();37 }*/40 /* 41 * String jsonLine = ""; while (br.ready()) { jsonLine += 42 * br.readLine(); } 43 */ 38 44 JsonObject jsonobj = Json.createReader(br).readObject(); 39 45 if (!jsonobj.getBoolean("more")) { … … 47 53 image = jsonarr.getJsonObject(i); 48 54 images.add(new MapillaryImage(image.getString("key"), image 49 .getJsonNumber("lat") 50 . doubleValue(), image.getJsonNumber("lon").doubleValue(), image55 .getJsonNumber("lat").doubleValue(), image 56 .getJsonNumber("lon").doubleValue(), image 51 57 .getJsonNumber("ca").doubleValue())); 52 58 } catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.