Changeset 13129 in josm for trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
- Timestamp:
- 2017-11-19T19:07:47+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r13127 r13129 67 67 private static final BooleanProperty AGPIFO_STYLE2 = 68 68 new BooleanProperty("geoimage.agpifo-style-drag-and-zoom", false); 69 private static int DRAG_BUTTON;70 private static int ZOOM_BUTTON;69 private static int dragButton; 70 private static int zoomButton; 71 71 72 72 /** Alternative to mouse wheel zoom; esp. handy if no mouse wheel is present **/ … … 87 87 private static final BooleanProperty BILIN_UPSAMP = 88 88 new BooleanProperty("geoimage.bilinear-upsampling", false); 89 private static double BILIN_UPPER;90 private static double BILIN_LOWER;89 private static double bilinUpper; 90 private static double bilinLower; 91 91 92 92 @Override 93 93 public void preferenceChanged(PreferenceChangeEvent e) { 94 94 if (e == null || 95 e.getKey().equals(AGPIFO_STYLE2.getKey())) 96 { 97 DRAG_BUTTON = AGPIFO_STYLE2.get() ? 1 : 3; 98 ZOOM_BUTTON = DRAG_BUTTON == 1 ? 3 : 1; 95 e.getKey().equals(AGPIFO_STYLE2.getKey())) { 96 dragButton = AGPIFO_STYLE2.get() ? 1 : 3; 97 zoomButton = dragButton == 1 ? 3 : 1; 99 98 } 100 99 if (e == null || 101 100 e.getKey().equals(MAX_ZOOM.getKey()) || 102 101 e.getKey().equals(BILIN_DOWNSAMP.getKey()) || 103 e.getKey().equals(BILIN_UPSAMP.getKey())) 104 { 105 BILIN_UPPER = (BILIN_UPSAMP.get() ? 2*MAX_ZOOM.get() : (BILIN_DOWNSAMP.get() ? 0.5 : 0)); 106 BILIN_LOWER = (BILIN_DOWNSAMP.get() ? 0 : 1); 107 } 108 } 109 110 /** Manage the visible rectangle of an image with full bounds stored in init. **/ 102 e.getKey().equals(BILIN_UPSAMP.getKey())) { 103 bilinUpper = (BILIN_UPSAMP.get() ? 2*MAX_ZOOM.get() : (BILIN_DOWNSAMP.get() ? 0.5 : 0)); 104 bilinLower = (BILIN_DOWNSAMP.get() ? 0 : 1); 105 } 106 } 107 108 /** 109 * Manage the visible rectangle of an image with full bounds stored in init. 110 * @since 13127 111 */ 111 112 public static class VisRect extends Rectangle { 112 113 private final Rectangle init; 113 114 115 /** 116 * Constructs a new {@code VisRect}. 117 * @param x the specified X coordinate 118 * @param y the specified Y coordinate 119 * @param width the width of the rectangle 120 * @param height the height of the rectangle 121 */ 114 122 public VisRect(int x, int y, int width, int height) { 115 123 super(x, y, width, height); … … 122 130 } 123 131 132 /** 133 * Constructs a new {@code VisRect} from another one. 134 * @param v rectangle to copy 135 */ 124 136 public VisRect(VisRect v) { 125 137 super(v); … … 127 139 } 128 140 141 /** 142 * Constructs a new empty {@code VisRect}. 143 */ 129 144 public VisRect() { 130 145 this(0, 0, 0, 0); … … 269 284 270 285 private boolean mouseIsDragging(MouseEvent e) { 271 return ( DRAG_BUTTON== 1 && SwingUtilities.isLeftMouseButton(e)) ||272 ( DRAG_BUTTON== 2 && SwingUtilities.isMiddleMouseButton(e)) ||273 ( DRAG_BUTTON== 3 && SwingUtilities.isRightMouseButton(e));286 return (dragButton == 1 && SwingUtilities.isLeftMouseButton(e)) || 287 (dragButton == 2 && SwingUtilities.isMiddleMouseButton(e)) || 288 (dragButton == 3 && SwingUtilities.isRightMouseButton(e)); 274 289 } 275 290 276 291 private boolean mouseIsZoomSelecting(MouseEvent e) { 277 return ( ZOOM_BUTTON== 1 && SwingUtilities.isLeftMouseButton(e)) ||278 ( ZOOM_BUTTON== 2 && SwingUtilities.isMiddleMouseButton(e)) ||279 ( ZOOM_BUTTON== 3 && SwingUtilities.isRightMouseButton(e));292 return (zoomButton == 1 && SwingUtilities.isLeftMouseButton(e)) || 293 (zoomButton == 2 && SwingUtilities.isMiddleMouseButton(e)) || 294 (zoomButton == 3 && SwingUtilities.isRightMouseButton(e)); 280 295 } 281 296 … … 636 651 double scale = target.width / (double) r.width; // pixel ratio is 1:1 637 652 638 if (selectedRect == null && BILIN_LOWER < scale && scale < BILIN_UPPER) {653 if (selectedRect == null && bilinLower < scale && scale < bilinUpper) { 639 654 BufferedImage bi = ImageProvider.toBufferedImage(image, r); 640 655 r.x = r.y = 0;
Note:
See TracChangeset
for help on using the changeset viewer.