Changeset 31972 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-01-11T16:17:06+01:00 (9 years ago)
Author:
floscher
Message:

Fix several code style issues

Location:
applications/editors/josm/plugins/mapillary
Files:
19 edited

Legend:

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

    r31909 r31972  
    55import java.util.Calendar;
    66import java.util.Date;
     7import java.util.Locale;
    78
    89import org.openstreetmap.josm.Main;
     
    118119  public String getDate(String format) {
    119120    final Date date = new Date(getCapturedAt());
    120 
    121     final SimpleDateFormat formatter = new SimpleDateFormat(format);
     121    final SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
    122122    formatter.setTimeZone(Calendar.getInstance().getTimeZone());
    123123    return formatter.format(date);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31951 r31972  
    2222public class MapillaryData {
    2323
    24   private Set<MapillaryAbstractImage> images;
     24  private final Set<MapillaryAbstractImage> images;
    2525  /**
    2626   * The image currently selected, this is the one being shown.
     
    123123  public void addMultiSelectedImage(MapillaryAbstractImage image) {
    124124    if (!this.multiSelectedImages.contains(image)) {
    125       if (this.getSelectedImage() != null)
     125      if (this.getSelectedImage() == null)
     126        this.setSelectedImage(image);
     127      else
    126128        this.multiSelectedImages.add(image);
    127       else
    128         this.setSelectedImage(image);
    129129    }
    130130    if (Main.main != null)
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31951 r31972  
    357357      } else if (imageAbs instanceof MapillaryImportedImage) {
    358358        MapillaryImportedImage image = (MapillaryImportedImage) imageAbs;
    359         ImageIcon icon;
    360         if (!this.data.getMultiSelectedImages().contains(image))
    361           icon = MapillaryPlugin.MAP_ICON_IMPORTED;
    362         else
    363           icon = MapillaryPlugin.MAP_ICON_SELECTED;
     359        ImageIcon icon = this.data.getMultiSelectedImages().contains(image)
     360            ? MapillaryPlugin.MAP_ICON_SELECTED
     361            : MapillaryPlugin.MAP_ICON_IMPORTED;
    364362        draw(g, image, icon, p);
    365363      }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31832 r31972  
    273273   */
    274274  public static ImageProvider getProvider(String s) {
    275     if (Main.main == null)
     275    if (Main.main == null) {
    276276      return null;
    277     else
    278       return new ImageProvider(s);
     277    }
     278    return new ImageProvider(s);
    279279  }
    280280}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java

    r31833 r31972  
    3434  public FinishedUploadDialog() {
    3535    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    36     JLabel text = new JLabel(tr("Uploaded {0} images", PluginState.imagesUploaded));
     36    JLabel text = new JLabel(tr("Uploaded {0} images", PluginState.getImagesUploaded()));
    3737    text.setAlignmentX(Component.CENTER_ALIGNMENT);
    3838    this.add(text);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java

    r31840 r31972  
    284284  private class UndoRedoSelectionListener implements TreeSelectionListener {
    285285
    286     private JTree source;
     286    private final JTree source;
    287287
    288288    protected UndoRedoSelectionListener(JTree source) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java

    r31909 r31972  
    579579                : new GridLayout(1, buttons.size()));
    580580        this.buttonsPanel.add(buttonRowPanel);
    581         for (SideButton button : buttons)
     581        for (SideButton button : buttons) {
    582582          buttonRowPanel.add(button);
     583        }
    583584      }
    584585      panel.add(this.buttonsPanel, BorderLayout.NORTH);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordListener.java

    r31787 r31972  
    1313   * Fired when any command is undone or redone.
    1414   */
    15   public void recordChanged();
     15  void recordChanged();
    1616}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandJoin.java

    r31909 r31972  
    1818public class CommandJoin extends MapillaryExecutableCommand {
    1919
    20   private MapillaryAbstractImage a;
    21   private MapillaryAbstractImage b;
     20  private final MapillaryAbstractImage a;
     21  private final MapillaryAbstractImage b;
    2222
    2323  /**
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandUnjoin.java

    r31909 r31972  
    1818public class CommandUnjoin extends MapillaryExecutableCommand {
    1919
    20   private MapillaryAbstractImage a;
    21   private MapillaryAbstractImage b;
     20  private final MapillaryAbstractImage a;
     21  private final MapillaryAbstractImage b;
    2222
    2323  /**
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r31951 r31972  
    205205    for (Thread t : threads) {
    206206      if (t.isAlive())
    207         System.out.println(t);
     207        Main.info(t+" is still alive!");
    208208      t.interrupt();
    209209    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java

    r31797 r31972  
    8686    private long lastDownload;
    8787
    88     private boolean moved = false;
     88    private boolean moved;
    8989
    9090    @Override
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    r31909 r31972  
    3737  private final MapillaryRecord record;
    3838  private boolean nothingHighlighted;
    39   private boolean imageHighlighted = false;
     39  private boolean imageHighlighted;
    4040
    4141  /**
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31909 r31972  
    8888    @Override
    8989    public void run() {
    90       PluginState.imagesToUpload(this.images.size());
     90      PluginState.addImagesToUpload(this.images.size());
    9191      MapillaryUtils.updateHelpText();
    9292      for (MapillaryAbstractImage img : this.images) {
     
    194194    byte[] imageBytes = outputStream.toByteArray();
    195195    new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);
     196    os.close();
    196197    return tempFile;
    197198  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoGlyph.java

    r31795 r31972  
    1111
    1212public final class TrafficoGlyph {
     13  private static Map<String, Character> glyphs;
     14
    1315  private TrafficoGlyph() {
    1416    // private constructor to avoid instantiation
    1517  }
    16   private static Map<String, Character> glyphs;
    1718
    1819  private static Map<String, Character> readGlyphsFromResources() {
     
    2526      glyphs.put(name, glyphObject.getString(name).charAt(0));
    2627    }
     28    reader.close();
    2729    return glyphs;
    2830  }
    2931
    30   public static Character getGlyph(String key) {
     32  public static synchronized Character getGlyph(String key) {
    3133    if (glyphs == null) {
    3234      glyphs = readGlyphsFromResources();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r31882 r31972  
    125125   *                                  not one of the values mentioned above
    126126   */
    127   public static double degMinSecToDouble(RationalNumber[] degMinSec,
    128                                          String ref) {
     127  public static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) {
    129128    if (degMinSec == null || degMinSec.length != 3) {
    130129      throw new IllegalArgumentException("Array's length must be 3.");
     
    256255                      ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
    257256      if (lat_ref == null || lat == null || lon == null || lon_ref == null) {
    258         if (exceptionNoTags)
    259           throw new IllegalArgumentException(
    260                   "The image doesn't have the needed EXIF tags.");
    261         else
    262           return readNoTags(file);
     257        if (exceptionNoTags) {
     258          throw new IllegalArgumentException("The image doesn't have the needed EXIF tags.");
     259        }
     260        return readNoTags(file);
    263261      }
    264262      double latValue = 0;
     
    273271      if (ca != null && ca.getValue() instanceof RationalNumber)
    274272        caValue = ((RationalNumber) ca.getValue()).doubleValue();
    275       if (datetimeOriginal != null)
    276         return new MapillaryImportedImage(latValue, lonValue, caValue, file,
    277                 datetimeOriginal.getStringValue());
    278       else
    279         return new MapillaryImportedImage(latValue, lonValue, caValue, file);
     273      if (datetimeOriginal != null) {
     274        return new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue());
     275      }
     276      return new MapillaryImportedImage(latValue, lonValue, caValue, file);
    280277    }
    281278    throw new IllegalStateException("Invalid format.");
     
    317314              .findEXIFValueWithExactMatch(
    318315                      ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
    319       if (datetimeOriginal == null)
    320         return new MapillaryImportedImage(pos.lat(), pos.lon(), 0,
    321                 file);
    322       else {
    323         try {
    324           return new MapillaryImportedImage(pos.lat(), pos.lon(), 0,
    325                   file, datetimeOriginal.getStringValue());
    326         } catch (ImageReadException e) {
    327           Main.error(e);
    328         }
     316      if (datetimeOriginal == null) {
     317        return new MapillaryImportedImage(pos.lat(), pos.lon(), 0, file);
     318      }
     319      try {
     320        return new MapillaryImportedImage(pos.lat(), pos.lon(), 0, file, datetimeOriginal.getStringValue());
     321      } catch (ImageReadException e) {
     322        Main.error(e);
    329323      }
    330324    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/PluginState.java

    r31841 r31972  
    1919  private static int runningDownloads;
    2020  /** Images that have to be uploaded. */
    21   protected static int imagesToUpload;
     21  private static int imagesToUpload;
    2222  /** Images that have been uploaded. */
    23   public static int imagesUploaded;
     23  private static int imagesUploaded;
    2424
    2525  private PluginState() {
     
    6868   *          The amount of images that are going to be uploaded.
    6969   */
    70   public static void imagesToUpload(int amount) {
     70  public static void addImagesToUpload(int amount) {
    7171    if (imagesToUpload <= imagesUploaded) {
    7272      imagesToUpload = 0;
     
    7474    }
    7575    imagesToUpload += amount;
     76  }
     77
     78  public static int getImagesToUpload() {
     79    return imagesToUpload;
     80  }
     81
     82  public static int getImagesUploaded() {
     83    return imagesUploaded;
    7684  }
    7785
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryURLTest.java

    r31970 r31972  
    6161
    6262  @Test
    63   public void testConnectURL() throws MalformedURLException {
     63  public void testConnectURL() {
    6464    assertUrlEquals(
    6565        MapillaryURL.connectURL("http://redirect-host/ä"),
     
    8989
    9090  @Test
    91   public void testSearchImageURL() throws MalformedURLException {
     91  public void testSearchImageURL() {
    9292    assertUrlEquals(
    9393        MapillaryURL.searchImageURL(new Bounds(1.1, 2.22, 3.333, 4.4444), 42),
     
    111111
    112112  @Test
    113   public void testSearchSequenceURL() throws MalformedURLException {
     113  public void testSearchSequenceURL() {
    114114    assertUrlEquals(
    115115        MapillaryURL.searchSequenceURL(new Bounds(-55.55555, -66.666666, 77.7777777, 88.88888888, false), 42),
     
    133133
    134134  @Test
    135   public void testSearchTrafficSignURL() throws MalformedURLException {
     135  public void testSearchTrafficSignURL() {
    136136    assertUrlEquals(
    137137        MapillaryURL.searchTrafficSignURL(new Bounds(1.1, 2.22, 3.333, 4.4444), -42),
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/PluginStateTest.java

    r31484 r31972  
    3535  public void uploadTest() {
    3636    assertEquals(false, PluginState.isUploading());
    37     PluginState.imagesToUpload(2);
    38     assertEquals(2, PluginState.imagesToUpload);
    39     assertEquals(0, PluginState.imagesUploaded);
     37    PluginState.addImagesToUpload(2);
     38    assertEquals(2, PluginState.getImagesToUpload());
     39    assertEquals(0, PluginState.getImagesUploaded());
    4040    assertEquals(true, PluginState.isUploading());
    4141    PluginState.imageUploaded();
    42     assertEquals(1, PluginState.imagesUploaded);
     42    assertEquals(1, PluginState.getImagesUploaded());
    4343    assertEquals(true, PluginState.isUploading());
    4444    PluginState.imageUploaded();
    4545    assertEquals(false, PluginState.isUploading());
    46     assertEquals(2, PluginState.imagesToUpload);
    47     assertEquals(2, PluginState.imagesUploaded);
     46    assertEquals(2, PluginState.getImagesToUpload());
     47    assertEquals(2, PluginState.getImagesUploaded());
    4848  }
    4949}
Note: See TracChangeset for help on using the changeset viewer.