Changeset 31173 in osm for applications/editors
- Timestamp:
- 2015-06-01T18:53:50+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDownloadAction.java
r31166 r31173 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 import org.openstreetmap.josm.tools.ImageProvider; 14 15 import org.openstreetmap.josm.tools.Shortcut; 15 16 … … 24 25 25 26 public MapillaryDownloadAction() { 26 super(tr("Mapillary"), "icon16.png",27 super(tr("Mapillary"), new ImageProvider("icon24.png"), 27 28 tr("Create Mapillary layer."), Shortcut.registerShortcut( 28 29 "menu:Mapillary", tr("Menu: {0}", tr("Mapillary")), 29 KeyEvent.VK_M, Shortcut.ALT_CTRL_SHIFT), false );30 KeyEvent.VK_M, Shortcut.ALT_CTRL_SHIFT), false, "mapillaryDownload", false); 30 31 } 31 32 … … 51 52 layer = new MapillaryLayer(); 52 53 else { 53 this.layer.download();54 54 if (Main.map.mapView.getActiveLayer() != layer) 55 55 Main.map.mapView.setActiveLayer(layer); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java
r31168 r31173 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 14 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryExportManager; 15 import org.openstreetmap.josm.tools.ImageProvider; 15 16 16 17 /** … … 25 26 26 27 public MapillaryExportAction() { 27 super(tr("Export images"), "icon24.png", tr("Export images."), null,28 false);28 super(tr("Export images"), new ImageProvider("icon24.png"), 29 tr("Export images."), null, false, "mapillaryExport", false); 29 30 } 30 31 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31170 r31173 30 30 import java.awt.Color; 31 31 import java.awt.Graphics2D; 32 import java.awt.Image; 32 33 import java.awt.Point; 33 34 import java.awt.event.MouseEvent; 34 35 import java.awt.event.MouseListener; 36 import java.awt.geom.AffineTransform; 37 import java.awt.image.AffineTransformOp; 38 import java.awt.image.BufferedImage; 35 39 import java.io.IOException; 36 40 … … 46 50 47 51 public static Boolean INSTANCED = false; 52 public static MapillaryLayer INSTANCE; 48 53 public static CacheAccess<String, BufferedImageCacheEntry> CACHE; 49 54 public static MapillaryImage BLUE; … … 66 71 private void init() { 67 72 INSTANCED = true; 73 MapillaryLayer.INSTANCE = this; 68 74 try { 69 75 CACHE = JCSCacheManager.getCache("Mapillary"); … … 89 95 } 90 96 97 public static MapillaryLayer getInstance() { 98 if (MapillaryLayer.INSTANCE == null) 99 MapillaryLayer.INSTANCE = new MapillaryLayer(); 100 return MapillaryLayer.INSTANCE; 101 } 102 91 103 /** 92 104 * Downloads all images of the area covered by the OSM data. … … 120 132 .setImage(null); 121 133 INSTANCED = false; 134 MapillaryLayer.INSTANCE = null; 122 135 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false); 123 136 MapillaryData.deleteInstance(); 124 137 Main.map.mapView.removeMouseListener(this); 125 138 MapView.removeEditLayerChangeListener(this); 126 Main.map.mapView.getEditLayer().data.removeDataSetListener(this); 139 if (Main.map.mapView.getEditLayer() != null) 140 Main.map.mapView.getEditLayer().data.removeDataSetListener(this); 127 141 super.destroy(); 128 142 } … … 148 162 synchronized (this) { 149 163 // Draw colored lines 150 this.BLUE = null;151 this.RED = null;164 MapillaryLayer.BLUE = null; 165 MapillaryLayer.RED = null; 152 166 MapillaryToggleDialog.getInstance().blueButton.setEnabled(false); 153 167 MapillaryToggleDialog.getInstance().redButton.setEnabled(false); … … 157 171 .getLatLon()); 158 172 if (closestImages[0] != null) { 159 this.BLUE = closestImages[0];173 MapillaryLayer.BLUE = closestImages[0]; 160 174 g.setColor(Color.BLUE); 161 175 g.drawLine(mv.getPoint(closestImages[0].getLatLon()).x, 162 176 mv.getPoint(closestImages[0].getLatLon()).y, 163 177 selected.x, selected.y); 164 MapillaryToggleDialog.getInstance().blueButton.setEnabled(true); 178 MapillaryToggleDialog.getInstance().blueButton 179 .setEnabled(true); 165 180 } 166 181 if (closestImages[1] != null) { 167 this.RED = closestImages[1];182 MapillaryLayer.RED = closestImages[1]; 168 183 g.setColor(Color.RED); 169 184 g.drawLine(mv.getPoint(closestImages[1].getLatLon()).x, 170 185 mv.getPoint(closestImages[1].getLatLon()).y, 171 186 selected.x, selected.y); 172 MapillaryToggleDialog.getInstance().redButton.setEnabled(true); 187 MapillaryToggleDialog.getInstance().redButton 188 .setEnabled(true); 173 189 } 174 190 } … … 185 201 ImageIcon icon; 186 202 if (!mapillaryData.getMultiSelectedImages().contains(image)) 187 icon = MapillaryPlugin. ICON16;203 icon = MapillaryPlugin.MAP_ICON; 188 204 else 189 icon = MapillaryPlugin.ICON16SELECTED; 205 icon = MapillaryPlugin.MAP_ICON_SELECTED; 206 Image imagetemp = icon.getImage(); 207 BufferedImage bi = (BufferedImage) imagetemp; 190 208 int width = icon.getIconWidth(); 191 209 int height = icon.getIconHeight(); 192 g.drawImage(icon.getImage(), p.x - (width / 2), p.y 193 - (height / 2), Main.map.mapView); 210 211 // Rotate the image 212 double rotationRequired = Math.toRadians(image.getCa()); 213 double locationX = width / 2; 214 double locationY = height / 2; 215 AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY); 216 AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); 217 218 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2), 219 Main.map.mapView); 220 194 221 } 195 222 } … … 326 353 } 327 354 328 // DataSetListener 329 355 /** 356 * When more data is downloaded, a delayed update is thrown, in order to 357 * wait for the data bounds to be set. 358 * 359 * @param event 360 */ 330 361 @Override 331 362 public void dataChanged(DataChangedEvent event) { 363 Main.worker.submit(new delayedDownload()); 364 } 365 366 private class delayedDownload extends Thread { 367 368 @Override 369 public void run() { 370 try { 371 sleep(1000); 372 } catch (InterruptedException e) { 373 // TODO Auto-generated catch block 374 e.printStackTrace(); 375 } 376 MapillaryLayer.getInstance().download(); 377 } 378 332 379 } 333 380 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31170 r31173 19 19 public class MapillaryPlugin extends Plugin { 20 20 21 public static final ImageIcon ICON = new ImageProvider("icon24.png").get(); 21 public static final ImageIcon ICON24 = new ImageProvider("icon24.png") 22 .get(); 22 23 public static final ImageIcon ICON16 = new ImageProvider("icon16.png") 23 24 .get(); 24 public static final ImageIcon ICON16SELECTED = new ImageProvider( 25 "icon16selected.png").get(); 25 public static final ImageIcon MAP_ICON = new ImageProvider("mapicon.png") 26 .get(); 27 public static final ImageIcon MAP_ICON_SELECTED = new ImageProvider( 28 "mapiconselected.png").get(); 26 29 public static final int ICON_SIZE = 24; 27 30 … … 32 35 public static JMenuItem EXPORT_MENU; 33 36 37 public static String DIR; 38 34 39 public MapillaryPlugin(PluginInformation info) { 35 40 super(info); … … 37 42 exportAction = new MapillaryExportAction(); 38 43 39 DOWNLOAD_MENU = MainMenu 40 .add(Main.main.menu.imageryMenu,downloadAction, false);44 DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, 45 downloadAction, false); 41 46 EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, 42 47 false, 14); 43 48 EXPORT_MENU.setEnabled(false); 49 MapillaryPlugin.DIR = this.getPluginDir(); 44 50 45 51 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java
r31170 r31173 192 192 class redAction extends AbstractAction { 193 193 public redAction() { 194 putValue(NAME, " Red");194 putValue(NAME, "Jump to red"); 195 195 putValue(SHORT_DESCRIPTION, 196 196 tr("Shows the previous picture in the sequence")); … … 211 211 class blueAction extends AbstractAction { 212 212 public blueAction() { 213 putValue(NAME, " Blue");213 putValue(NAME, "Jump to blue"); 214 214 putValue(SHORT_DESCRIPTION, 215 215 tr("Shows the previous picture in the sequence"));
Note:
See TracChangeset
for help on using the changeset viewer.