Changeset 31840 in osm


Ignore:
Timestamp:
2015-12-16T17:17:09+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Improve legibility and fix minor 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/MapillaryLayer.java

    r31802 r31840  
    477477      if (image.getLatLon().greatCircleDistance(selectedCoords) < SEQUENCE_MAX_JUMP_DISTANCE
    478478          && selected.getSequence() != image.getSequence()) {
    479         if ((ret[0] == null && ret[1] == null)
    480             || (image.getLatLon().greatCircleDistance(selectedCoords) < distances[0] && (ret[1] == null || image
    481                 .getSequence() != ret[1].getSequence()))) {
     479        if (
     480            ret[0] == null && ret[1] == null
     481            || image.getLatLon().greatCircleDistance(selectedCoords) < distances[0]
     482            && (ret[1] == null || image.getSequence() != ret[1].getSequence())
     483        ) {
    482484          ret[0] = image;
    483485          distances[0] = image.getLatLon().greatCircleDistance(selectedCoords);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java

    r31797 r31840  
    2828   */
    2929  public MapillaryDownloadAction() {
    30     super(tr("Mapillary"), MapillaryPlugin.getProvider("icon24.png"),
    31         tr("Create Mapillary layer"), Shortcut.registerShortcut("Mapillary",
    32             tr("Start Mapillary layer"), KeyEvent.VK_COMMA, Shortcut.SHIFT),
    33         false, "mapillaryDownload", false);
     30    super(
     31        tr("Mapillary"),
     32        MapillaryPlugin.getProvider("icon24.png"),
     33        tr("Create Mapillary layer"),
     34        Shortcut.registerShortcut("Mapillary", tr("Start Mapillary layer"), KeyEvent.VK_COMMA, Shortcut.SHIFT),
     35        false,
     36        "mapillaryDownload",
     37        false
     38    );
    3439    this.setEnabled(false);
    3540  }
     
    3843  public void actionPerformed(ActionEvent arg0) {
    3944    MapillaryLayer.getInstance();
    40     if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance())
     45    if (Main.map.mapView.getActiveLayer() == MapillaryLayer.getInstance()) {
     46      Main.map.mapView.setActiveLayer(Main.map.mapView.getEditLayer());
     47    } else {
    4148      Main.map.mapView.setActiveLayer(MapillaryLayer.getInstance());
    42     else
    43       Main.map.mapView.setActiveLayer(Main.map.mapView.getEditLayer());
     49    }
    4450  }
    4551}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java

    r31816 r31840  
    8080            if (!images.contains(image))
    8181              images.addAll(((MapillaryImage) image).getSequence().getImages());
    82           } else
     82          } else {
    8383            images.add(image);
     84          }
    8485        export(images);
    8586      } else if (this.dialog.group.isSelected(this.dialog.selected.getModel())) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java

    r31837 r31840  
    3939   */
    4040  public MapillaryImportAction() {
    41     super(tr("Import pictures"), MapillaryPlugin.getProvider("icon24.png"),
    42         tr("Import local pictures"), Shortcut.registerShortcut(
    43             "Import Mapillary", tr("Import pictures into Mapillary layer"),
    44             KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryImport",
     41    super(
     42        tr("Import pictures"),
     43        MapillaryPlugin.getProvider("icon24.png"),
     44        tr("Import local pictures"),
     45        Shortcut.registerShortcut(
     46            "Import Mapillary",
     47            tr("Import pictures into Mapillary layer"),
     48            KeyEvent.CHAR_UNDEFINED,
     49            Shortcut.NONE
     50        ),
     51        false,
     52        "mapillaryImport",
    4553        false);
    4654    this.setEnabled(false);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/CacheUtils.java

    r31797 r31840  
    6363        break;
    6464      case FULL_IMAGE:
     65      default:
    6566        submit(img.getKey(), MapillaryCache.Type.FULL_IMAGE, ignoreDownload);
    6667        break;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java

    r31811 r31840  
    132132   * @return The unique instance of the class.
    133133   */
    134   public static MapillaryHistoryDialog getInstance() {
     134  public static synchronized MapillaryHistoryDialog getInstance() {
    135135    if (instance == null)
    136136      instance = new MapillaryHistoryDialog();
     
    229229
    230230    @Override
    231     public Component getTreeCellRendererComponent(JTree tree, Object value,
    232         boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    233       super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row,
    234           hasFocus);
     231    public Component getTreeCellRendererComponent(
     232        JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus
     233    ) {
     234      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    235235      setIcon(ImageProvider.get("data/node.png"));
    236236      return this;
     
    249249    @Override
    250250    public void mouseClicked(MouseEvent e) {
     251      // Method is enforced by MouseListener, but (currently) not needed
    251252    }
    252253
    253254    @Override
    254255    public void mouseEntered(MouseEvent e) {
     256      // Method is enforced by MouseListener, but (currently) not needed
    255257    }
    256258
    257259    @Override
    258260    public void mouseExited(MouseEvent e) {
     261      // Method is enforced by MouseListener, but (currently) not needed
    259262    }
    260263
     
    262265    public void mousePressed(MouseEvent e) {
    263266      if (e.getClickCount() == 2) {
    264         if (MapillaryHistoryDialog.this.undoTree.getSelectionPath() != null) {
    265           MapillaryCommand cmd = MapillaryHistoryDialog.this.map
    266               .get(MapillaryHistoryDialog.this.undoTree.getSelectionPath()
    267                   .getLastPathComponent());
    268           if (!(cmd instanceof CommandDelete))
     267        if (undoTree.getSelectionPath() == null) {
     268          MapillaryUtils.showPictures(map.get(redoTree.getSelectionPath().getLastPathComponent()).images, true);
     269        } else {
     270          MapillaryCommand cmd = map.get(undoTree.getSelectionPath().getLastPathComponent());
     271          if (!(cmd instanceof CommandDelete)) {
    269272            MapillaryUtils.showPictures(cmd.images, true);
    270         } else
    271           MapillaryUtils.showPictures(MapillaryHistoryDialog.this.map
    272               .get(MapillaryHistoryDialog.this.redoTree.getSelectionPath()
    273                   .getLastPathComponent()).images, true);
     273          }
     274        }
    274275      }
    275276    }
     
    277278    @Override
    278279    public void mouseReleased(MouseEvent e) {
     280      // Method is enforced by MouseListener, but (currently) not needed
    279281    }
    280282  }
     
    284286    private JTree source;
    285287
    286     private UndoRedoSelectionListener(JTree source) {
     288    protected UndoRedoSelectionListener(JTree source) {
    287289      this.source = source;
    288290    }
     
    290292    @Override
    291293    public void valueChanged(TreeSelectionEvent e) {
    292       if (this.source == MapillaryHistoryDialog.this.undoTree) {
    293         MapillaryHistoryDialog.this.redoTree.getSelectionModel()
    294             .removeTreeSelectionListener(
    295                 MapillaryHistoryDialog.this.redoSelectionListener);
    296         MapillaryHistoryDialog.this.redoTree.clearSelection();
    297         MapillaryHistoryDialog.this.redoTree.getSelectionModel()
    298             .addTreeSelectionListener(
    299                 MapillaryHistoryDialog.this.redoSelectionListener);
    300       }
    301       if (this.source == MapillaryHistoryDialog.this.redoTree) {
    302         MapillaryHistoryDialog.this.undoTree.getSelectionModel()
    303             .removeTreeSelectionListener(
    304                 MapillaryHistoryDialog.this.undoSelectionListener);
    305         MapillaryHistoryDialog.this.undoTree.clearSelection();
    306         MapillaryHistoryDialog.this.undoTree.getSelectionModel()
    307             .addTreeSelectionListener(
    308                 MapillaryHistoryDialog.this.undoSelectionListener);
     294      if (this.source == undoTree) {
     295        redoTree.getSelectionModel().removeTreeSelectionListener(redoSelectionListener);
     296        redoTree.clearSelection();
     297        redoTree.getSelectionModel().addTreeSelectionListener(redoSelectionListener);
     298      }
     299      if (this.source == redoTree) {
     300        undoTree.getSelectionModel().removeTreeSelectionListener(undoSelectionListener);
     301        undoTree.clearSelection();
     302        undoTree.getSelectionModel().addTreeSelectionListener(undoSelectionListener);
    309303      }
    310304    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java

    r31815 r31840  
    452452   * @return the part of compRect with the same width/height ratio as the image
    453453   */
    454   static Rectangle calculateDrawImageRectangle(Rectangle imgRect, Rectangle compRect) {
     454  private static Rectangle calculateDrawImageRectangle(Rectangle imgRect, Rectangle compRect) {
    455455    int x = 0;
    456456    int y = 0;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandDelete.java

    r31811 r31840  
    66import java.util.HashMap;
    77import java.util.List;
     8import java.util.Map;
    89
    910import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
     
    1819public class CommandDelete extends MapillaryExecutableCommand {
    1920
    20   private final HashMap<MapillaryAbstractImage, Integer> changesHash = new HashMap<>();
     21  private final Map<MapillaryAbstractImage, Integer> changesHash = new HashMap<>();
    2122
    2223  /**
     
    3233  @Override
    3334  public void sum(MapillaryCommand command) {
     35    // TODO: Implement
    3436  }
    3537
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/MapillaryCommand.java

    r31788 r31840  
    2424   */
    2525  public MapillaryCommand(List<MapillaryAbstractImage> images) {
    26     this.images = new ArrayList<MapillaryAbstractImage>(images);
     26    this.images = new ArrayList<>(images);
    2727  }
    2828
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r31833 r31840  
    55
    66import java.util.ArrayList;
     7import java.util.List;
    78import java.util.concurrent.ArrayBlockingQueue;
    89import java.util.concurrent.ThreadPoolExecutor;
     
    3132
    3233  /** All the Threads that have been run. Used to interrupt them properly. */
    33   private static ArrayList<Thread> threads = new ArrayList<>();
     34  private static List<Thread> threads = new ArrayList<>();
    3435
    3536  /** Max area to be downloaded */
    36   public static final double MAX_AREA = Main.pref.getDouble(
    37       "mapillary.max-download-area", 0.015);
     37  public static final double MAX_AREA = Main.pref.getDouble("mapillary.max-download-area", 0.015);
    3838
    3939  /** Executor that will run the petitions. */
     
    175175  private static boolean isAreaTooBig() {
    176176    double area = 0;
    177     for (Bounds bounds : Main.map.mapView.getEditLayer().data
    178         .getDataSourceBounds()) {
     177    for (Bounds bounds : Main.map.mapView.getEditLayer().data.getDataSourceBounds()) {
    179178      area += bounds.getArea();
    180179    }
    181     if (area > MAX_AREA)
    182       return true;
    183     return false;
     180    return area > MAX_AREA;
    184181  }
    185182
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/export/MapillaryExportWriterThread.java

    r31797 r31840  
    8585          String path = ((MapillaryImportedImage) mimg).getFile().getPath();
    8686          finalPath = path.substring(0, path.lastIndexOf('.'));
    87         } else if (mimg instanceof MapillaryImage)
    88           finalPath = this.path + "/" + ((MapillaryImage) mimg).getKey();
    89         else if (mimg instanceof MapillaryImportedImage)
    90           finalPath = this.path + "/"
    91               + ((MapillaryImportedImage) mimg).getFile().getName();
     87        } else if (mimg instanceof MapillaryImage) {
     88          finalPath = this.path + '/' + ((MapillaryImage) mimg).getKey();
     89        } else if (mimg instanceof MapillaryImportedImage) {
     90          finalPath = this.path + '/' + ((MapillaryImportedImage) mimg).getFile().getName();
     91        }
    9292
    9393        // Transforms the image into a byte array.
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31811 r31840  
    6060    private final UUID uuid;
    6161    private final boolean delete;
    62     ThreadPoolExecutor ex;
     62    private ThreadPoolExecutor ex;
    6363
    6464    private SequenceUploadThread(List<MapillaryAbstractImage> images,
Note: See TracChangeset for help on using the changeset viewer.