Changeset 31837 in osm for applications/editors


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

[mapillary] Convert unnecessary private fields to local variables

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

Legend:

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

    r31816 r31837  
    3535  private static final long serialVersionUID = 4995924098228081806L;
    3636
    37   private JFileChooser chooser;
    38 
    3937  /**
    4038   * Main constructor.
     
    5149  @Override
    5250  public void actionPerformed(ActionEvent e) {
    53     this.chooser = new JFileChooser();
     51    JFileChooser chooser = new JFileChooser();
    5452    File startDirectory = new File(Main.pref.get("mapillary.start-directory",
    5553        System.getProperty("user.home")));
    56     this.chooser.setCurrentDirectory(startDirectory);
    57     this.chooser.setDialogTitle(tr("Select pictures"));
    58     this.chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    59     this.chooser.setAcceptAllFileFilterUsed(false);
    60     this.chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg", "jpeg", "png"));
    61     this.chooser.setMultiSelectionEnabled(true);
    62     if (this.chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
     54    chooser.setCurrentDirectory(startDirectory);
     55    chooser.setDialogTitle(tr("Select pictures"));
     56    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
     57    chooser.setAcceptAllFileFilterUsed(false);
     58    chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg", "jpeg", "png"));
     59    chooser.setMultiSelectionEnabled(true);
     60    if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
    6361      List<MapillaryAbstractImage> images = new ArrayList<>();
    64       for (int i = 0; i < this.chooser.getSelectedFiles().length; i++) {
    65         File file = this.chooser.getSelectedFiles()[i];
     62      for (File file : chooser.getSelectedFiles()) {
    6663        Main.pref.put("mapillary.start-directory", file.getParent());
    6764        MapillaryLayer.getInstance();
     
    6966          if (file.listFiles() == null)
    7067            continue;
    71           for (int j = 0; j < file.listFiles().length; j++) {
    72             String extension = MapillaryUtils.getExtension(file.listFiles()[j]);
     68          for (File innerFile : file.listFiles()) {
     69            String extension = MapillaryUtils.getExtension(innerFile);
    7370            try {
    7471              if ("jpg".equals(extension) || "jpeg".equals(extension))
    75                 images.add(MapillaryUtils.readJPG(file.listFiles()[j]));
     72                images.add(MapillaryUtils.readJPG(innerFile));
    7673              else if ("png".equals(extension))
    77                 images.add(MapillaryUtils.readPNG(file.listFiles()[j]));
     74                images.add(MapillaryUtils.readPNG(innerFile));
    7875            } catch (ImageReadException | IOException | NullPointerException e1) {
    7976              Main.error(e1);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java

    r31816 r31837  
    3838  private static final long serialVersionUID = -9190217809965894878L;
    3939
    40   private JFileChooser chooser;
    41 
    4240  private List<MapillaryAbstractImage> images;
    4341
     
    5957    this.images = new LinkedList<>();
    6058
    61     this.chooser = new JFileChooser();
     59    JFileChooser chooser = new JFileChooser();
    6260    File startDirectory = new File(Main.pref.get("mapillary.start-directory",
    6361        System.getProperty("user.home")));
    64     this.chooser.setCurrentDirectory(startDirectory);
    65     this.chooser.setDialogTitle(tr("Select pictures"));
    66     this.chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    67     this.chooser.setAcceptAllFileFilterUsed(false);
    68     this.chooser.addChoosableFileFilter(new FileNameExtensionFilter("images",
    69         "jpg", "jpeg"));
    70     this.chooser.setMultiSelectionEnabled(true);
     62    chooser.setCurrentDirectory(startDirectory);
     63    chooser.setDialogTitle(tr("Select pictures"));
     64    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
     65    chooser.setAcceptAllFileFilterUsed(false);
     66    chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg", "jpeg"));
     67    chooser.setMultiSelectionEnabled(true);
    7168
    72     if (this.chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
    73       for (int i = 0; i < this.chooser.getSelectedFiles().length; i++) {
    74         File file = this.chooser.getSelectedFiles()[i];
     69    if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
     70      for (File file : chooser.getSelectedFiles()) {
    7571        if (file == null)
    7672          break;
     
    7874        MapillaryLayer.getInstance();
    7975        if (file.isDirectory()) {
    80           for (int j = 0; j < file.listFiles().length; j++) {
    81             String extension = MapillaryUtils.getExtension(file.listFiles()[j]);
     76          for (File file2 : file.listFiles()) {
     77            String extension = MapillaryUtils.getExtension(file2);
    8278            try {
    8379              if ("jpg".equals(extension) || "jpeg".equals(extension))
    84                 MapillaryUtils.readJPG(file.listFiles()[j], true);
     80                MapillaryUtils.readJPG(file2, true);
    8581            } catch (ImageReadException | NullPointerException | IOException e) {
    8682              Main.error(e);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r31812 r31837  
    4747
    4848  private static final String[] TIME_LIST = { tr("All"), tr("Years"), tr("Months"), tr("Days") };
    49 
    50   private final JPanel panel;
    5149
    5250  /** Spinner to choose the range of dates. */
     
    9088            KeyEvent.VK_M, Shortcut.NONE), 200);
    9189
    92     this.panel = new JPanel();
    93 
    9490    this.signChooser.setEnabled(false);
    9591    JPanel signChooserPanel = new JPanel();
     
    115111    this.downloaded.setSelected(true);
    116112
     113    JPanel panel = new JPanel();
    117114    JPanel col1 = new JPanel(new GridLayout(2, 1));
    118115    col1.add(this.downloaded);
    119116    col1.add(fromPanel);
    120     this.panel.add(col1);
     117    panel.add(col1);
    121118    JPanel col2 = new JPanel(new GridLayout(2, 1));
    122119    col2.add(this.imported);
    123120    col2.add(userSearchPanel);
    124     this.panel.add(col2);
     121    panel.add(col2);
    125122    JPanel col3 = new JPanel(new GridLayout(2, 1));
    126123    col3.add(this.onlySigns);
    127124    col3.add(signChooserPanel);
    128     this.panel.add(col3);
    129 
    130     createLayout(this.panel, true,
    131         Arrays.asList(new SideButton[] { this.updateButton, this.resetButton }));
     125    panel.add(col3);
     126
     127    createLayout(panel, true, Arrays.asList(new SideButton[] { updateButton, resetButton }));
    132128  }
    133129
     
    203199      Long currentTime = currentTime();
    204200      long[] timeFactor = new long[]{
    205           31536000000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year
    206           2592000000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month
    207           86400000 // = 24 * 60 * 60 * 1000 = number of ms in a day
     201          31_536_000_000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year
     202          2_592_000_000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month
     203          86_400_000 // = 24 * 60 * 60 * 1000 = number of ms in a day
    208204      };
    209205      for (int i = 1; i <= 3; i++) {
     
    235231  }
    236232
    237   private static boolean checkSign(MapillaryImage img, JCheckBox signCheckBox,
    238       String singString) {
     233  private static boolean checkSign(MapillaryImage img, JCheckBox signCheckBox, String singString) {
    239234    boolean contains = false;
    240235    for (String sign : img.getSigns()) {
     
    242237        contains = true;
    243238    }
    244     if (contains == signCheckBox.isSelected() && contains)
    245       return true;
    246     return false;
     239    return contains == signCheckBox.isSelected() && contains;
    247240  }
    248241
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThread.java

    r31828 r31837  
    122122
    123123  private boolean isInside(MapillaryAbstractImage image) {
    124     for (int i = 0; i < MapillaryLayer.getInstance().getData().bounds.size(); i++)
    125       if (MapillaryLayer.getInstance().getData().bounds.get(i).contains(image.getLatLon()))
     124    for (Bounds b : MapillaryLayer.getInstance().getData().bounds) {
     125      if (b.contains(image.getLatLon())) {
    126126        return true;
     127      }
     128    }
    127129    return false;
    128130  }
Note: See TracChangeset for help on using the changeset viewer.