Ignore:
Timestamp:
2017-11-19T19:07:47+01:00 (6 years ago)
Author:
Don-vip
Message:

see #15476 - fix checkstyle/pmd warnings, add some javadoc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java

    r13127 r13129  
    6767    private static final BooleanProperty AGPIFO_STYLE2 =
    6868        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;
    7171
    7272    /** Alternative to mouse wheel zoom; esp. handy if no mouse wheel is present **/
     
    8787    private static final BooleanProperty BILIN_UPSAMP =
    8888        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;
    9191
    9292    @Override
    9393    public void preferenceChanged(PreferenceChangeEvent e) {
    9494        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;
    9998        }
    10099        if (e == null ||
    101100            e.getKey().equals(MAX_ZOOM.getKey()) ||
    102101            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     */
    111112    public static class VisRect extends Rectangle {
    112113        private final Rectangle init;
    113114
     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         */
    114122        public VisRect(int x, int y, int width, int height) {
    115123            super(x, y, width, height);
     
    122130        }
    123131
     132        /**
     133         * Constructs a new {@code VisRect} from another one.
     134         * @param v rectangle to copy
     135         */
    124136        public VisRect(VisRect v) {
    125137            super(v);
     
    127139        }
    128140
     141        /**
     142         * Constructs a new empty {@code VisRect}.
     143         */
    129144        public VisRect() {
    130145            this(0, 0, 0, 0);
     
    269284
    270285        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));
    274289        }
    275290
    276291        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));
    280295        }
    281296
     
    636651            double scale = target.width / (double) r.width; // pixel ratio is 1:1
    637652
    638             if (selectedRect == null && BILIN_LOWER < scale && scale < BILIN_UPPER) {
     653            if (selectedRect == null && bilinLower < scale && scale < bilinUpper) {
    639654                BufferedImage bi = ImageProvider.toBufferedImage(image, r);
    640655                r.x = r.y = 0;
Note: See TracChangeset for help on using the changeset viewer.