Ignore:
Timestamp:
2015-07-09T11:57:53+02:00 (9 years ago)
Author:
nokutu
Message:

Finished join/unjoin mode. You can change the mode with a button in data menu.

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

Legend:

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

    r31357 r31358  
    163163   */
    164164  public void selectNext() {
    165     if (getSelectedImage() instanceof MapillaryImage) {
    166       if (getSelectedImage() == null)
    167         return;
    168       if (((MapillaryImage) getSelectedImage()).getSequence() == null)
    169         return;
    170       if (selectedImage instanceof MapillaryImage
    171           && ((MapillaryImage) selectedImage).getSequence() != null) {
    172         MapillaryAbstractImage tempImage = selectedImage;
    173         while (tempImage.next() != null) {
    174           tempImage = tempImage.next();
    175           if (tempImage.isVisible()) {
    176             setSelectedImage(tempImage,
    177                 Main.pref.getBoolean("mapillary.move-to-picture", true));
    178             break;
    179           }
    180         }
     165    if (getSelectedImage() == null)
     166      return;
     167    if (getSelectedImage().getSequence() == null)
     168      return;
     169    MapillaryAbstractImage tempImage = selectedImage;
     170    while (tempImage.next() != null) {
     171      tempImage = tempImage.next();
     172      if (tempImage.isVisible()) {
     173        setSelectedImage(tempImage, Main.pref.getBoolean("mapillary.move-to-picture", true));
     174        break;
    181175      }
    182176    }
     
    189183   */
    190184  public void selectPrevious() {
    191     if (getSelectedImage() instanceof MapillaryImage) {
    192       if (getSelectedImage() == null)
    193         return;
    194       if (((MapillaryImage) getSelectedImage()).getSequence() == null)
    195         throw new IllegalStateException();
    196       if (selectedImage instanceof MapillaryImage
    197           && ((MapillaryImage) selectedImage).getSequence() != null) {
    198         MapillaryAbstractImage tempImage = selectedImage;
    199         while (tempImage.previous() != null) {
    200           tempImage = tempImage.previous();
    201           if (tempImage.isVisible()) {
    202             setSelectedImage(tempImage,
    203                 Main.pref.getBoolean("mapillary.move-to-picture", true));
    204             break;
    205           }
    206         }
     185    if (getSelectedImage() == null)
     186      return;
     187    if (getSelectedImage().getSequence() == null)
     188      throw new IllegalStateException();
     189    MapillaryAbstractImage tempImage = selectedImage;
     190    while (tempImage.previous() != null) {
     191      tempImage = tempImage.previous();
     192      if (tempImage.isVisible()) {
     193        setSelectedImage(tempImage, Main.pref.getBoolean("mapillary.move-to-picture", true));
     194        break;
    207195      }
    208196    }
     
    242230        // Donwloadins thumbnails of surrounding pictures.
    243231        if (mapillaryImage.next() != null) {
    244           new MapillaryCache(((MapillaryImage) mapillaryImage.next()).getKey(),
    245               MapillaryCache.Type.THUMBNAIL).submit(this, false);
     232          new MapillaryCache(((MapillaryImage) mapillaryImage.next()).getKey(), MapillaryCache.Type.THUMBNAIL).submit(
     233              this, false);
    246234          if (mapillaryImage.next().next() != null)
    247             new MapillaryCache(((MapillaryImage) mapillaryImage.next().next()).getKey(),
    248                 MapillaryCache.Type.THUMBNAIL).submit(this, false);
     235            new MapillaryCache(((MapillaryImage) mapillaryImage.next().next()).getKey(), MapillaryCache.Type.THUMBNAIL)
     236                .submit(this, false);
    249237        }
    250238        if (mapillaryImage.previous() != null) {
    251           new MapillaryCache(((MapillaryImage) mapillaryImage.previous()).getKey(),
    252               MapillaryCache.Type.THUMBNAIL).submit(this, false);
     239          new MapillaryCache(((MapillaryImage) mapillaryImage.previous()).getKey(), MapillaryCache.Type.THUMBNAIL)
     240              .submit(this, false);
    253241          if (mapillaryImage.previous().previous() != null)
    254242            new MapillaryCache(((MapillaryImage) mapillaryImage.previous().previous()).getKey(),
     
    258246    }
    259247    if (zoom)
    260       Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage()
    261           .getLatLon());
     248      Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage().getLatLon());
    262249    if (Main.map != null)
    263250      Main.map.mapView.repaint();
     
    265252  }
    266253
    267   private void fireSelectedImageChanged(MapillaryAbstractImage oldImage,
    268       MapillaryAbstractImage newImage) {
     254  private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) {
    269255    if (listeners.isEmpty())
    270256      return;
     
    323309   */
    324310  @Override
    325   public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes,
    326       LoadResult result) {
     311  public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, LoadResult result) {
    327312    // DO NOTHING
    328313  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31357 r31358  
    124124    Main.map.mapView.removeMouseMotionListener(this.mode);
    125125    this.mode = mode;
     126    Main.map.mapView.setNewCursor(mode.cursor, this);
    126127    Main.map.mapView.addMouseListener(mode);
    127128    Main.map.mapView.addMouseMotionListener(mode);
     129    updateHelpText();
    128130  }
    129131
     
    552554  public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    553555    if (newLayer == this) {
    554       if (data.size() > 0)
    555         Main.map.statusLine.setHelpText(tr("Total images: {0}", data.size()));
    556       else
    557         Main.map.statusLine.setHelpText(tr("No images found"));
     556      updateHelpText();
    558557      MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true);
    559558    } else
     
    568567  public void layerRemoved(Layer oldLayer) {
    569568  }
     569 
     570  public void updateHelpText() {
     571    String ret = "";
     572    if (data.size() > 0)
     573      ret += tr("Total images: {0}", data.size());
     574    else
     575      ret += tr("No images found");
     576    ret += " -- " + tr(mode.toString());
     577   
     578     Main.map.statusLine.setHelpText(ret);
     579  }
    570580}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java

    r31352 r31358  
    3939  @Override
    4040  public void run() {
    41     Main.map.statusLine.setHelpText("Downloading images from Mapillary");
     41    Main.map.statusLine.setHelpText(tr("Downloading images from Mapillary"));
    4242    try {
    4343      downloadSequences();
    4444      if (imagesAdded) {
    45         Main.map.statusLine.setHelpText("Downloading image's information");
     45        Main.map.statusLine.setHelpText(tr("Downloading image's information"));
    4646        completeImages();
    4747        MapillaryMainDialog.getInstance().updateTitle();
    48         Main.map.statusLine.setHelpText("Downloading signs");
     48        Main.map.statusLine.setHelpText(tr("Downloading signs"));
    4949        downloadSigns();
    5050      }
     
    5252      Main.error(e);
    5353    }
    54     if (layer.data.getImages().size() > 0)
    55       Main.map.statusLine.setHelpText(tr("Total images: ") + layer.data.getImages().size());
    56     else
    57       Main.map.statusLine.setHelpText(tr("No images found"));
     54    layer.updateHelpText();
    5855    layer.data.dataUpdated();
    5956    MapillaryFilterDialog.getInstance().refresh();
     
    6259
    6360  private void downloadSequences() throws InterruptedException {
    64     ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     61    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
     62        new ArrayBlockingQueue<Runnable>(5));
    6563    int page = 0;
    6664    while (!ex.isShutdown()) {
    67       ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences + "&page=" + page + "&limit=10", layer, this));
     65      ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences
     66          + "&page=" + page + "&limit=10", layer, this));
    6867      while (ex.getQueue().remainingCapacity() == 0)
    6968        Thread.sleep(500);
     
    7574
    7675  private void completeImages() throws InterruptedException {
    77     ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     76    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
     77        new ArrayBlockingQueue<Runnable>(5));
    7878    int page = 0;
    7979    while (!ex.isShutdown()) {
    80       ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages + "&page=" + page + "&limit=20", layer));
     80      ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages
     81          + "&page=" + page + "&limit=20", layer));
    8182      while (ex.getQueue().remainingCapacity() == 0)
    8283        Thread.sleep(100);
     
    8788
    8889  private void downloadSigns() throws InterruptedException {
    89     ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     90    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
     91        new ArrayBlockingQueue<Runnable>(5));
    9092    int page = 0;
    9193    while (!ex.isShutdown()) {
    92       ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page=" + page + "&limit=20", layer));
     94      ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page="
     95          + page + "&limit=20", layer));
    9396      while (ex.getQueue().remainingCapacity() == 0)
    9497        Thread.sleep(100);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java

    r31355 r31358  
    137137        return;
    138138      }
     139      // Enables/disables next/previous buttons
     140      this.nextButton.setEnabled(false);
     141      this.previousButton.setEnabled(false);
     142      if (image.getSequence() != null) {
     143        MapillaryAbstractImage tempImage = image;
     144        while (tempImage.next() != null) {
     145          tempImage = tempImage.next();
     146          if (tempImage.isVisible()) {
     147            this.nextButton.setEnabled(true);
     148            break;
     149          }
     150        }
     151      }
     152      if (image.getSequence() != null) {
     153        MapillaryAbstractImage tempImage = image;
     154        while (tempImage.previous() != null) {
     155          tempImage = tempImage.previous();
     156          if (tempImage.isVisible()) {
     157            this.previousButton.setEnabled(true);
     158            break;
     159          }
     160        }
     161      }
    139162      if (image instanceof MapillaryImage) {
    140163        mapillaryImageDisplay.hyperlink.setVisible(true);
    141164        MapillaryImage mapillaryImage = (MapillaryImage) this.image;
    142165        updateTitle();
    143         // Enables/disables next/previous buttons
    144         this.nextButton.setEnabled(false);
    145         this.previousButton.setEnabled(false);
    146         if (((MapillaryImage) image).getSequence() != null) {
    147           MapillaryAbstractImage tempImage = image;
    148           while (tempImage.next() != null) {
    149             tempImage = tempImage.next();
    150             if (tempImage.isVisible()) {
    151               this.nextButton.setEnabled(true);
    152               break;
    153             }
    154           }
    155         }
    156         if (((MapillaryImage) image).getSequence() != null) {
    157           MapillaryAbstractImage tempImage = image;
    158           while (tempImage.previous() != null) {
    159             tempImage = tempImage.previous();
    160             if (tempImage.isVisible()) {
    161               this.previousButton.setEnabled(true);
    162               break;
    163             }
    164           }
    165         }
    166166
    167167        mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey());
     
    182182      } else if (image instanceof MapillaryImportedImage) {
    183183        mapillaryImageDisplay.hyperlink.setVisible(false);
    184         this.nextButton.setEnabled(false);
    185         this.previousButton.setEnabled(false);
    186184        MapillaryImportedImage mapillaryImage = (MapillaryImportedImage) this.image;
    187185        try {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java

    r31357 r31358  
    11package org.openstreetmap.josm.plugins.mapillary.mode;
    22
     3import java.awt.Cursor;
    34import java.awt.Graphics2D;
    45import java.awt.Point;
     
    1415
    1516  protected MapillaryData data = MapillaryData.getInstance();
     17 
     18  public int cursor = Cursor.DEFAULT_CURSOR;
    1619
    1720  public AbstractMode() {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java

    r31357 r31358  
    22
    33import java.awt.Color;
     4import java.awt.Cursor;
    45import java.awt.Graphics2D;
    56import java.awt.Point;
    67import java.awt.event.MouseEvent;
     8import java.util.ArrayList;
    79
    810import org.openstreetmap.josm.Main;
     
    1820  public MapillaryImportedImage lastClick;
    1921  public MouseEvent lastPos;
     22 
     23  public JoinMode() {
     24    cursor = Cursor.CROSSHAIR_CURSOR;
     25  }
    2026
    2127  @Override
     
    2430      return;
    2531    if (lastClick == null && data.getHighlighted() instanceof MapillaryImportedImage) {
    26       if (data.getHighlighted().previous() == null || data.getHighlighted().next() == null)
    27         lastClick = (MapillaryImportedImage) data.getHighlighted();
     32      lastClick = (MapillaryImportedImage) data.getHighlighted();
    2833    } else if (lastClick != null && data.getHighlighted() instanceof MapillaryImportedImage) {
    29       if ((data.getHighlighted().previous() == null && lastClick.next() == null)
    30           || (data.getHighlighted().next() == null && lastClick.previous() == null)) {
     34      if (((data.getHighlighted().previous() == null && lastClick.next() == null) || (data.getHighlighted().next() == null && lastClick
     35          .previous() == null))
     36          && (data.getHighlighted().getSequence() != lastClick.getSequence() || lastClick.getSequence() == null)) {
    3137        join(lastClick, (MapillaryImportedImage) data.getHighlighted());
    3238      } else if (lastClick.next() == data.getHighlighted() || lastClick.previous() == data.getHighlighted())
     
    8187
    8288  private void unjoin(MapillaryImportedImage img1, MapillaryImportedImage img2) {
    83     // TODO
     89    if (img1.next() != img2) {
     90      MapillaryImportedImage temp = img1;
     91      img1 = img2;
     92      img2 = temp;
     93    }
     94
     95    ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(img1.getSequence().getImages()
     96        .subList(0, img1.getSequence().getImages().indexOf(img2)));
     97    ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(img1.getSequence().getImages()
     98        .subList(img1.getSequence().getImages().indexOf(img2), img1.getSequence().getImages().size()));
     99
     100    MapillarySequence seq1 = new MapillarySequence();
     101    MapillarySequence seq2 = new MapillarySequence();
     102
     103    for (MapillaryAbstractImage img : firstHalf) {
     104      img.setSequence(seq1);
     105      seq1.add(img);
     106    }
     107    for (MapillaryAbstractImage img : secondHalf) {
     108      img.setSequence(seq2);
     109      seq2.add(img);
     110    }
     111  }
     112 
     113  @Override
     114  public String toString() {
     115    return "Join mode";
    84116  }
    85117}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    r31357 r31358  
    196196  public void paint(Graphics2D g, MapView mv, Bounds box) {
    197197  }
     198 
     199  @Override
     200  public String toString() {
     201    return "Select mode";
     202  }
    198203}
Note: See TracChangeset for help on using the changeset viewer.