Changeset 31974 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-01-11T23:05:25+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Fix some more minor code issues

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

Legend:

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

    r31972 r31974  
    111111   * @param lis Listener to be added.
    112112   */
    113   public void addListener(MapillaryDataListener lis) {
     113  public final void addListener(MapillaryDataListener lis) {
    114114    this.listeners.add(lis);
    115115  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31972 r31974  
    6868 *
    6969 */
    70 public class MapillaryLayer extends AbstractModifiableLayer implements
     70public final class MapillaryLayer extends AbstractModifiableLayer implements
    7171    DataSetListener, EditLayerChangeListener, LayerChangeListener {
    7272
     
    371371   * Draws the highlight of the icon.
    372372   *
    373    * @param g
    374    * @param p
    375    *          The {@link Point} where the image must be set.
    376    * @param size
    377    *          The width in pixels of the highlight.
     373   * @param g  the graphics context
     374   * @param p  the {@link Point} where the image must be set.
     375   * @param size  the width in pixels of the highlight.
    378376   */
    379377  private void drawPointHighlight(Graphics2D g, Point p, int size) {
     
    396394   * image.
    397395   *
    398    * @param g
    399    * @param image
    400    *          The {@link MapillaryAbstractImage} which is being drown.
    401    * @param icon
    402    *          The {@link ImageIcon} that represents the image.
    403    * @param p
    404    *          The P¡{@link Point} when the image lies.
     396   * @param g  the graphics context
     397   * @param image  The {@link MapillaryAbstractImage} which is being drown.
     398   * @param icon  The {@link ImageIcon} that represents the image.
     399   * @param p  The P¡{@link Point} when the image lies.
    405400   */
    406401  private void draw(Graphics2D g, MapillaryAbstractImage image, ImageIcon icon, Point p) {
     
    531526  @Override
    532527  public void primitivesAdded(PrimitivesAddedEvent event) {
     528    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    533529  }
    534530
    535531  @Override
    536532  public void primitivesRemoved(PrimitivesRemovedEvent event) {
     533    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    537534  }
    538535
    539536  @Override
    540537  public void tagsChanged(TagsChangedEvent event) {
     538    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    541539  }
    542540
    543541  @Override
    544542  public void nodeMoved(NodeMovedEvent event) {
     543    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    545544  }
    546545
    547546  @Override
    548547  public void wayNodesChanged(WayNodesChangedEvent event) {
     548    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    549549  }
    550550
    551551  @Override
    552552  public void relationMembersChanged(RelationMembersChangedEvent event) {
     553    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    553554  }
    554555
    555556  @Override
    556557  public void otherDatasetChange(AbstractDatasetChangedEvent event) {
     558    // Required by DataSetListener. But we are not interested in what changed, only _that_ something changed.
    557559  }
    558560
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java

    r31838 r31974  
    88import java.awt.event.KeyEvent;
    99import java.util.ArrayList;
     10import java.util.List;
    1011
    1112import javax.swing.JDialog;
     
    3233
    3334  private WalkThread thread = null;
    34   private final ArrayList<WalkListener> listeners = new ArrayList<>();
     35  private final List<WalkListener> listeners = new ArrayList<>();
    3536
    3637  /**
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java

    r31811 r31974  
    8282    this.group.add(this.rewrite);
    8383    // Some options are disabled depending on the circumstances
    84     if (MapillaryLayer.getInstance().getData().getSelectedImage() == null
    85         || !(MapillaryLayer.getInstance().getData().getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryLayer
    86             .getInstance().getData().getSelectedImage()).getSequence() != null)) {
     84    if (!(MapillaryLayer.getInstance().getData().getSelectedImage() instanceof MapillaryImage)
     85        || ((MapillaryImage) MapillaryLayer.getInstance().getData().getSelectedImage()).getSequence() == null
     86    ) {
    8787      this.sequence.setEnabled(false);
    8888    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java

    r31972 r31974  
    1414import java.util.ArrayList;
    1515import java.util.Arrays;
     16import java.util.List;
    1617import java.util.concurrent.ConcurrentHashMap;
    1718
     
    141142    this.redoButton.setEnabled(true);
    142143    this.undoButton.setEnabled(true);
    143     ArrayList<MapillaryCommand> commands = MapillaryRecord.getInstance().commandList;
     144    List<MapillaryCommand> commands = MapillaryRecord.getInstance().commandList;
    144145    int position = MapillaryRecord.getInstance().position;
    145146    ArrayList<MapillaryCommand> undoCommands = new ArrayList<>();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java

    r31951 r31974  
    33
    44import java.util.ArrayList;
     5import java.util.List;
    56
    67import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
     
    1819  private static MapillaryRecord instance;
    1920
    20   private final ArrayList<MapillaryRecordListener> listeners = new ArrayList<>();
     21  private final List<MapillaryRecordListener> listeners = new ArrayList<>();
    2122
    2223  /** The set of commands that have taken place or that have been undone. */
    23   public ArrayList<MapillaryCommand> commandList;
     24  public List<MapillaryCommand> commandList;
    2425  /** Last written command. */
    2526  public int position;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r31972 r31974  
    6969   * Returns the current download mode.
    7070   *
    71    * @return 0 - automatic; 1 - semiautomatic; 2 - manual.
     71   * @return the currently enabled of the available {@link MODES}
    7272   */
    7373  public static MapillaryDownloader.MODES getMode() {
    74     if (Main.pref.get("mapillary.download-mode").equals(MODES.Automatic.toString())
    75         && (!MapillaryLayer.hasInstance() || !MapillaryLayer.getInstance().tempSemiautomatic))
    76       return MODES.Automatic;
    77     else if (Main.pref.get("mapillary.download-mode").equals(MODES.Semiautomatic.toString())
    78         || (MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic))
     74    String downloadMode = Main.pref.get("mapillary.download-mode", MODES.Automatic.toString());
     75    boolean isTempSemiautomatic = MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic;
     76    if (MODES.Semiautomatic.toString().equals(downloadMode) || isTempSemiautomatic)
    7977      return MODES.Semiautomatic;
    80     else if (Main.pref.get("mapillary.download-mode").equals(MODES.Manual.toString()))
     78    else if (MODES.Manual.toString().equals(downloadMode))
    8179      return MODES.Manual;
    82     else if ("".equals(Main.pref.get("mapillary.download-mode")))
     80    else if (MODES.Automatic.toString().equals(downloadMode))
    8381      return MODES.Automatic;
    8482    else
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java

    r31951 r31974  
    9595    while (!this.completeExecutor.isShutdown()) {
    9696      this.completeExecutor.execute(new MapillaryImageInfoDownloadThread(completeExecutor, bounds, page));
    97       while (this.completeExecutor.getQueue().remainingCapacity() == 0)
     97      while (this.completeExecutor.getQueue().remainingCapacity() == 0) {
    9898        Thread.sleep(100);
     99      }
    99100      page++;
    100101    }
     
    112113    while (!this.signsExecutor.isShutdown()) {
    113114      this.signsExecutor.execute(new MapillaryTrafficSignDownloadThread(this.signsExecutor, bounds, page));
    114       while (this.signsExecutor.getQueue().remainingCapacity() == 0)
     115      while (this.signsExecutor.getQueue().remainingCapacity() == 0) {
    115116        Thread.sleep(100);
     117      }
    116118      page++;
    117119    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java

    r31787 r31974  
    4444    if (this.data.getHighlightedImage() == null)
    4545      return;
    46     if (this.lastClick == null
    47         && this.data.getHighlightedImage() instanceof MapillaryImportedImage) {
     46    if (this.lastClick == null && this.data.getHighlightedImage() instanceof MapillaryImportedImage) {
    4847      this.lastClick = (MapillaryImportedImage) this.data.getHighlightedImage();
    4948    } else if (this.lastClick != null
    5049        && this.data.getHighlightedImage() instanceof MapillaryImportedImage) {
    51       if (((this.data.getHighlightedImage().previous() == null && this.lastClick
    52           .next() == null) || (this.data.getHighlightedImage().next() == null && this.lastClick
    53           .previous() == null))
    54           && (this.data.getHighlightedImage().getSequence() != this.lastClick
    55               .getSequence() || this.lastClick.getSequence() == null)) {
     50      if (
     51        (this.data.getHighlightedImage().previous() == null && this.lastClick.next() == null
     52          || this.data.getHighlightedImage().next() == null && this.lastClick.previous() == null)
     53        && (this.data.getHighlightedImage().getSequence() != this.lastClick.getSequence() || this.lastClick.getSequence() == null)
     54      ) {
    5655
    5756        MapillaryRecord.getInstance().addCommand(
     
    5958                this.lastClick, this.data.getHighlightedImage() })));
    6059      } else if (this.lastClick.next() == this.data.getHighlightedImage()
    61           || this.lastClick.previous() == this.data.getHighlightedImage())
     60          || this.lastClick.previous() == this.data.getHighlightedImage()) {
    6261        MapillaryRecord.getInstance().addCommand(
    6362            new CommandUnjoin(Arrays.asList(new MapillaryAbstractImage[] {
    6463                this.lastClick, this.data.getHighlightedImage() })));
     64      }
    6565      this.lastClick = null;
    6666    }
    67     if (Main.main != null)
    68       MapillaryData.dataUpdated();
     67    MapillaryData.dataUpdated();
    6968  }
    7069
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryLoginListener.java

    r31810 r31974  
    1313   * @param username the username that the user is now logged in with
    1414   */
    15   public void onLogin(final String username);
     15  void onLogin(final String username);
    1616  /**
    1717   * Should be called whenever the user logs out of a mapillary account.
    1818   * E.g. for updating the GUI to reflect the login status.
    1919   */
    20   public void onLogout();
     20  void onLogout();
    2121}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31972 r31974  
    99import java.io.OutputStream;
    1010import java.util.HashMap;
     11import java.util.Map;
    1112import java.util.Set;
    1213import java.util.UUID;
     
    5657public class UploadUtils {
    5758
     59  private UploadUtils() {
     60    // Private constructor to avoid instantiation.
     61  }
     62
    5863  /**
    5964   * Required keys for POST
     
    145150          throws ImageReadException, IOException, ImageWriteException {
    146151    TiffOutputSet outputSet = null;
    147     TiffOutputDirectory exifDirectory = null;
    148     TiffOutputDirectory gpsDirectory = null;
    149     TiffOutputDirectory rootDirectory = null;
     152    TiffOutputDirectory exifDirectory;
     153    TiffOutputDirectory gpsDirectory;
     154    TiffOutputDirectory rootDirectory;
    150155
    151156    // If the image is imported, loads the rest of the EXIF data.
     
    216221            + image.getCa() + "_" + image.getCapturedAt() + ".jpg";
    217222
    218     String policy = null;
    219     String signature = null;
     223    String policy;
     224    String signature;
    220225    policy = MapillaryUser.getSecrets().get("images_policy");
    221226    signature = MapillaryUser.getSecrets().get("images_hash");
    222227
    223     HashMap<String, String> hash = new HashMap<>();
     228    Map<String, String> hash = new HashMap<>();
    224229    hash.put("key", key);
    225230    hash.put("AWSAccessKeyId", "AKIAI2X3BJAT2W75HILA");
     
    241246   * @throws IllegalArgumentException if the hash doesn't contain all the needed keys.
    242247   */
    243   public static void uploadFile(File file, HashMap<String, String> hash)
    244           throws IOException {
     248  public static void uploadFile(File file, Map<String, String> hash) throws IOException {
    245249    HttpClientBuilder builder = HttpClientBuilder.create();
    246250    HttpClient httpClient = builder.build();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r31972 r31974  
    363363        zoomBounds = new Bounds(new LatLon(0, 0));
    364364      } else {
     365        zoomBounds = new Bounds(images.iterator().next().getLatLon());
    365366        for (MapillaryAbstractImage img : images) {
    366           if (zoomBounds == null) {
    367             zoomBounds = new Bounds(img.getLatLon());
    368           } else
    369             zoomBounds.extend(img.getLatLon());
     367          zoomBounds.extend(img.getLatLon());
    370368        }
    371369      }
Note: See TracChangeset for help on using the changeset viewer.