Changeset 32977 in osm


Ignore:
Timestamp:
2016-09-11T13:47:49+02:00 (8 years ago)
Author:
nokutu
Message:

More FindBugs

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySign.java

    r32974 r32977  
    3232      try (
    3333        BufferedReader br = new BufferedReader(new InputStreamReader(
    34           MapillarySign.class.getResourceAsStream("/data/signs/" + country + ".cson")
     34          MapillarySign.class.getResourceAsStream("/data/signs/" + country + ".cson"), "UTF-8"
    3535        ));
    3636      ) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java

    r32690 r32977  
    1818 *
    1919 * @author nokutu
    20  *
    2120 */
    2221public class WalkThread extends Thread implements MapillaryDataListener {
     
    3332   * Main constructor.
    3433   *
    35    * @param interval
    36    *          How often the images switch.
    37    * @param waitForPicture
    38    *          If it must wait for the full resolution picture or just the
    39    *          thumbnail.
    40    * @param followSelected
    41    *          Zoom to each image that is selected.
    42    * @param goForward
    43    *          true to go forward; false to go backwards.
     34   * @param interval How often the images switch.
     35   * @param waitForPicture If it must wait for the full resolution picture or just the
     36   * thumbnail.
     37   * @param followSelected Zoom to each image that is selected.
     38   * @param goForward true to go forward; false to go backwards.
    4439   */
    4540  public WalkThread(int interval, boolean waitForPicture,
    46       boolean followSelected, boolean goForward) {
     41                    boolean followSelected, boolean goForward) {
    4742    this.interval = interval;
    4843    this.waitForFullQuality = waitForPicture;
     
    6762        }
    6863        try {
    69           synchronized (this) {
    70             // Waits for full quality picture.
    71             final BufferedImage displayImage = MapillaryMainDialog.getInstance().mapillaryImageDisplay.getImage();
    72             if (this.waitForFullQuality && image instanceof MapillaryImage) {
    73               while (displayImage == this.lastImage || displayImage == null || displayImage.getWidth() < 2048) {
    74                 wait(100);
    75               }
    76             } else { // Waits for thumbnail.
    77               while (displayImage == this.lastImage || displayImage == null || displayImage.getWidth() < 320) {
    78                 wait(100);
    79               }
     64          // Waits for full quality picture.
     65          final BufferedImage displayImage = MapillaryMainDialog.getInstance().mapillaryImageDisplay.getImage();
     66          if (this.waitForFullQuality && image instanceof MapillaryImage) {
     67            while (displayImage == this.lastImage || displayImage == null || displayImage.getWidth() < 2048) {
     68              Thread.sleep(100);
    8069            }
    81             while (this.paused) {
    82               wait(100);
    83             }
    84             wait(this.interval);
    85             while (this.paused) {
    86               wait(100);
     70          } else { // Waits for thumbnail.
     71            while (displayImage == this.lastImage || displayImage == null || displayImage.getWidth() < 320) {
     72              Thread.sleep(100);
    8773            }
    8874          }
     75          while (this.paused) {
     76            Thread.sleep(100);
     77          }
     78          wait(this.interval);
     79          while (this.paused) {
     80            Thread.sleep(100);
     81          }
    8982          this.lastImage = MapillaryMainDialog.getInstance().mapillaryImageDisplay.getImage();
    90           synchronized (this) {
    91             if (this.goForward) {
    92               this.data.selectNext(this.followSelected);
    93             } else {
    94               this.data.selectPrevious(this.followSelected);
    95             }
     83          if (this.goForward) {
     84            this.data.selectNext(this.followSelected);
     85          } else {
     86            this.data.selectPrevious(this.followSelected);
    9687          }
    9788        } catch (InterruptedException e) {
     
    10899  /**
    109100   * Downloads n images into the cache beginning from the supplied start-image (including the start-image itself).
     101   *
    110102   * @param startImage the image to start with (this and the next n-1 images in the same sequence are downloaded)
    111103   * @param n the number of images to download
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java

    r32653 r32977  
    4141
    4242  /** The image currently displayed */
    43   private transient BufferedImage image;
     43  private volatile BufferedImage image;
    4444
    4545  /**
     
    4747   * rectangle is calculated each time the zoom is modified
    4848   */
    49   private Rectangle visibleRect;
     49  private volatile Rectangle visibleRect;
    5050
    5151  /**
Note: See TracChangeset for help on using the changeset viewer.