Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java =================================================================== --- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java (revision 13128) +++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java (revision 13129) @@ -67,6 +67,6 @@ private static final BooleanProperty AGPIFO_STYLE2 = new BooleanProperty("geoimage.agpifo-style-drag-and-zoom", false); - private static int DRAG_BUTTON; - private static int ZOOM_BUTTON; + private static int dragButton; + private static int zoomButton; /** Alternative to mouse wheel zoom; esp. handy if no mouse wheel is present **/ @@ -87,29 +87,37 @@ private static final BooleanProperty BILIN_UPSAMP = new BooleanProperty("geoimage.bilinear-upsampling", false); - private static double BILIN_UPPER; - private static double BILIN_LOWER; + private static double bilinUpper; + private static double bilinLower; @Override public void preferenceChanged(PreferenceChangeEvent e) { if (e == null || - e.getKey().equals(AGPIFO_STYLE2.getKey())) - { - DRAG_BUTTON = AGPIFO_STYLE2.get() ? 1 : 3; - ZOOM_BUTTON = DRAG_BUTTON == 1 ? 3 : 1; + e.getKey().equals(AGPIFO_STYLE2.getKey())) { + dragButton = AGPIFO_STYLE2.get() ? 1 : 3; + zoomButton = dragButton == 1 ? 3 : 1; } if (e == null || e.getKey().equals(MAX_ZOOM.getKey()) || e.getKey().equals(BILIN_DOWNSAMP.getKey()) || - e.getKey().equals(BILIN_UPSAMP.getKey())) - { - BILIN_UPPER = (BILIN_UPSAMP.get() ? 2*MAX_ZOOM.get() : (BILIN_DOWNSAMP.get() ? 0.5 : 0)); - BILIN_LOWER = (BILIN_DOWNSAMP.get() ? 0 : 1); - } - } - - /** Manage the visible rectangle of an image with full bounds stored in init. **/ + e.getKey().equals(BILIN_UPSAMP.getKey())) { + bilinUpper = (BILIN_UPSAMP.get() ? 2*MAX_ZOOM.get() : (BILIN_DOWNSAMP.get() ? 0.5 : 0)); + bilinLower = (BILIN_DOWNSAMP.get() ? 0 : 1); + } + } + + /** + * Manage the visible rectangle of an image with full bounds stored in init. + * @since 13127 + */ public static class VisRect extends Rectangle { private final Rectangle init; + /** + * Constructs a new {@code VisRect}. + * @param x the specified X coordinate + * @param y the specified Y coordinate + * @param width the width of the rectangle + * @param height the height of the rectangle + */ public VisRect(int x, int y, int width, int height) { super(x, y, width, height); @@ -122,4 +130,8 @@ } + /** + * Constructs a new {@code VisRect} from another one. + * @param v rectangle to copy + */ public VisRect(VisRect v) { super(v); @@ -127,4 +139,7 @@ } + /** + * Constructs a new empty {@code VisRect}. + */ public VisRect() { this(0, 0, 0, 0); @@ -269,13 +284,13 @@ private boolean mouseIsDragging(MouseEvent e) { - return (DRAG_BUTTON == 1 && SwingUtilities.isLeftMouseButton(e)) || - (DRAG_BUTTON == 2 && SwingUtilities.isMiddleMouseButton(e)) || - (DRAG_BUTTON == 3 && SwingUtilities.isRightMouseButton(e)); + return (dragButton == 1 && SwingUtilities.isLeftMouseButton(e)) || + (dragButton == 2 && SwingUtilities.isMiddleMouseButton(e)) || + (dragButton == 3 && SwingUtilities.isRightMouseButton(e)); } private boolean mouseIsZoomSelecting(MouseEvent e) { - return (ZOOM_BUTTON == 1 && SwingUtilities.isLeftMouseButton(e)) || - (ZOOM_BUTTON == 2 && SwingUtilities.isMiddleMouseButton(e)) || - (ZOOM_BUTTON == 3 && SwingUtilities.isRightMouseButton(e)); + return (zoomButton == 1 && SwingUtilities.isLeftMouseButton(e)) || + (zoomButton == 2 && SwingUtilities.isMiddleMouseButton(e)) || + (zoomButton == 3 && SwingUtilities.isRightMouseButton(e)); } @@ -636,5 +651,5 @@ double scale = target.width / (double) r.width; // pixel ratio is 1:1 - if (selectedRect == null && BILIN_LOWER < scale && scale < BILIN_UPPER) { + if (selectedRect == null && bilinLower < scale && scale < bilinUpper) { BufferedImage bi = ImageProvider.toBufferedImage(image, r); r.x = r.y = 0; Index: trunk/src/org/openstreetmap/josm/tools/ImageProvider.java =================================================================== --- trunk/src/org/openstreetmap/josm/tools/ImageProvider.java (revision 13128) +++ trunk/src/org/openstreetmap/josm/tools/ImageProvider.java (revision 13129) @@ -617,12 +617,9 @@ * implementation, which adds support for HiDPI displays. The effect will be * that in HiDPI mode, when GUI elements are scaled by a factor 1.5, 2.0, etc., - * the images are not just up-scaled, but a higher resolution version of the - * image is rendered instead. + * the images are not just up-scaled, but a higher resolution version of the image is rendered instead. *
- * Use {@link HiDPISupport#getBaseImage(java.awt.Image)} to extract the original - * image from a multi-resolution image. + * Use {@link HiDPISupport#getBaseImage(java.awt.Image)} to extract the original image from a multi-resolution image. *
- * See {@link HiDPISupport#processMRImage} for how to process the image without
- * removing the multi-resolution magic.
+ * See {@link HiDPISupport#processMRImage} for how to process the image without removing the multi-resolution magic.
* @param multiResolution true, if multi-resolution image is requested
* @return the current object, for convenience
@@ -821,5 +818,4 @@
// This method is called from different thread and modifying HashMap concurrently can result
// for example in loops in map entries (ie freeze when such entry is retrieved)
- // Yes, it did happen to me :-)
if (name == null)
return null;
@@ -911,6 +907,5 @@
// and redundant when you have a whole ton of objects. So,
// index the cache by the name of the icon we're looking for
- // and don't bother to create a URL unless we're actually
- // creating the image.
+ // and don't bother to create a URL unless we're actually creating the image.
URL path = getImageUrl(fullName);
if (path == null) {
@@ -1618,6 +1613,5 @@
* has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color.
*
- * @return a BufferedImage
containing the decoded
- * contents of the input, or null
.
+ * @return a BufferedImage
containing the decoded contents of the input, or null
.
*
* @throws IllegalArgumentException if input
is null
.
@@ -1673,6 +1667,5 @@
* has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color.
*
- * @return a BufferedImage
containing the decoded
- * contents of the input, or null
.
+ * @return a BufferedImage
containing the decoded contents of the input, or null
.
*
* @throws IllegalArgumentException if input
is null
.
@@ -1717,6 +1710,5 @@
* has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color.
*
- * @return a BufferedImage
containing the decoded
- * contents of the input, or null
.
+ * @return a BufferedImage
containing the decoded contents of the input, or null
.
*
* @throws IllegalArgumentException if input
is null
.
@@ -1987,14 +1979,10 @@
public static BufferedImage toBufferedImage(Image image, Rectangle crop_area) {
BufferedImage buffImage = null;
-
Rectangle r = new Rectangle(image.getWidth(null), image.getHeight(null));
if (r.intersection(crop_area).equals(crop_area)) {
buffImage = new BufferedImage(crop_area.width, crop_area.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = buffImage.createGraphics();
- g2.drawImage(image,
- 0, 0, crop_area.width, crop_area.height,
- crop_area.x, crop_area.y,
- crop_area.x + crop_area.width, crop_area.y + crop_area.height,
- null);
+ g2.drawImage(image, 0, 0, crop_area.width, crop_area.height,
+ crop_area.x, crop_area.y, crop_area.x + crop_area.width, crop_area.y + crop_area.height, null);
g2.dispose();
}