Changeset 31270 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-06-16T13:36:43+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31266 r31270 24 24 private final List<MapillaryAbstractImage> images; 25 25 private MapillaryAbstractImage selectedImage; 26 private MapillaryAbstractImage hoveredImage; 26 27 private final List<MapillaryAbstractImage> multiSelectedImages; 27 28 … … 86 87 addWithoutUpdate(image); 87 88 } 89 } 90 91 /** 92 * Sets the image under the mouse cursor. 93 * 94 * @param image 95 */ 96 public void setHoveredImage(MapillaryAbstractImage image) { 97 hoveredImage = image; 98 } 99 100 /** 101 * Returns the image under the mouse cursor. 102 * 103 * @return 104 */ 105 public MapillaryAbstractImage getHoveredImage() { 106 return hoveredImage; 88 107 } 89 108 … … 212 231 } 213 232 214 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) { 233 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, 234 MapillaryAbstractImage newImage) { 215 235 if (listeners.isEmpty()) 216 236 return; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31267 r31270 16 16 /** Unique identifier of the object */ 17 17 private final String key; 18 /** Sequence of pictures containing this */18 /** Sequence of pictures containing this object*/ 19 19 private MapillarySequence sequence; 20 20 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31266 r31270 229 229 else 230 230 icon = MapillaryPlugin.MAP_ICON_SELECTED; 231 Image imagetemp = icon.getImage(); 232 BufferedImage bi = (BufferedImage) imagetemp; 233 int width = icon.getIconWidth(); 234 int height = icon.getIconHeight(); 235 236 // Rotate the image 237 double rotationRequired = Math.toRadians(image.getCa()); 238 double locationX = width / 2; 239 double locationY = height / 2; 240 AffineTransform tx = AffineTransform.getRotateInstance( 241 rotationRequired, locationX, locationY); 242 AffineTransformOp op = new AffineTransformOp(tx, 243 AffineTransformOp.TYPE_BILINEAR); 244 245 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y 246 - (height / 2), Main.map.mapView); 231 draw(g, image, icon, p); 247 232 if (!image.getSignals().isEmpty()) { 248 233 g.drawImage(MapillaryPlugin.MAP_SIGNAL.getImage(), p.x 249 + width / 2, p.y - height / 2, 234 + icon.getIconWidth() / 2, 235 p.y - icon.getIconHeight() / 2, 250 236 Main.map.mapView); 251 237 } … … 257 243 else 258 244 icon = MapillaryPlugin.MAP_ICON_SELECTED; 259 Image imagetemp = icon.getImage(); 260 BufferedImage bi = (BufferedImage) imagetemp; 261 int width = icon.getIconWidth(); 262 int height = icon.getIconHeight(); 263 264 // Rotate the image 265 double rotationRequired = Math.toRadians(image.getCa()); 266 double locationX = width / 2; 267 double locationY = height / 2; 268 AffineTransform tx = AffineTransform.getRotateInstance( 269 rotationRequired, locationX, locationY); 270 AffineTransformOp op = new AffineTransformOp(tx, 271 AffineTransformOp.TYPE_BILINEAR); 272 273 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y 274 - (height / 2), Main.map.mapView); 245 draw(g, image, icon, p); 275 246 } 276 247 } 277 248 } 249 } 250 251 /** 252 * Draws the given icon of an image. Also checks if the mouse is over the 253 * image. 254 * 255 * @param g 256 * @param image 257 * @param icon 258 * @param p 259 */ 260 private void draw(Graphics2D g, MapillaryAbstractImage image, 261 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 Image imagetemp = icon.getImage(); 270 BufferedImage bi = (BufferedImage) imagetemp; 271 int width = icon.getIconWidth(); 272 int height = icon.getIconHeight(); 273 274 // Rotate the image 275 double rotationRequired = Math.toRadians(ca); 276 double locationX = width / 2; 277 double locationY = height / 2; 278 AffineTransform tx = AffineTransform.getRotateInstance( 279 rotationRequired, locationX, locationY); 280 AffineTransformOp op = new AffineTransformOp(tx, 281 AffineTransformOp.TYPE_BILINEAR); 282 283 g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2), 284 Main.map.mapView); 278 285 } 279 286 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java
r31264 r31270 11 11 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage; 12 12 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord; 13 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryToggleDialog; 13 14 14 15 /** … … 84 85 .subList(j, i + 1))); 85 86 } 86 // click87 // click 87 88 } else 88 89 mapillaryData.setSelectedImage(closest); 89 // If you select an imported image90 // If you select an imported image 90 91 } else if (closestTemp instanceof MapillaryImportedImage) { 91 92 MapillaryImportedImage closest = (MapillaryImportedImage) closestTemp; … … 173 174 } 174 175 176 /** 177 * Checks if the mouse is over pictures. 178 */ 179 @Override 180 public void mouseMoved(MouseEvent e) { 181 MapillaryAbstractImage closestTemp = getClosest(e.getPoint()); 182 183 if (Main.map.mapView.getActiveLayer() instanceof MapillaryLayer 184 && MapillaryData.getInstance().getHoveredImage() != closestTemp 185 && closestTemp != null) { 186 MapillaryData.getInstance().setHoveredImage(closestTemp); 187 MapillaryToggleDialog.getInstance().setImage(closestTemp); 188 MapillaryData.getInstance().dataUpdated(); 189 MapillaryToggleDialog.getInstance().updateImage(); 190 } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp 191 && closestTemp == null) { 192 MapillaryData.getInstance().setHoveredImage(null); 193 MapillaryToggleDialog.getInstance().setImage( 194 MapillaryData.getInstance().getSelectedImage()); 195 MapillaryData.getInstance().dataUpdated(); 196 MapillaryToggleDialog.getInstance().updateImage(); 197 } 198 } 175 199 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31268 r31270 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("hover.png").get(); 45 46 public static final int ICON_SIZE = 24; 46 47
Note:
See TracChangeset
for help on using the changeset viewer.