Ignore:
Timestamp:
2015-12-04T17:55:52+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] More coding issues solved and more tests added

Location:
applications/editors/josm/plugins/mapillary
Files:
5 added
17 edited
1 moved

Legend:

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

    r31796 r31797  
    110110  public String toString() {
    111111    return "Image[key=" + this.key + ";lat=" + this.latLon.lat() + ";lon="
    112         + this.latLon.lon() + ";ca=" + this.ca + "]";
     112        + this.latLon.lon() + ";ca=" + this.ca + ']';
    113113  }
    114114
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31796 r31797  
    7474
    7575  /** Maximum distance for the red/blue lines. */
    76   public final static int SEQUENCE_MAX_JUMP_DISTANCE = Main.pref.getInteger(
     76  public static final int SEQUENCE_MAX_JUMP_DISTANCE = Main.pref.getInteger(
    7777      "mapillary.sequence-max-jump-distance", 100);
    7878
     
    8181
    8282  /** Unique instance of the class. */
    83   public static MapillaryLayer INSTANCE;
     83  private static MapillaryLayer instance;
    8484  /** The image pointed by the blue line. */
    85   public static MapillaryImage BLUE;
     85  private MapillaryImage blue;
    8686  /** The image pointed by the red line. */
    87   public static MapillaryImage RED;
     87  private MapillaryImage red;
    8888  /** {@link MapillaryData} object that stores the database. */
    8989  private final MapillaryData data;
     
    110110   */
    111111  private void init() {
    112     if (INSTANCE == null)
    113       INSTANCE = this;
    114112    if (Main.main != null && Main.map.mapView != null) {
    115113      setMode(new SelectMode());
     
    166164
    167165  /**
     166   * Clears the unique instance of this class.
     167   */
     168  public static void clearInstance() {
     169    instance = null;
     170  }
     171
     172  /**
    168173   * Returns the unique instance of this class.
    169174   *
    170175   * @return The unique instance of this class.
    171176   */
    172   public synchronized static MapillaryLayer getInstance() {
    173     if (INSTANCE == null)
    174       return new MapillaryLayer();
    175     return MapillaryLayer.INSTANCE;
     177  public static synchronized MapillaryLayer getInstance() {
     178    if (instance == null)
     179      instance = new MapillaryLayer();
     180    return instance;
     181  }
     182
     183  /**
     184   * @return if the unique instance of this layer is currently instantiated
     185   */
     186  public static boolean hasInstance() {
     187    return instance != null;
    176188  }
    177189
     
    184196  public MapillaryData getData() {
    185197    return this.data;
     198  }
     199
     200  /**
     201   * @return The image that is linked to the current image with a blue line
     202   */
     203  public MapillaryImage getBlue() {
     204    return blue;
     205  }
     206
     207  /**
     208   * @return The image that is linked to the current image with a blue line
     209   */
     210  public MapillaryImage getRed() {
     211    return red;
    186212  }
    187213
     
    203229    clearInstance();
    204230    super.destroy();
    205   }
    206 
    207   /**
    208    * Clears the unique instance of this class.
    209    */
    210   public static void clearInstance() {
    211     INSTANCE = null;
    212231  }
    213232
     
    284303
    285304    // Draw colored lines
    286     MapillaryLayer.BLUE = null;
    287     MapillaryLayer.RED = null;
     305    blue = null;
     306    red = null;
    288307    MapillaryMainDialog.getInstance().blueButton.setEnabled(false);
    289308    MapillaryMainDialog.getInstance().redButton.setEnabled(false);
     
    294313      Point selected = mv.getPoint(this.data.getSelectedImage().getLatLon());
    295314      if (closestImages[0] != null) {
    296         MapillaryLayer.BLUE = closestImages[0];
     315        blue = closestImages[0];
    297316        g.setColor(Color.BLUE);
    298317        g.drawLine(mv.getPoint(closestImages[0].getLatLon()).x,
     
    301320      }
    302321      if (closestImages[1] != null) {
    303         MapillaryLayer.RED = closestImages[1];
     322        red = closestImages[1];
    304323        g.setColor(Color.RED);
    305324        g.drawLine(mv.getPoint(closestImages[1].getLatLon()).x,
     
    392411   *          The P¡{@link Point} when the image lies.
    393412   */
    394   private void draw(Graphics2D g, MapillaryAbstractImage image, ImageIcon icon,
    395       Point p) {
     413  private void draw(Graphics2D g, MapillaryAbstractImage image, ImageIcon icon, Point p) {
    396414    Image imagetemp = icon.getImage();
    397415    BufferedImage bi = (BufferedImage) imagetemp;
     
    401419    // Rotate the image
    402420    double rotationRequired = Math.toRadians(image.getCa());
    403     double locationX = width / 2;
    404     double locationY = height / 2;
    405     AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired,
    406         locationX, locationY);
    407     AffineTransformOp op = new AffineTransformOp(tx,
    408         AffineTransformOp.TYPE_BILINEAR);
    409 
    410     g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2),
    411         Main.map.mapView);
     421    double locationX = width / 2d;
     422    double locationY = height / 2d;
     423    AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY);
     424    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
     425
     426    g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2), Main.map.mapView);
    412427    if (this.data.getHighlightedImage() == image) {
    413428      drawPointHighlight(g, p, 16);
     
    433448  @Override
    434449  public Action[] getMenuEntries() {
    435     List<Action> actions = new ArrayList<>();
    436     actions.add(LayerListDialog.getInstance().createShowHideLayerAction());
    437     actions.add(LayerListDialog.getInstance().createDeleteLayerAction());
    438     actions.add(new LayerListPopup.InfoAction(this));
    439     return actions.toArray(new Action[actions.size()]);
     450    return new Action[]{
     451      LayerListDialog.getInstance().createShowHideLayerAction(),
     452      LayerListDialog.getInstance().createDeleteLayerAction(),
     453      new LayerListPopup.InfoAction(this)
     454    };
    440455  }
    441456
     
    560575  @Override
    561576  public void layerAdded(Layer newLayer) {
     577    // Do nothing, we're only interested in layer change, not addition
    562578  }
    563579
    564580  @Override
    565581  public void layerRemoved(Layer oldLayer) {
     582    // Do nothing, we're only interested in layer change, not removal
    566583  }
    567584
     
    597614    @Override
    598615    public void actionPerformed(ActionEvent e) {
    599       if (INSTANCE != null)
     616      if (instance != null)
    600617        MapillaryRecord.getInstance().addCommand(
    601618            new CommandDelete(getData().getMultiSelectedImages()));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java

    r31787 r31797  
    3737  @Override
    3838  public void actionPerformed(ActionEvent arg0) {
    39     if (MapillaryLayer.INSTANCE == null) {
    40       MapillaryLayer.getInstance();
    41     } else {
    42       if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance())
    43         Main.map.mapView.setActiveLayer(MapillaryLayer.getInstance());
    44       else
    45         Main.map.mapView.setActiveLayer(Main.map.mapView.getEditLayer());
    46     }
     39    MapillaryLayer.getInstance();
     40    if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance())
     41      Main.map.mapView.setActiveLayer(MapillaryLayer.getInstance());
     42    else
     43      Main.map.mapView.setActiveLayer(Main.map.mapView.getEditLayer());
    4744  }
    4845}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java

    r31787 r31797  
    124124
    125125  @Override
    126   public synchronized void interrupt() {
    127     super.interrupt();
    128   }
    129 
    130   @Override
    131126  public void imagesAdded() {
    132127    // Nothing
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/CacheUtils.java

    r31787 r31797  
    1818public class CacheUtils {
    1919
    20   private static IgnoreDownload IGNORE_DOWNLOAD = new IgnoreDownload();
     20  private static IgnoreDownload ignoreDownload = new IgnoreDownload();
    2121
    2222  /** Picture quality */
     
    5454    switch (pic) {
    5555      case BOTH:
    56         if (new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL)
    57             .get() == null)
    58           submit(img.getKey(), MapillaryCache.Type.THUMBNAIL, IGNORE_DOWNLOAD);
    59         if (new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE)
    60             .get() == null)
    61           submit(img.getKey(), MapillaryCache.Type.FULL_IMAGE, IGNORE_DOWNLOAD);
     56        if (new MapillaryCache(img.getKey(), MapillaryCache.Type.THUMBNAIL).get() == null)
     57          submit(img.getKey(), MapillaryCache.Type.THUMBNAIL, ignoreDownload);
     58        if (new MapillaryCache(img.getKey(), MapillaryCache.Type.FULL_IMAGE).get() == null)
     59          submit(img.getKey(), MapillaryCache.Type.FULL_IMAGE, ignoreDownload);
    6260        break;
    6361      case THUMBNAIL:
    64         submit(img.getKey(), MapillaryCache.Type.THUMBNAIL, IGNORE_DOWNLOAD);
     62        submit(img.getKey(), MapillaryCache.Type.THUMBNAIL, ignoreDownload);
    6563        break;
    6664      case FULL_IMAGE:
    67         submit(img.getKey(), MapillaryCache.Type.FULL_IMAGE, IGNORE_DOWNLOAD);
     65        submit(img.getKey(), MapillaryCache.Type.FULL_IMAGE, ignoreDownload);
    6866        break;
    6967    }
     
    9391
    9492    @Override
    95     public void loadingFinished(CacheEntry arg0, CacheEntryAttributes arg1,
    96         LoadResult arg2) {
     93    public void loadingFinished(CacheEntry arg0, CacheEntryAttributes arg1, LoadResult arg2) {
     94      // Ignore download
    9795    }
    9896  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java

    r31787 r31797  
    1717 *
    1818 */
    19 public class MapillaryCache extends
    20     JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> {
     19public class MapillaryCache extends JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> {
    2120
    22   private volatile URL url;
    23   private volatile String key;
     21  private final URL url;
     22  private final String key;
    2423
    2524  /**
     
    2827   * @author nokutu
    2928   */
    30   public static enum Type {
     29  public enum Type {
    3130    /** Full quality image */
    3231    FULL_IMAGE,
     
    4645  public MapillaryCache(String key, Type type) {
    4746    super(MapillaryPlugin.CACHE, 50000, 50000, new HashMap<String, String>());
    48     this.key = key;
    49     try {
    50       switch (type) {
    51         case FULL_IMAGE:
    52           this.url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
    53               + "/thumb-2048.jpg");
    54           this.key += ".FULL_IMAGE";
    55           break;
    56         case THUMBNAIL:
    57           this.url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
    58               + "/thumb-320.jpg");
    59           this.key += ".THUMBNAIL";
    60           break;
     47    String k = null;
     48    URL u = null;
     49    if (key != null && type != null) {
     50      try {
     51        switch (type) {
     52          case FULL_IMAGE:
     53            k = key + ".FULL_IMAGE";
     54            u = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key + "/thumb-2048.jpg");
     55            break;
     56          case THUMBNAIL:
     57          default:
     58            k = key + ".THUMBNAIL";
     59            u = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key + "/thumb-320.jpg");
     60            break;
     61        }
     62      } catch (MalformedURLException e) {
     63        // TODO: Throw exception, so that a MapillaryCache with malformed URL can't be instantiated.
     64        Main.error(e);
    6165      }
    62     } catch (MalformedURLException e) {
    63       Main.error(e);
    6466    }
     67    this.key = k;
     68    this.url = u;
    6569  }
    6670
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java

    r31787 r31797  
    4747  public final JCheckBox noTurn = new JCheckBox();
    4848
    49   private static MapillaryFilterChooseSigns INSTANCE;
     49  private static MapillaryFilterChooseSigns instance;
    5050
    5151  private MapillaryFilterChooseSigns() {
     
    172172   */
    173173  public static MapillaryFilterChooseSigns getInstance() {
    174     if (INSTANCE == null)
    175       INSTANCE = new MapillaryFilterChooseSigns();
    176     return INSTANCE;
     174    if (instance == null)
     175      instance = new MapillaryFilterChooseSigns();
     176    return instance;
    177177  }
    178178}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r31787 r31797  
    4747  private static MapillaryFilterDialog INSTANCE;
    4848
    49   private final static String[] TIME_LIST = { tr("All"), tr("Years"),
     49  private static final String[] TIME_LIST = { tr("All"), tr("Years"),
    5050      tr("Months"), tr("Days") };
    5151
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java

    r31787 r31797  
    5454  private static final long serialVersionUID = -3019715241209349372L;
    5555
    56   private static MapillaryHistoryDialog INSTANCE;
     56  private static MapillaryHistoryDialog instance;
    5757
    5858  private transient UndoRedoSelectionListener undoSelectionListener;
     
    133133   */
    134134  public static MapillaryHistoryDialog getInstance() {
    135     if (INSTANCE == null)
    136       INSTANCE = new MapillaryHistoryDialog();
    137     return INSTANCE;
     135    if (instance == null)
     136      instance = new MapillaryHistoryDialog();
     137    return instance;
    138138  }
    139139
     
    149149      this.undoButton.setEnabled(false);
    150150    ArrayList<MapillaryCommand> redoCommands = new ArrayList<>();
    151     if (commands.size() > 0 && position + 1 < commands.size())
    152       redoCommands = new ArrayList<>(commands.subList(position + 1,
    153           commands.size()));
     151    if (!commands.isEmpty() && position + 1 < commands.size())
     152      redoCommands = new ArrayList<>(commands.subList(position + 1, commands.size()));
    154153    else
    155154      this.redoButton.setEnabled(false);
     
    161160    for (MapillaryCommand command : undoCommands) {
    162161      if (command != null) {
    163         DefaultMutableTreeNode node = new DefaultMutableTreeNode(
    164             command.toString());
     162        DefaultMutableTreeNode node = new DefaultMutableTreeNode(command.toString());
    165163        this.map.put(node, command);
    166164        undoRoot.add(node);
     
    169167    for (MapillaryCommand command : redoCommands) {
    170168      if (command != null) {
    171         DefaultMutableTreeNode node = new DefaultMutableTreeNode(
    172             command.toString());
     169        DefaultMutableTreeNode node = new DefaultMutableTreeNode(command.toString());
    173170        this.map.put(node, command);
    174171        redoRoot.add(node);
     
    176173    }
    177174
    178     this.separator.setVisible(!undoCommands.isEmpty()
    179         || !redoCommands.isEmpty());
     175    this.separator.setVisible(!undoCommands.isEmpty() || !redoCommands.isEmpty());
    180176    this.spacer.setVisible(undoCommands.isEmpty() && !redoCommands.isEmpty());
    181177
     
    246242   */
    247243  public static void destroyInstance() {
    248     MapillaryHistoryDialog.INSTANCE = null;
     244    MapillaryHistoryDialog.instance = null;
    249245  }
    250246
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java

    r31787 r31797  
    429429  }
    430430
    431   private final static Point getCenterImgCoord(Rectangle visibleRect) {
     431  private static final Point getCenterImgCoord(Rectangle visibleRect) {
    432432    return new Point(visibleRect.x + visibleRect.width / 2, visibleRect.y
    433433        + visibleRect.height / 2);
     
    500500  }
    501501
    502   private final static void checkVisibleRectPos(Image image, Rectangle visibleRect) {
     502  private static final void checkVisibleRectPos(Image image, Rectangle visibleRect) {
    503503    if (visibleRect.x < 0) {
    504504      visibleRect.x = 0;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java

    r31787 r31797  
    5454  private static final long serialVersionUID = 6856496736429480600L;
    5555
    56   private final static String BASE_TITLE = marktr("Mapillary picture");
    57 
    58   private static MapillaryMainDialog INSTANCE;
     56  private static final String BASE_TITLE = marktr("Mapillary picture");
     57
     58  private static MapillaryMainDialog instance;
    5959
    6060  private volatile MapillaryAbstractImage image;
     
    6262  private final SideButton nextButton = new SideButton(new nextPictureAction());
    6363  private final SideButton previousButton = new SideButton(
    64       new previousPictureAction());
     64      new PreviousPictureAction());
    6565  /** Button used to jump to the image following the red line */
    66   public final SideButton redButton = new SideButton(new redAction());
     66  public final SideButton redButton = new SideButton(new RedAction());
    6767  /** Button used to jump to the image following the blue line */
    68   public final SideButton blueButton = new SideButton(new blueAction());
    69 
    70   private final SideButton playButton = new SideButton(new playAction());
    71   private final SideButton pauseButton = new SideButton(new pauseAction());
    72   private final SideButton stopButton = new SideButton(new stopAction());
     68  public final SideButton blueButton = new SideButton(new BlueAction());
     69
     70  private final SideButton playButton = new SideButton(new PlayAction());
     71  private final SideButton pauseButton = new SideButton(new PauseAction());
     72  private final SideButton stopButton = new SideButton(new StopAction());
    7373
    7474  /**
     
    7878   *
    7979   */
    80   public static enum MODE {
     80  public enum MODE {
    8181    /** Standard mode to view pictures. */
    8282    NORMAL,
     
    123123        KeyStroke.getKeyStroke("PAGE_UP"), "previous");
    124124    this.previousButton.getActionMap().put("previous",
    125         new previousPictureAction());
     125        new PreviousPictureAction());
    126126    this.blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    127127        KeyStroke.getKeyStroke("control PAGE_UP"), "blue");
    128     this.blueButton.getActionMap().put("blue", new blueAction());
     128    this.blueButton.getActionMap().put("blue", new BlueAction());
    129129    this.redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    130130        KeyStroke.getKeyStroke("control PAGE_DOWN"), "red");
    131     this.redButton.getActionMap().put("red", new redAction());
     131    this.redButton.getActionMap().put("red", new RedAction());
    132132  }
    133133
     
    138138   */
    139139  public static MapillaryMainDialog getInstance() {
    140     if (INSTANCE == null)
    141       INSTANCE = new MapillaryMainDialog();
    142     return INSTANCE;
     140    if (instance == null)
     141      instance = new MapillaryMainDialog();
     142    return instance;
    143143  }
    144144
     
    151151  public void setMode(MODE mode) {
    152152    switch (mode) {
    153       case NORMAL:
    154         createLayout(
    155             this.mapillaryImageDisplay,
    156             Arrays.asList(new SideButton[] { this.blueButton,
    157                 this.previousButton, this.nextButton, this.redButton }),
    158             Main.pref.getBoolean("mapillary.reverse-buttons"));
    159         break;
    160153      case WALK:
    161154        createLayout(
    162155            this.mapillaryImageDisplay,
    163             Arrays.asList(new SideButton[] { this.playButton, this.pauseButton,
    164                 this.stopButton }),
     156            Arrays.asList(new SideButton[] { playButton, pauseButton, stopButton }),
     157            Main.pref.getBoolean("mapillary.reverse-buttons"));
     158        break;
     159      case NORMAL:
     160      default:
     161        createLayout(
     162            this.mapillaryImageDisplay,
     163            Arrays.asList(new SideButton[] { blueButton, previousButton, nextButton, redButton }),
    165164            Main.pref.getBoolean("mapillary.reverse-buttons"));
    166165        break;
     
    176175   */
    177176  public static void destroyInstance() {
    178     INSTANCE = null;
     177    instance = null;
    179178  }
    180179
     
    204203      });
    205204    } else {
    206       if (MapillaryLayer.INSTANCE == null) {
     205      if (!MapillaryLayer.hasInstance()) {
    207206        return;
    208207      }
     
    309308        }
    310309      });
    311     } else {
    312       if (this.image != null) {
    313         if (this.image instanceof MapillaryImage) {
    314           MapillaryImage mapillaryImage = (MapillaryImage) this.image;
    315           String title = tr(BASE_TITLE);
    316           if (mapillaryImage.getUser() != null)
    317             title += " -- " + mapillaryImage.getUser();
    318           if (mapillaryImage.getCapturedAt() != 0)
    319             title += " -- " + mapillaryImage.getDate();
    320           setTitle(title);
    321         } else if (this.image instanceof MapillaryImportedImage) {
    322           MapillaryImportedImage mapillaryImportedImage = (MapillaryImportedImage) this.image;
    323           String title = tr(BASE_TITLE);
    324           title += " -- " + mapillaryImportedImage.getFile().getName();
    325           title += " -- " + mapillaryImportedImage.getDate();
    326           setTitle(title);
    327         }
     310    } else if (this.image != null) {
     311      if (this.image instanceof MapillaryImage) {
     312        MapillaryImage mapillaryImage = (MapillaryImage) this.image;
     313        String title = tr(BASE_TITLE);
     314        if (mapillaryImage.getUser() != null)
     315          title += " -- " + mapillaryImage.getUser();
     316        if (mapillaryImage.getCapturedAt() != 0)
     317          title += " -- " + mapillaryImage.getDate();
     318        setTitle(title);
     319      } else if (this.image instanceof MapillaryImportedImage) {
     320        MapillaryImportedImage mapillaryImportedImage = (MapillaryImportedImage) this.image;
     321        String title = tr(BASE_TITLE);
     322        title += " -- " + mapillaryImportedImage.getFile().getName();
     323        title += " -- " + mapillaryImportedImage.getDate();
     324        setTitle(title);
    328325      }
    329326    }
     
    366363   *
    367364   */
    368   private class previousPictureAction extends AbstractAction {
     365  private class PreviousPictureAction extends AbstractAction {
    369366
    370367    private static final long serialVersionUID = -6420511632957956012L;
    371368
    372     public previousPictureAction() {
     369    public PreviousPictureAction() {
    373370      putValue(NAME, tr("Previous picture"));
    374371      putValue(SHORT_DESCRIPTION,
     
    388385   *
    389386   */
    390   private class redAction extends AbstractAction {
     387  private class RedAction extends AbstractAction {
    391388
    392389    private static final long serialVersionUID = -6480229431481386376L;
    393390
    394     public redAction() {
     391    public RedAction() {
    395392      putValue(NAME, tr("Jump to red"));
    396393      putValue(SHORT_DESCRIPTION,
     
    402399      if (MapillaryMainDialog.getInstance().getImage() != null) {
    403400        MapillaryLayer.getInstance().getData()
    404             .setSelectedImage(MapillaryLayer.RED, true);
     401            .setSelectedImage(MapillaryLayer.getInstance().getRed(), true);
    405402      }
    406403    }
     
    413410   *
    414411   */
    415   private class blueAction extends AbstractAction {
     412  private class BlueAction extends AbstractAction {
    416413
    417414    private static final long serialVersionUID = 6250690644594703314L;
    418415
    419     public blueAction() {
     416    public BlueAction() {
    420417      putValue(NAME, tr("Jump to blue"));
    421418      putValue(SHORT_DESCRIPTION,
     
    427424      if (MapillaryMainDialog.getInstance().getImage() != null) {
    428425        MapillaryLayer.getInstance().getData()
    429             .setSelectedImage(MapillaryLayer.BLUE, true);
    430       }
    431     }
    432   }
    433 
    434   private class stopAction extends AbstractAction implements WalkListener {
     426            .setSelectedImage(MapillaryLayer.getInstance().getBlue(), true);
     427      }
     428    }
     429  }
     430
     431  private class StopAction extends AbstractAction implements WalkListener {
    435432
    436433    private static final long serialVersionUID = -6561451575815789198L;
     
    438435    private WalkThread thread;
    439436
    440     public stopAction() {
     437    public StopAction() {
    441438      putValue(NAME, tr("Stop"));
    442439      putValue(SHORT_DESCRIPTION, tr("Stops the walk."));
     
    457454  }
    458455
    459   private class playAction extends AbstractAction implements WalkListener {
     456  private class PlayAction extends AbstractAction implements WalkListener {
    460457
    461458    private static final long serialVersionUID = -17943404752082788L;
    462459    private WalkThread thread;
    463460
    464     public playAction() {
     461    public PlayAction() {
    465462      putValue(NAME, tr("Play"));
    466463      putValue(SHORT_DESCRIPTION, tr("Continues with the paused walk."));
     
    482479  }
    483480
    484   private class pauseAction extends AbstractAction implements WalkListener {
     481  private class PauseAction extends AbstractAction implements WalkListener {
    485482
    486483    private static final long serialVersionUID = 4400240686337741192L;
     
    488485    private WalkThread thread;
    489486
    490     public pauseAction() {
     487    public PauseAction() {
    491488      putValue(NAME, tr("Pause"));
    492489      putValue(SHORT_DESCRIPTION, tr("Pauses the walk."));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java

    r31787 r31797  
    33
    44import java.util.ArrayList;
     5import java.util.List;
    56
    67import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
     
    1617public class MapillaryRecord {
    1718  /** The unique instance of the class. */
    18   private static MapillaryRecord INSTANCE;
     19  private static MapillaryRecord instance;
    1920
    2021  private ArrayList<MapillaryRecordListener> listeners;
     
    4041   */
    4142  public static synchronized MapillaryRecord getInstance() {
    42     if (MapillaryRecord.INSTANCE == null)
    43       MapillaryRecord.INSTANCE = new MapillaryRecord();
    44     return MapillaryRecord.INSTANCE;
     43    if (MapillaryRecord.instance == null)
     44      MapillaryRecord.instance = new MapillaryRecord();
     45    return MapillaryRecord.instance;
    4546  }
    4647
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r31796 r31797  
    3939
    4040  /** Base URL of the Mapillary API. */
    41   public final static String BASE_URL = "https://a.mapillary.com/v2/";
     41  public static final String BASE_URL = "https://a.mapillary.com/v2/";
    4242  /** Client ID for the app */
    43   public final static String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
     43  public static final String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
    4444  /** Executor that will run the petitions. */
    4545  private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5,
     
    179179  public static MapillaryDownloader.MODES getMode() {
    180180    if (Main.pref.get("mapillary.download-mode").equals(MODES.Automatic.toString())
    181         && (MapillaryLayer.INSTANCE == null || !MapillaryLayer.INSTANCE.TEMP_SEMIAUTOMATIC))
     181        && (!MapillaryLayer.hasInstance() || !MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC))
    182182      return MODES.Automatic;
    183183    else if (Main.pref.get("mapillary.download-mode").equals(MODES.Semiautomatic.toString())
    184         || (MapillaryLayer.INSTANCE != null && MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC))
     184        || (MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC))
    185185      return MODES.Semiautomatic;
    186186    else if (Main.pref.get("mapillary.download-mode").equals(MODES.Manual.toString()))
    187187      return MODES.Manual;
    188     else if (Main.pref.get("mapillary.download-mode").equals(""))
     188    else if ("".equals(Main.pref.get("mapillary.download-mode")))
    189189      return MODES.Automatic;
    190190    else
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/export/MapillaryExportWriterThread.java

    r31787 r31797  
    7373  public void run() {
    7474    this.monitor.setCustomText("Downloaded 0/" + this.amount);
    75     // File tempFile = null;
    7675    BufferedImage img;
    77     MapillaryAbstractImage mimg = null;
     76    MapillaryAbstractImage mimg;
    7877    String finalPath = "";
    7978    for (int i = 0; i < this.amount; i++) {
     
    9190          finalPath = this.path + "/"
    9291              + ((MapillaryImportedImage) mimg).getFile().getName();
    93         ;
    9492
    9593        // Transforms the image into a byte array.
     
    10098        // Write EXIF tags
    10199        TiffOutputSet outputSet = null;
    102         TiffOutputDirectory exifDirectory = null;
    103         TiffOutputDirectory gpsDirectory = null;
     100        TiffOutputDirectory exifDirectory;
     101        TiffOutputDirectory gpsDirectory;
    104102        // If the image is imported, loads the rest of the EXIF data.
    105103        if (mimg instanceof MapillaryImportedImage) {
     
    135133          exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL,
    136134              ((MapillaryImage) mimg).getDate("yyyy/MM/dd hh/mm/ss"));
    137         outputSet.setGPSInDegrees(mimg.getLatLon().lon(), mimg.getLatLon()
    138             .lat());
    139         OutputStream os = new BufferedOutputStream(new FileOutputStream(
    140             finalPath + ".jpg"));
    141         new ExifRewriter()
    142             .updateExifMetadataLossless(imageBytes, os, outputSet);
     135        outputSet.setGPSInDegrees(mimg.getLatLon().lon(), mimg.getLatLon().lat());
     136        OutputStream os = new BufferedOutputStream(new FileOutputStream(finalPath + ".jpg"));
     137        new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);
    143138
    144139        os.close();
     
    155150
    156151      // Increases the progress bar.
    157       this.monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX
    158           / this.amount);
     152      this.monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / this.amount);
    159153      this.monitor.setCustomText("Downloaded " + (i + 1) + "/" + this.amount);
    160154    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java

    r31796 r31797  
    2727    ZoomChangeListener {
    2828
    29   private final static int DOWNLOAD_COOLDOWN = 2000;
     29  private static final int DOWNLOAD_COOLDOWN = 2000;
    3030
    3131  protected MapillaryData data = MapillaryLayer.getInstance().getData();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r31789 r31797  
    190190   * @param mapillaryAbstractImage2
    191191   */
    192   public synchronized static void join(
     192  public static synchronized void join(
    193193      MapillaryAbstractImage mapillaryAbstractImage,
    194194      MapillaryAbstractImage mapillaryAbstractImage2) {
     
    433433   * @param mapillaryAbstractImage2
    434434   */
    435   public synchronized static void unjoin(
     435  public static synchronized void unjoin(
    436436      MapillaryAbstractImage mapillaryAbstractImage,
    437437      MapillaryAbstractImage mapillaryAbstractImage2) {
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java

    r31500 r31797  
    22
    33import static org.junit.Assert.assertEquals;
     4import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertTrue;
    46import static org.junit.Assert.fail;
    57
     
    266268
    267269    this.record.addCommand(cmd1);
    268     assertEquals(false, MapillaryLayer.getInstance().getData().getImages()
    269         .contains(this.img1));
     270    assertFalse(MapillaryLayer.getInstance().getData().getImages().contains(this.img1));
    270271    assertEquals(null, this.img2.previous());
    271272    this.record.undo();
    272     assertEquals(true, MapillaryLayer.getInstance().getData().getImages()
    273         .contains(this.img1));
     273    assertTrue(MapillaryLayer.getInstance().getData().getImages().contains(this.img1));
    274274    this.record.redo();
    275275    this.record.addCommand(cmd2);
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java

    r31796 r31797  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.mapillary.downloads;
     4package org.openstreetmap.josm.plugins.mapillary.io.download;
    55
    66import static org.junit.Assert.assertTrue;
Note: See TracChangeset for help on using the changeset viewer.