Changeset 31273 in osm for applications/editors/josm
- Timestamp:
- 2015-06-17T14:04:39+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31270 r31273 20 20 import org.openstreetmap.josm.data.coor.LatLon; 21 21 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 22 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 22 23 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 23 24 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 67 68 68 69 private MouseAdapter mouseAdapter; 70 71 int highlightPointRadius = Main.pref.getInteger("mappaint.highlight.radius", 7); 72 private int highlightStep = Main.pref.getInteger("mappaint.highlight.step", 4); 69 73 70 74 public MapillaryLayer() { … … 248 252 } 249 253 } 254 255 /** 256 * Draws the highlight of the icon. 257 * @param g 258 * @param p 259 * @param size 260 */ 261 private void drawPointHighlight(Graphics2D g, Point p, int size) { 262 Color oldColor = g.getColor(); 263 Color highlightColor = PaintColors.HIGHLIGHT.get(); 264 Color highlightColorTransparent = new Color(highlightColor.getRed(), highlightColor.getGreen(), highlightColor.getBlue(), 100); 265 g.setColor(highlightColorTransparent); 266 int s = size + highlightPointRadius; 267 while(s >= size) { 268 int r = (int) Math.floor(s/2d); 269 g.fillRoundRect(p.x-r, p.y-r, s, s, r, r); 270 s -= highlightStep; 271 } 272 g.setColor(oldColor); 273 } 250 274 251 275 /** … … 260 284 private void draw(Graphics2D g, MapillaryAbstractImage image, 261 285 ImageIcon icon, Point p) { 262 draw(g, icon, p, image.getCa());263 if (MapillaryData.getInstance().getHoveredImage() == image) {264 draw(g, MapillaryPlugin.MAP_ICON_HOVER, p, image.getCa());265 }266 }267 268 private void draw(Graphics2D g, ImageIcon icon, Point p, double ca) {269 286 Image imagetemp = icon.getImage(); 270 287 BufferedImage bi = (BufferedImage) imagetemp; … … 273 290 274 291 // Rotate the image 275 double rotationRequired = Math.toRadians( ca);292 double rotationRequired = Math.toRadians(image.getCa()); 276 293 double locationX = width / 2; 277 294 double locationY = height / 2; … … 283 300 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2), 284 301 Main.map.mapView); 285 } 302 if (MapillaryData.getInstance().getHoveredImage() == image) { 303 drawPointHighlight(g, p, 16); 304 } 305 } 306 286 307 287 308 @Override -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java
r31271 r31273 8 8 import org.openstreetmap.josm.Main; 9 9 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 10 12 import org.openstreetmap.josm.plugins.mapillary.commands.CommandMoveImage; 11 13 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage; … … 27 29 private MapillaryRecord record; 28 30 31 private boolean nothingHighlighted; 32 29 33 public MapillaryMouseAdapter() { 30 34 mapillaryData = MapillaryData.getInstance(); … … 37 41 if (e.getButton() != MouseEvent.BUTTON1) 38 42 return; 39 if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance())40 return;41 43 MapillaryAbstractImage closestTemp = getClosest(e.getPoint()); 44 if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closestTemp != null) { 45 this.lastClicked = this.closest; 46 MapillaryData.getInstance().setSelectedImage(closestTemp); 47 return; 48 } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer 49 .getInstance()) 50 return; 42 51 if (closestTemp instanceof MapillaryImage || closestTemp == null) { 43 52 MapillaryImage closest = (MapillaryImage) closestTemp; … … 180 189 public void mouseMoved(MouseEvent e) { 181 190 MapillaryAbstractImage closestTemp = getClosest(e.getPoint()); 191 192 if (closestTemp != null 193 && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer 194 && Main.map.mapModeSelect.getValue("active") == Boolean.TRUE) { 195 Main.map.mapModeSelect.exitMode(); 196 } else if (closestTemp == null 197 && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer 198 && Main.map.mapModeSelect.getValue("active") == Boolean.FALSE) { 199 Main.map.mapModeSelect.enterMode(); 200 nothingHighlighted = false; 201 } else if (Main.map.mapModeSelect.getValue("active") == Boolean.FALSE 202 && !nothingHighlighted) { 203 for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data 204 .allPrimitives()) { 205 primivitive.setHighlighted(false); 206 } 207 nothingHighlighted = true; 208 } 209 182 210 // TODO check if it is possible to do this while the OSM data layer is 183 211 // selected. 184 if (Main.map.mapView.getActiveLayer() instanceof MapillaryLayer 185 && MapillaryData.getInstance().getHoveredImage() != closestTemp 212 if (MapillaryData.getInstance().getHoveredImage() != closestTemp 186 213 && closestTemp != null) { 187 214 MapillaryData.getInstance().setHoveredImage(closestTemp); 188 215 MapillaryToggleDialog.getInstance().setImage(closestTemp); 189 MapillaryData.getInstance().dataUpdated();190 216 MapillaryToggleDialog.getInstance().updateImage(); 191 217 } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp … … 194 220 MapillaryToggleDialog.getInstance().setImage( 195 221 MapillaryData.getInstance().getSelectedImage()); 196 MapillaryData.getInstance().dataUpdated();197 222 MapillaryToggleDialog.getInstance().updateImage(); 198 223 } 224 MapillaryData.getInstance().dataUpdated(); 199 225 } 200 226 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31271 r31273 43 43 public static final ImageIcon MAP_SIGNAL = new ImageProvider("signal.png") 44 44 .get(); 45 public static final ImageIcon MAP_ICON_HOVER = new ImageProvider(46 "hover.png").get();47 45 public static final int ICON_SIZE = 24; 48 46 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java
r31245 r31273 66 66 return false; 67 67 } 68 69 public void cancelOutstandingTasks() {70 // TODO71 }72 68 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryToggleDialog.java
r31272 r31273 70 70 71 71 private JPanel buttonsPanel; 72 private JPanel top;73 72 74 73 public MapillaryImageDisplay mapillaryImageDisplay; … … 128 127 mode = NORMAL_MODE; 129 128 } 130 top = new JPanel(); 131 top.setLayout(new BorderLayout()); 132 top.add(titleBar, BorderLayout.NORTH); 129 133 130 createLayout(mapillaryImageDisplay, list, 134 131 Main.pref.getBoolean("mapillary.reverse-buttons")); … … 204 201 205 202 mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey()); 203 // Downloads the thumbnail. 206 204 this.mapillaryImageDisplay.setImage(null); 207 205 if (thumbnailCache != null) … … 211 209 thumbnailCache.submit(this, false); 212 210 211 // Downloads the full resolution image. 213 212 if (imageCache != null) 214 213 imageCache.cancelOutstandingTasks(); … … 390 389 public void createLayout(Component data, List<SideButton> buttons, 391 390 boolean reverse) { 391 this.removeAll(); 392 392 JPanel panel = new JPanel(); 393 393 panel.setLayout(new BorderLayout()); … … 407 407 } else 408 408 createLayout(panel, true, buttons); 409 this.add(titleBar, BorderLayout.NORTH); 409 410 } 410 411
Note:
See TracChangeset
for help on using the changeset viewer.