Ignore:
Timestamp:
2018-07-19T02:09:21+02:00 (7 years ago)
Author:
renerr18
Message:

Reimplemented previous/next functionality in StreetsideMainDialog.

Location:
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideAbstractImage.java

    r34428 r34429  
    2727        protected String id;
    2828
     29        // Image id of next image in sequence (decimal)
    2930        private long ne;
    30   private long pr;
    31 
    32 
    33         /** The time the image was captured, in Epoch format. */
    34         protected long cd;
     31    //Image id of previous image in sequence (decimal)
     32    private long pr;
     33
     34
    3535        /** Sequence of pictures containing this object. */
    3636        private StreetsideSequence sequence;
     
    3838        /** Position of the picture. */
    3939        protected LatLon latLon;
    40         /** Direction of the picture. */
     40        /** Direction of the picture in degrees from true north. */
    4141        protected double he;
    4242        /** Temporal position of the picture until it is uploaded. */
     
    116116
    117117        /**
    118          * Returns the Epoch time when the image was captured.
    119          *
    120          * @return The long containing the Epoch time when the image was captured.
    121          */
    122         public long getCd() {
    123                 return cd;
    124         }
    125 
    126         /**
    127          * Returns the date the picture was taken in DMY format.
    128          *
    129          * @return A String object containing the date when the picture was taken.
    130          */
    131         public String getDate() {
    132                 final StringBuilder format = new StringBuilder(26);
    133                 format.append("m/d/YYYY");
    134                 if (StreetsideProperties.DISPLAY_HOUR.get()) {
    135                         if (StreetsideProperties.TIME_FORMAT_24.get()) {
    136                                 format.append(" - HH:mm:ss");
    137                         } else {
    138                                 format.append(" - h:mm:ss a");
    139                         }
    140                 }
    141                 return getDate(format.toString());
    142         }
    143 
    144         /**
    145          * Returns the date the picture was taken in the given format.
    146          *
    147          * @param format
    148          *            Format of the date. See {@link SimpleDateFormat}.
    149          * @return A String containing the date the picture was taken using the given
    150          *         format.
    151          * @throws NullPointerException
    152          *             if parameter format is <code>null</code>
    153          */
    154         public String getDate(String format) {
    155                 final Date date = new Date(getCd());
    156                 final SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.US);
    157                 formatter.setTimeZone(Calendar.getInstance().getTimeZone());
    158                 return formatter.format(date);
    159         }
    160 
    161         /**
    162118         * Returns a LatLon object containing the original coordinates of the object.
    163119         *
     
    227183         */
    228184        public boolean isModified() {
    229                 return !getMovingLatLon().equals(latLon) || Math.abs(getMovingHe() - cd) > EPSILON;
     185                return !getMovingLatLon().equals(latLon) || Math.abs(getMovingHe() - he) > EPSILON;
    230186        }
    231187
     
    277233        public void setHe(final double he) {
    278234                this.he = he;
    279         }
    280 
    281         /**
    282          * Sets the Epoch time when the picture was captured.
    283          *
    284          * @param cd
    285          *            Epoch time when the image was captured.
    286          */
    287         public synchronized void setCd(final long cd) {
    288                 this.cd = cd;
    289235        }
    290236
     
    339285         *            The angle the image is moving.
    340286         */
    341         public void turn(final double ca) {
    342                 movingHe = tempHe + ca;
     287        public void turn(final double he) {
     288                movingHe = tempHe + he;
    343289        }
    344290
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideData.java

    r34358 r34429  
    245245   */
    246246  public void selectNext(boolean moveToPicture) {
    247     if (getSelectedImage() == null) {
    248                 throw new IllegalStateException();
    249         }
    250     if (getSelectedImage().getSequence() == null) {
    251                 throw new IllegalStateException();
    252         }
    253247    StreetsideAbstractImage tempImage = selectedImage;
    254     while (tempImage.next() != null) {
    255       tempImage = tempImage.next();
    256       if (tempImage.isVisible()) {
    257         setSelectedImage(tempImage, moveToPicture);
    258         break;
     248    if (selectedImage != null && selectedImage.getSequence() != null) {
     249      while (tempImage.next() != null) {
     250        tempImage = tempImage.next();
     251        if (tempImage.isVisible()) {
     252          setSelectedImage(tempImage, moveToPicture);
     253          break;
     254        }
    259255      }
    260256    }
     
    284280   */
    285281  public void selectPrevious(boolean moveToPicture) {
    286     if (getSelectedImage() == null) {
    287                 throw new IllegalStateException();
    288         }
    289     if (getSelectedImage().getSequence() == null) {
    290                 throw new IllegalStateException();
    291         }
    292     StreetsideAbstractImage tempImage = selectedImage;
    293     while (tempImage.previous() != null) {
    294       tempImage = tempImage.previous();
    295       if (tempImage.isVisible()) {
    296         setSelectedImage(tempImage, moveToPicture);
    297         break;
     282    if (selectedImage != null && selectedImage.getSequence() != null) {
     283      StreetsideAbstractImage tempImage = selectedImage;
     284      while (tempImage.previous() != null) {
     285        tempImage = tempImage.previous();
     286        if (tempImage.isVisible()) {
     287          setSelectedImage(tempImage, moveToPicture);
     288          break;
     289        }
    298290      }
    299291    }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideImage.java

    r34416 r34429  
    7373  // Default constructor for Jackson/JSON Deserializattion
    7474  public StreetsideImage() {
    75     super(CubemapUtils.IMPORTED_ID, null, 0.0);
     75    super(CubemapUtils.TEST_IMAGE_ID, null, 0.0);
    7676  }
    7777
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideLayer.java

    r34416 r34429  
    322322    final Color directionC;
    323323    if (selectedImg != null && getData().getMultiSelectedImages().contains(img)) {
    324       markerC = img instanceof StreetsideImportedImage
    325         ? StreetsideColorScheme.SEQ_IMPORTED_HIGHLIGHTED
    326         : StreetsideColorScheme.SEQ_HIGHLIGHTED;
    327       directionC = img instanceof StreetsideImportedImage
    328         ? StreetsideColorScheme.SEQ_IMPORTED_HIGHLIGHTED_CA
    329         : StreetsideColorScheme.SEQ_HIGHLIGHTED_CA;
     324      markerC = StreetsideColorScheme.SEQ_HIGHLIGHTED;
     325      directionC = StreetsideColorScheme.SEQ_HIGHLIGHTED_CA;
    330326    } else if (selectedImg != null && selectedImg.getSequence() != null && selectedImg.getSequence().equals(img.getSequence())) {
    331       markerC = img instanceof StreetsideImportedImage
    332         ? StreetsideColorScheme.SEQ_IMPORTED_SELECTED
    333         : StreetsideColorScheme.SEQ_SELECTED;
    334       directionC = img instanceof StreetsideImportedImage
    335         ? StreetsideColorScheme.SEQ_IMPORTED_SELECTED_CA
    336         : StreetsideColorScheme.SEQ_SELECTED_CA;
     327      markerC = StreetsideColorScheme.SEQ_SELECTED;
     328      directionC = StreetsideColorScheme.SEQ_SELECTED_CA;
    337329    } else {
    338       markerC = img instanceof StreetsideImportedImage
    339         ? StreetsideColorScheme.SEQ_IMPORTED_UNSELECTED
    340         : StreetsideColorScheme.SEQ_UNSELECTED;
    341       directionC = img instanceof StreetsideImportedImage
    342         ? StreetsideColorScheme.SEQ_IMPORTED_UNSELECTED_CA
    343         : StreetsideColorScheme.SEQ_UNSELECTED_CA;
     330      markerC = StreetsideColorScheme.SEQ_UNSELECTED;
     331      directionC = StreetsideColorScheme.SEQ_UNSELECTED_CA;
    344332    }
    345333
    346334    // Paint direction indicator
    347335    g.setColor(directionC);
    348     g.fillArc(p.x - CA_INDICATOR_RADIUS, p.y - CA_INDICATOR_RADIUS, 2 * CA_INDICATOR_RADIUS, 2 * CA_INDICATOR_RADIUS, (int) (90 - img.getMovingHe() - CA_INDICATOR_ANGLE / 2d), CA_INDICATOR_ANGLE);
     336    g.fillArc(p.x - CA_INDICATOR_RADIUS, p.y - CA_INDICATOR_RADIUS, 2 * CA_INDICATOR_RADIUS, 2 * CA_INDICATOR_RADIUS, (int) (90 - /*img.getMovingHe()*/img.getHe() - CA_INDICATOR_ANGLE / 2d), CA_INDICATOR_ANGLE);
    349337    // Paint image marker
    350338    g.setColor(markerC);
     
    397385      ))
    398386      .append("\n\n")
    399       .append(I18n.tr(
    400         "{0} imported images",
    401         getData().getImages().stream().filter(i -> i instanceof StreetsideImportedImage).count()
    402       ))
    403387      .append("\n+ ")
    404388      .append(I18n.tr(
     
    489473    }
    490474    if (MainApplication.isDisplayingMapView()) {
    491       //StreetsideMainDialog.getInstance().redButton.setEnabled(nearestImages.length >= 1);
    492       //StreetsideMainDialog.getInstance().blueButton.setEnabled(nearestImages.length >= 2);
     475      StreetsideMainDialog.getInstance().redButton.setEnabled(nearestImages.length >= 1);
     476      StreetsideMainDialog.getInstance().blueButton.setEnabled(nearestImages.length >= 2);
    493477    }
    494478    if (nearestImages.length >= 1) {
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsidePlugin.java

    r34416 r34429  
    2525import org.openstreetmap.josm.tools.ImageProvider;
    2626
     27import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerPanel;
     28
    2729/**
    2830 * This is the main class of the Streetside plugin.
     
    4345      MainMenu.add(MainApplication.getMenu().viewMenu, ZOOM_ACTION, false, 15);
    4446      MainMenu.add(MainApplication.getMenu().fileMenu, new StreetsideDownloadViewAction(), false, 14);
    45       //MainMenu.add(MainApplication.getMenu().dataMenu, new StreetsideJoinAction(), false);
    4647      MainMenu.add(MainApplication.getMenu().moreToolsMenu, WALK_ACTION, false);
    4748    }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideExportAction.java

    r34399 r34429  
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
    9 import java.io.IOException;
    10 import java.util.ArrayList;
    119import java.util.Set;
    1210import java.util.concurrent.ConcurrentSkipListSet;
     
    2220import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
    2321import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
    24 import org.openstreetmap.josm.plugins.streetside.StreetsideImportedImage;
    2522import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    2623import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
     
    9491        export(StreetsideLayer.getInstance().getData().getMultiSelectedImages());
    9592      }
    96       // This option ignores the selected directory.
    97     } else if (dialog.group.isSelected(dialog.rewrite.getModel())) {
    98       ArrayList<StreetsideImportedImage> images = new ArrayList<>();
    99       StreetsideLayer.getInstance().getData().getImages().stream().filter(img -> img instanceof StreetsideImportedImage).forEach(img -> images.add((StreetsideImportedImage) img));
    100       try {
    101         MainApplication.worker.execute(new StreetsideExportManager(images));
    102       } catch (IOException e1) {
    103         logger.error(e1);
    104       }
    10593    }
    10694    dlg.dispose();
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapBuilder.java

    r34428 r34429  
    3535        private static CubemapBuilder instance;
    3636        private StreetsideCubemap cubemap;
    37         protected boolean cancelled;
    38         private long startTime;
     37        protected boolean isBuilding;
     38
     39  private long startTime;
    3940
    4041        private Map<String, BufferedImage> tileImages = new ConcurrentHashMap<>();
     
    8182  @Override
    8283  public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) {
     84
     85
    8386    startTime = System.currentTimeMillis();
    8487
     
    8790                        cubemap = null;
    8891                        cubemap = new StreetsideCubemap(newImage.getId(), newImage.getLatLon(), newImage.getHe());
    89                         cubemap.setCd(newImage.getCd());
     92                        currentTileCount = 0;
     93                        resetTileImages();
    9094
    9195                        // download cubemap images in different threads and then subsequently
     
    149153
    150154          List<Future<List<String>>> results = pool.invokeAll(tasks);
    151           /*for (Future<List<String>> ff : results) {
    152 
    153             if (StreetsideProperties.DEBUGING_ENABLED.get()) {
     155          for (Future<List<String>> ff : results) {
     156            if (StreetsideProperties.DEBUGING_ENABLED.get() && results!=null) {
    154157              logger.debug(
    155158                MessageFormat.format(
    156159                  "Completed tile downloading task {0} in {1} seconds.", ff.get().toString(),
    157                   (System.currentTimeMillis()) / 1000 - startTime)
     160                  ((System.currentTimeMillis()) - startTime)/1000)
    158161                );
     162            } else {
     163              logger.error(MessageFormat.format("Results of downloading tasks for image id {0} are null!", imageId));
    159164            }
    160           }*/
     165          }
    161166
    162167          // launch 16-tiled (high-res) downloading tasks
     
    178183      List<Future<List<String>>> results = pool.invokeAll(tasks);
    179184      for (Future<List<String>> ff : results) {
    180         if (StreetsideProperties.DEBUGING_ENABLED.get()) {
     185        if (StreetsideProperties.DEBUGING_ENABLED.get() && results!=null) {
    181186          logger.debug(
    182187            MessageFormat.format(
     
    184189              ((System.currentTimeMillis()) - startTime)/1000)
    185190            );
     191        } else {
     192          logger.error(MessageFormat.format("Results of downloading tasks for image id {0} are null!", imageId));
    186193        }
    187194      }
     
    218225    // and set the views in the cubemap box.
    219226
    220     if(currentTileCount>96) {
    221       int x = 0;
     227    if(!tileId.startsWith(cubemap.getId())) {
     228      return;
    222229    }
    223230
     
    328335    resetTileImages();
    329336    currentTileCount = 0;
     337    isBuilding = false;
    330338        }
    331339
     
    364372
    365373        /**
     374   * @return the isBuilding
     375   */
     376  public boolean isBuilding() {
     377    return isBuilding;
     378  }
     379
     380
     381        /**
    366382         * Destroys the unique instance of the class.
    367383         */
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapUtils.java

    r34428 r34429  
    7272        // numerical base for decimal conversion (quaternary in the case of Streetside)
    7373        private static final int NUM_BASE = 4;
    74         public static final String IMPORTED_ID = "00000000";
     74        public static final String TEST_IMAGE_ID = "00000000";
    7575        public static final int NUM_SIDES = 6;
    7676        public static Map<String,String> rowCol2StreetsideCellAddressMap = null;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideExportDialog.java

    r34349 r34429  
    1818
    1919import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
    20 import org.openstreetmap.josm.plugins.streetside.StreetsideImportedImage;
    2120import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    2221
     
    4241   */
    4342  public final JRadioButton selected;
    44   /** Button to rewrite all imported images. */
    45   public final JRadioButton rewrite;
    4643  /** Group of button containing all the options. */
    4744  public final ButtonGroup group;
     
    6562
    6663    RewriteButtonAction action = new RewriteButtonAction(this);
    67     this.group = new ButtonGroup();
    68     this.all = new JRadioButton(action);
    69     this.all.setText(tr("Export all images"));
    70     this.sequence = new JRadioButton(action);
    71     this.sequence.setText(tr("Export selected sequence"));
    72     this.selected = new JRadioButton(action);
    73     this.selected.setText(tr("Export selected images"));
    74     this.rewrite = new JRadioButton(action);
    75     this.rewrite.setText(tr("Rewrite imported images"));
    76     this.group.add(this.all);
    77     this.group.add(this.sequence);
    78     this.group.add(this.selected);
    79     this.group.add(this.rewrite);
     64    group = new ButtonGroup();
     65    all = new JRadioButton(action);
     66    all.setText(tr("Export all images"));
     67    sequence = new JRadioButton(action);
     68    sequence.setText(tr("Export selected sequence"));
     69    selected = new JRadioButton(action);
     70    selected.setText(tr("Export selected images"));
     71    group.add(all);
     72    group.add(sequence);
     73    group.add(selected);
    8074    // Some options are disabled depending on the circumstances
    8175    sequence.setEnabled(StreetsideLayer.getInstance().getData().getSelectedImage() instanceof StreetsideImage);
    8276    if (StreetsideLayer.getInstance().getData().getMultiSelectedImages().isEmpty()) {
    83      this.selected.setEnabled(false);
     77     selected.setEnabled(false);
    8478    }
    85     this.rewrite.setEnabled(StreetsideLayer.getInstance().getData().getImages().parallelStream().anyMatch(img -> img instanceof StreetsideImportedImage));
    8679
    87     this.path = new JLabel(tr("Select a directory"));
    88     this.choose = new JButton(tr("Explore"));
    89     this.choose.addActionListener(this);
     80    path = new JLabel(tr("Select a directory"));
     81    choose = new JButton(tr("Explore"));
     82    choose.addActionListener(this);
    9083
    9184    // All options belong to the same JPanel so the are in line.
    9285    JPanel jpanel = new JPanel();
    9386    jpanel.setLayout(new BoxLayout(jpanel, BoxLayout.PAGE_AXIS));
    94     jpanel.add(this.all);
    95     jpanel.add(this.sequence);
    96     jpanel.add(this.selected);
    97     jpanel.add(this.rewrite);
     87    jpanel.add(all);
     88    jpanel.add(sequence);
     89    jpanel.add(selected);
    9890    jpanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    99     this.path.setAlignmentX(Component.CENTER_ALIGNMENT);
    100     this.choose.setAlignmentX(Component.CENTER_ALIGNMENT);
     91    path.setAlignmentX(Component.CENTER_ALIGNMENT);
     92    choose.setAlignmentX(Component.CENTER_ALIGNMENT);
    10193
    10294    add(jpanel);
    103     add(this.path);
    104     add(this.choose);
     95    add(path);
     96    add(choose);
    10597  }
    10698
     
    110102  @Override
    111103  public void actionPerformed(ActionEvent e) {
    112     this.chooser = new JFileChooser();
    113     this.chooser.setCurrentDirectory(new java.io.File(System
     104    chooser = new JFileChooser();
     105    chooser.setCurrentDirectory(new java.io.File(System
    114106        .getProperty("user.home")));
    115     this.chooser.setDialogTitle(tr("Select a directory"));
    116     this.chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    117     this.chooser.setAcceptAllFileFilterUsed(false);
     107    chooser.setDialogTitle(tr("Select a directory"));
     108    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     109    chooser.setAcceptAllFileFilterUsed(false);
    118110
    119     if (this.chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
    120       this.path.setText(this.chooser.getSelectedFile().toString());
    121       this.updateUI();
    122       this.ok.setEnabled(true);
     111    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
     112      path.setText(chooser.getSelectedFile().toString());
     113      updateUI();
     114      ok.setEnabled(true);
    123115    }
    124116  }
     
    148140    }
    149141
     142    @SuppressWarnings("synthetic-access")
    150143    @Override
    151144    public void actionPerformed(ActionEvent arg0) {
    152       StreetsideExportDialog.this.choose
    153           .setEnabled(!StreetsideExportDialog.this.rewrite.isSelected());
    154       if (StreetsideExportDialog.this.rewrite.isSelected()) {
    155         this.lastPath = this.dlg.path.getText();
    156         this.dlg.path.setText(" ");
    157       } else if (this.lastPath != null) {
    158         this.dlg.path.setText(this.lastPath);
     145      choose
     146          .setEnabled(true);
     147      if (lastPath != null) {
     148        dlg.path.setText(lastPath);
    159149      }
    160150    }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideMainDialog.java

    r34428 r34429  
    88import java.io.ByteArrayInputStream;
    99import java.io.IOException;
     10import java.text.MessageFormat;
     11import java.util.Arrays;
    1012import java.util.List;
    1113
     
    1315import javax.swing.AbstractAction;
    1416import javax.swing.Action;
     17import javax.swing.JComponent;
     18import javax.swing.KeyStroke;
    1519import javax.swing.SwingUtilities;
    1620
     
    2428import org.openstreetmap.josm.plugins.streetside.StreetsideDataListener;
    2529import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
    26 import org.openstreetmap.josm.plugins.streetside.StreetsideImportedImage;
    2730import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    2831import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
     
    3134import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache;
    3235import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.ImageInfoHelpPopup;
    33 import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerHelpPopup;
    3436import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
    3537import org.openstreetmap.josm.tools.I18n;
     
    5759        private volatile StreetsideAbstractImage image;
    5860
    59         private ImageInfoHelpPopup imageInfoHelp;
    60 
    61         private StreetsideViewerHelpPopup streetsideViewerHelp;
     61        private final SideButton nextButton = new SideButton(new NextPictureAction());
     62  private final SideButton previousButton = new SideButton(new PreviousPictureAction());
     63  /**
     64   * Button used to jump to the image following the red line
     65   */
     66  public final SideButton redButton = new SideButton(new RedAction());
     67  /**
     68   * Button used to jump to the image following the blue line
     69   */
     70  public final SideButton blueButton = new SideButton(new BlueAction());
     71
     72  private final SideButton playButton = new SideButton(new PlayAction());
     73  private final SideButton pauseButton = new SideButton(new PauseAction());
     74  private final SideButton stopButton = new SideButton(new StopAction());
     75
     76  private ImageInfoHelpPopup imageInfoHelp;
    6277
    6378        /**
     
    98113         * Adds the shortcuts to the buttons.
    99114         */
    100         private void addShortcuts() {
    101                 // next, previous, blueAction and redAction from Mapillary removed
    102         }
     115  private void addShortcuts() {
     116    nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_DOWN"), "next");
     117    nextButton.getActionMap().put("next", new NextPictureAction());
     118    previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_UP"), "previous");
     119    previousButton.getActionMap().put("previous", new PreviousPictureAction());
     120    blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control PAGE_UP"), "blue");
     121    blueButton.getActionMap().put("blue", new BlueAction());
     122    redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control PAGE_DOWN"), "red");
     123    redButton.getActionMap().put("red", new RedAction());
     124  }
    103125
    104126        /**
     
    125147        }
    126148
    127         public synchronized void setStreetsideViewerHelp(StreetsideViewerHelpPopup popup) {
    128                 streetsideViewerHelp = popup;
    129         }
    130 
    131         /**
    132          * @return the streetsideViewerHelp
    133          */
    134         public StreetsideViewerHelpPopup getStreetsideViewerHelp() {
    135                 return streetsideViewerHelp;
    136         }
    137 
    138149        /**
    139150         * Sets a new mode for the dialog.
     
    144155                switch (mode) {
    145156                case WALK:
    146                         createLayout(
    147                                 streetsideImageDisplay,
    148                                 null
    149                                 // TODO: Walk Action for Streetside - re-add buttons here
    150                         );
    151                 case NORMAL:
    152                 default:
    153                         createLayout(
    154                         streetsideImageDisplay,
    155                         null
    156                     );
    157                 }
    158 
    159                 if (MODE.NORMAL.equals(mode)) {
    160                         updateImage();
    161                 }       }
     157      createLayout(
     158        streetsideImageDisplay,
     159        Arrays.asList(playButton, pauseButton, stopButton)
     160      );
     161      break;
     162    case NORMAL:
     163    default:
     164      createLayout(
     165        streetsideImageDisplay,
     166        Arrays.asList(blueButton, previousButton, nextButton, redButton)
     167      );
     168      break;
     169                }
     170                disableAllButtons();
     171    if (MODE.NORMAL.equals(mode)) {
     172      updateImage();
     173    }
     174    revalidate();
     175    repaint();
     176        }
    162177
    163178        /**
     
    201216                        }
    202217
    203                         if (image.getSequence() != null) {
    204                                 StreetsideAbstractImage tempImage = image;
    205                                 while (tempImage.next() != null) {
    206                                         tempImage = tempImage.next();
    207                                         if (tempImage.isVisible()) {
    208                                                 //nextButton.setEnabled(true);
    209                                                 break;
    210                                         }
    211                                 }
    212                         }
    213                         if (image.getSequence() != null) {
    214                                 StreetsideAbstractImage tempImage = image;
    215                                 while (tempImage.previous() != null) {
    216                                         tempImage = tempImage.previous();
    217                                         if (tempImage.isVisible()) {
    218                                                 break;
    219                                         }
    220                                 }
    221                         }
    222218                        if (image instanceof StreetsideImage) {
    223219                                final StreetsideImage streetsideImage = (StreetsideImage) image;
     
    255251
    256252        /**
     253   * Disables all the buttons in the dialog
     254   */
     255  private void disableAllButtons() {
     256    nextButton.setEnabled(false);
     257    previousButton.setEnabled(false);
     258    blueButton.setEnabled(false);
     259    redButton.setEnabled(false);
     260  }
     261
     262        /**
    257263         * Sets a new StreetsideImage to be shown.
    258264         *
     
    272278                        final StringBuilder title = new StringBuilder(I18n.tr(StreetsideMainDialog.BASE_TITLE));
    273279                        if (image instanceof StreetsideImage) {
    274                                 final StreetsideImage streetsideImage = (StreetsideImage) image;
    275                                 if (streetsideImage.getCd() != 0) {
    276                                         title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(streetsideImage.getDate());
    277                                 }
    278                                 setTitle(title.toString());
    279                         } else if (image instanceof StreetsideImportedImage) {
    280                                 final StreetsideImportedImage mapillaryImportedImage = (StreetsideImportedImage) image;
    281                                 title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(mapillaryImportedImage.getFile().getName());
    282                                 title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(mapillaryImportedImage.getDate());
    283                                 setTitle(title.toString());
     280                                title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(MessageFormat.format("(heading {0}°)",Double.toString(image.getHe())));
     281        setTitle(title.toString());
    284282                        }
    285283                }
     
    533531        public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) {
    534532                setImage(newImage);
     533                if (newImage.getSequence() != null && newImage.next()!=null) {
     534      nextButton.setEnabled(true);
     535    }
     536    if (newImage.getSequence() != null && newImage.previous()!=null) {
     537      previousButton.setEnabled(true);
     538    }
    535539                updateImage();
    536540        }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideViewerDialog.java

    r34416 r34429  
    88import org.openstreetmap.josm.gui.SideButton;
    99import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
     10import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerHelpPopup;
    1011import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerPanel;
    1112
     
    2425
    2526        private static StreetsideViewerDialog instance;
     27
     28        // TODO: enable help without StreetsideViewerPanel being a ToggleDialog
     29        private StreetsideViewerHelpPopup streetsideViewerHelpPopup;
    2630
    2731        /**
     
    8185        }
    8286
     87  public void setStreetsideViewerHelpPopup(StreetsideViewerHelpPopup svhp) {
     88    streetsideViewerHelpPopup = svhp;
     89  }
     90
    8391}
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/imageinfo/StreetsideViewerPanel.java

    r34428 r34429  
    3838        private static ThreeSixtyDegreeViewerPanel threeSixtyDegreeViewerPanel;
    3939
     40  private StreetsideViewerHelpPopup streetsideViewerHelp;
     41
    4042        public StreetsideViewerPanel() {
    4143
     
    4345
    4446                SwingUtilities.invokeLater(new Runnable() {
    45                      @Override
     47                     @SuppressWarnings("synthetic-access")
     48        @Override
    4649                     public void run() {
    4750                         initializeAndStartGUI();
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnable.java

    r34428 r34429  
    7777        if (node.get("id") != null && node.get("la") != null && node.get("lo") != null) {
    7878          StreetsideImage image = new StreetsideImage(CubemapUtils.convertDecimal2Quaternary(node.path("id").asLong()), node.path("la").asDouble(), node.get("lo").asDouble());
     79          if(previous!=null) {
     80            image.setPr(Long.parseLong(previous.getId()));
     81            previous.setNe(Long.parseLong(image.getId()));
     82
     83          }
    7984          previous = image;
    8085          image.setAd(node.path("ad").asInt());
    8186          image.setAl(node.path("al").asDouble());
    8287          image.setBl(node.path("bl").asText());
    83           image.setCd(node.path("cd").asLong());
    8488          image.setHe(node.path("he").asDouble());
    8589          image.setMl(node.path("ml").asInt());
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/export/StreetsideExportManager.java

    r34365 r34429  
    77import java.io.IOException;
    88import java.util.HashSet;
    9 import java.util.List;
    109import java.util.Set;
    1110import java.util.concurrent.ArrayBlockingQueue;
     
    1817import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
    1918import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
    20 import org.openstreetmap.josm.plugins.streetside.StreetsideImportedImage;
    2119
    2220/**
     
    6361  }
    6462
    65   /**
    66    * Constructor used to rewrite imported images.
    67    *
    68    * @param images
    69    *          The set of {@link StreetsideImportedImage} object that is going to
    70    *          be rewritten.
    71    * @throws IOException
    72    *           If the file of one of the {@link StreetsideImportedImage} objects
    73    *           doesn't contain a picture.
    74    */
    75   public StreetsideExportManager(List<StreetsideImportedImage> images) throws IOException {
    76     this(null, null);
    77     for (StreetsideImportedImage image : images) {
    78       queue.add(image.getImage());
    79       queueImages.add(image);
    80     }
    81     amount = images.size();
    82   }
    83 
    8463  @Override
    8564  protected void cancel() {
     
    11291          logger.error(e);
    11392        }
    114       } else if (image instanceof StreetsideImportedImage) {
    115         try {
    116           queue.put(((StreetsideImportedImage) image).getImage());
    117           queueImages.put(image);
    118         } catch (InterruptedException e) {
    119           logger.error(e);
    120         }
    12193      }
    12294      try {
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/export/StreetsideExportWriterThread.java

    r34365 r34429  
    1414import org.apache.commons.imaging.ImageReadException;
    1515import org.apache.commons.imaging.ImageWriteException;
    16 import org.apache.commons.imaging.Imaging;
    17 import org.apache.commons.imaging.common.ImageMetadata;
    1816import org.apache.commons.imaging.common.RationalNumber;
    19 import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
    2017import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
    21 import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
    2218import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
    2319import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
     
    2824import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
    2925import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
    30 import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
    31 import org.openstreetmap.josm.plugins.streetside.StreetsideImportedImage;
    3226
    3327/**
     
    8276        img = queue.take();
    8377        mimg = queueImages.take();
    84         if (path == null && mimg instanceof StreetsideImportedImage) {
    85           String path = ((StreetsideImportedImage) mimg).getFile().getPath();
    86           finalPath = path.substring(0, path.lastIndexOf('.'));
    87         } else if (mimg instanceof StreetsideImage) {
    88           finalPath = path + '/' + ((StreetsideImage) mimg).getId();
    89         } else if (mimg instanceof StreetsideImportedImage) {
    90           finalPath = path + '/' + ((StreetsideImportedImage) mimg).getFile().getName();
    91         }
     78
    9279
    9380        // Transforms the image into a byte array.
     
    10188        TiffOutputDirectory gpsDirectory;
    10289        // If the image is imported, loads the rest of the EXIF data.
    103         if (mimg instanceof StreetsideImportedImage) {
    104           final ImageMetadata metadata = Imaging
    105               .getMetadata(((StreetsideImportedImage) mimg).getFile());
    106           final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
    107           if (null != jpegMetadata) {
    108             final TiffImageMetadata exif = jpegMetadata.getExif();
    109             if (null != exif) {
    110               outputSet = exif.getOutputSet();
    111             }
    112           }
    113         }
     90
    11491        if (null == outputSet) {
    11592          outputSet = new TiffOutputSet();
     
    127104
    128105        exifDirectory.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
    129         if (mimg instanceof StreetsideImportedImage) {
    130           exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL,
    131               mimg.getDate("yyyy/MM/dd HH:mm:ss"));
    132         } else if (mimg instanceof StreetsideImage) {
    133           exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL,
    134               mimg.getDate("yyyy/MM/dd HH/mm/ss"));
    135         }
     106
    136107        outputSet.setGPSInDegrees(mimg.getMovingLatLon().lon(), mimg.getMovingLatLon().lat());
    137108        OutputStream os = new BufferedOutputStream(new FileOutputStream(finalPath + ".jpg"));
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/api/JsonStreetsideSequencesDecoder.java

    r34325 r34429  
    9595      result.setPbn(image.getPbn());
    9696      result.setRn(image.getRn());
    97       result.setCd(image.getCd());
    9897    }
    9998    return result;
Note: See TracChangeset for help on using the changeset viewer.