Changeset 32915 in osm


Ignore:
Timestamp:
2016-09-03T17:11:07+02:00 (8 years ago)
Author:
donvip
Message:

fix error-prone warnings

Location:
applications/editors/josm/plugins/imagewaypoint
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java

    r32288 r32915  
    2222        }
    2323
     24        @Override
    2425        public final void onImageReady(final ImageEntry imageEntry,
    2526            final Image image) {
  • applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntry.java

    r16294 r32915  
    2323public final class ImageEntry implements Comparable<ImageEntry> {
    2424    public interface IImageReadyListener {
    25     void onImageReady(ImageEntry imageEntry, Image image);
     25        void onImageReady(ImageEntry imageEntry, Image image);
    2626    }
    2727
    2828    private static final class Observer implements ImageObserver {
    29     private final ImageEntry imageEntry;
    30 
    31     public Observer(final ImageEntry imageEntry) {
    32         this.imageEntry = imageEntry;
    33     }
    34 
    35     /**
    36      * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int,
    37      *      int, int, int, int)
    38      * @return true if this ImageObserver still wants to be updates about
    39      *         image loading progress
    40      */
    41     public final boolean imageUpdate(final Image image,
    42         final int infoflags, final int x, final int y, final int width,
    43         final int height) {
    44         final boolean complete = ImageObserver.ALLBITS == (infoflags | ImageObserver.ALLBITS);
    45         if (complete) {
    46         this.imageEntry.imageLoaded(image);
    47         }
    48 
    49         return !complete;
    50     }
     29        private final ImageEntry imageEntry;
     30
     31        public Observer(final ImageEntry imageEntry) {
     32            this.imageEntry = imageEntry;
     33        }
     34
     35        /**
     36         * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int,
     37         *      int, int, int, int)
     38         * @return true if this ImageObserver still wants to be updates about
     39         *         image loading progress
     40         */
     41        @Override
     42        public final boolean imageUpdate(final Image image,
     43            final int infoflags, final int x, final int y, final int width,
     44            final int height) {
     45            final boolean complete = ImageObserver.ALLBITS == (infoflags | ImageObserver.ALLBITS);
     46            if (complete) {
     47                this.imageEntry.imageLoaded(image);
     48            }
     49
     50            return !complete;
     51        }
    5152    }
    5253
     
    119120    }
    120121
     122    @Override
    121123    public final int compareTo(final ImageEntry image) {
    122124    return this.fileName.compareTo(image.fileName);
  • applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointDialog.java

    r30701 r32915  
    2222public final class ImageWayPointDialog {
    2323    private static final class ImageComponent extends JComponent {
    24     private static final long serialVersionUID = -5207198660736375133L;
    25 
    26     private Image image;
    27 
    28     public ImageComponent() {
    29         this.image = null;
    30     }
    31 
    32     @Override
    33     public final void paint(final Graphics g) {
    34         if (null == this.image || 0 >= this.image.getWidth(null)
    35             || 0 >= this.image.getHeight(null)) {
    36         g.setColor(Color.white);
    37         g.fillRect(0, 0, this.getSize().width, this.getSize().height);
    38         } else {
    39         final int maxWidth = this.getSize().width;
    40         final int maxHeight = this.getSize().height;
    41         final int imageWidth = this.image.getWidth(null);
    42         final int imageHeight = this.image.getHeight(null);
    43 
    44         final double aspect = 1.0 * imageWidth / imageHeight;
    45 
    46         // what's the width if the height is 100%?
    47         final int widthIfHeightIsMax = (int) (aspect * maxHeight);
    48 
    49         // now find the real width and height
    50         final int resizedWidth;
    51         final int resizedHeight;
    52         if (widthIfHeightIsMax > maxWidth) {
    53             // oops - burst the width - so width should be the max, and
    54             // work out the resulting height
    55             resizedWidth = maxWidth;
    56             resizedHeight = (int) (resizedWidth / aspect);
    57         } else {
    58             // that'll do...
    59             resizedWidth = widthIfHeightIsMax;
    60             resizedHeight = maxHeight;
    61         }
    62 
    63         g.drawImage(this.image,
    64             (maxWidth - resizedWidth) / 2,
    65             (maxHeight - resizedHeight) / 2,
    66             resizedWidth,
    67             resizedHeight,
    68             Color.black,
    69             null);
    70         }
    71     }
    72 
    73     public final void setImage(final Image image) {
    74         this.image = image;
    75         this.repaint();
    76     }
     24        private static final long serialVersionUID = -5207198660736375133L;
     25
     26        private Image image;
     27
     28        public ImageComponent() {
     29            this.image = null;
     30        }
     31
     32        @Override
     33        public final void paint(final Graphics g) {
     34            if (null == this.image || 0 >= this.image.getWidth(null)
     35                || 0 >= this.image.getHeight(null)) {
     36            g.setColor(Color.white);
     37            g.fillRect(0, 0, this.getSize().width, this.getSize().height);
     38            } else {
     39            final int maxWidth = this.getSize().width;
     40            final int maxHeight = this.getSize().height;
     41            final int imageWidth = this.image.getWidth(null);
     42            final int imageHeight = this.image.getHeight(null);
     43
     44            final double aspect = 1.0 * imageWidth / imageHeight;
     45
     46            // what's the width if the height is 100%?
     47            final int widthIfHeightIsMax = (int) (aspect * maxHeight);
     48
     49            // now find the real width and height
     50            final int resizedWidth;
     51            final int resizedHeight;
     52            if (widthIfHeightIsMax > maxWidth) {
     53                // oops - burst the width - so width should be the max, and
     54                // work out the resulting height
     55                resizedWidth = maxWidth;
     56                resizedHeight = (int) (resizedWidth / aspect);
     57            } else {
     58                // that'll do...
     59                resizedWidth = widthIfHeightIsMax;
     60                resizedHeight = maxHeight;
     61            }
     62
     63            g.drawImage(this.image,
     64                (maxWidth - resizedWidth) / 2,
     65                (maxHeight - resizedHeight) / 2,
     66                resizedWidth,
     67                resizedHeight,
     68                Color.black,
     69                null);
     70            }
     71        }
     72
     73        public final void setImage(final Image image) {
     74            this.image = image;
     75            this.repaint();
     76        }
    7777    }
    7878
    7979    private static final class ImageChangeListener implements
    8080        IImageChangeListener {
    81     private final ImageWayPointDialog dialog;
    82 
    83     public ImageChangeListener(final ImageWayPointDialog dialog) {
    84         this.dialog = dialog;
    85     }
    86 
    87     public final void onAvailableImageEntriesChanged(
    88         final ImageEntries entries) {
    89         this.dialog.imageDisplay.setImage(entries.getCurrentImage());
    90         this.dialog.updateUI();
    91     }
    92 
    93     public final void onSelectedImageEntryChanged(final ImageEntries entries) {
    94         this.dialog.imageDisplay.setImage(entries.getCurrentImage());
    95         this.dialog.updateUI();
    96     }
     81        private final ImageWayPointDialog dialog;
     82
     83        public ImageChangeListener(final ImageWayPointDialog dialog) {
     84            this.dialog = dialog;
     85        }
     86
     87        @Override
     88        public final void onAvailableImageEntriesChanged(
     89            final ImageEntries entries) {
     90            this.dialog.imageDisplay.setImage(entries.getCurrentImage());
     91            this.dialog.updateUI();
     92        }
     93
     94        @Override
     95        public final void onSelectedImageEntryChanged(final ImageEntries entries) {
     96            this.dialog.imageDisplay.setImage(entries.getCurrentImage());
     97            this.dialog.updateUI();
     98        }
    9799    }
    98100
     
    107109    }
    108110
     111    @Override
    109112    public final void actionPerformed(final ActionEvent actionEvent) {
    110113        if (ImageEntries.getInstance().hasPrevious()) {
     
    120123    }
    121124
     125    @Override
    122126    public final void actionPerformed(final ActionEvent actionEvent) {
    123127        if (ImageEntries.getInstance().hasNext()) {
     
    137141    }
    138142
     143    @Override
    139144    public final void actionPerformed(final ActionEvent actionEvent) {
    140145        ImageEntries.getInstance().rotateCurrentImageLeft();
     
    152157    }
    153158
     159    @Override
    154160    public final void actionPerformed(final ActionEvent actionEvent) {
    155161        ImageEntries.getInstance().rotateCurrentImageRight();
  • applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointLayer.java

    r32499 r32915  
    5252
    5353    private static final class ImageChangeListener implements IImageChangeListener {
     54        @Override
    5455        public final void onAvailableImageEntriesChanged(
    5556        final ImageEntries entries) {
     
    5758        }
    5859
     60        @Override
    5961        public final void onSelectedImageEntryChanged(final ImageEntries entries) {
    6062            Main.map.repaint();
Note: See TracChangeset for help on using the changeset viewer.