Changeset 32374 in osm


Ignore:
Timestamp:
2016-06-23T01:17:42+02:00 (8 years ago)
Author:
floscher
Message:

[mapillary] Fix some more minor code style issues

Among other things:

  • Make class with only static methods a utility class
  • remove public modifier from constructor of private class
  • whitespace changes to make passages more readable
Location:
applications/editors/josm/plugins/mapillary
Files:
8 edited

Legend:

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

    r32365 r32374  
    4747import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    4848import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    49 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    5049import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils;
    5150import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/CacheUtils.java

    r31840 r32374  
    1616 *
    1717 */
    18 public class CacheUtils {
     18public final class CacheUtils {
    1919
    2020  private static IgnoreDownload ignoreDownload = new IgnoreDownload();
     
    2828    /** Both of them */
    2929    BOTH;
     30  }
     31
     32  private CacheUtils() {
     33    // Private constructor to avoid instantiation
    3034  }
    3135
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r32064 r32374  
    255255  }
    256256
     257  /**
     258   * Destroys the unique instance of the class.
     259   */
     260  public static synchronized void destroyInstance() {
     261    instance = null;
     262  }
     263
    257264  private class DownloadCheckBoxAction extends AbstractAction {
    258265
    259266    private static final long serialVersionUID = 4672634002899519496L;
    260267
    261     public DownloadCheckBoxAction() {
     268    DownloadCheckBoxAction() {
    262269      putValue(NAME, tr("Downloaded images"));
    263270    }
     
    273280    private static final long serialVersionUID = -7417238601979689863L;
    274281
    275     public UpdateAction() {
     282    UpdateAction() {
    276283      putValue(NAME, tr("Update"));
    277284    }
     
    289296    private static final long serialVersionUID = 1178261778165525040L;
    290297
    291     public ResetAction() {
     298    ResetAction() {
    292299      putValue(NAME, tr("Reset"));
    293300    }
     
    303310    private static final long serialVersionUID = -2937440338019185723L;
    304311
    305     public OnlySignsAction() {
     312    OnlySignsAction() {
    306313      putValue(NAME, tr("Only images with signs"));
    307314    }
     
    322329    private static final long serialVersionUID = 8706299665735930148L;
    323330
    324     public SignChooserAction() {
     331    SignChooserAction() {
    325332      putValue(NAME, tr("Choose signs"));
    326333    }
     
    338345    }
    339346  }
    340 
    341   /**
    342    * Destroys the unique instance of the class.
    343    */
    344   public static synchronized void destroyInstance() {
    345     instance = null;
    346   }
    347347}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java

    r32373 r32374  
    3636  private static final long serialVersionUID = 3369727203329307716L;
    3737
    38   private static final int DRAG_BUTTON = Main.pref.getInteger(
    39       "mapillary.picture-drag-button", 3);
    40   private static final int OPTION_BUTTON = Main.pref.getInteger(
    41       "mapillary.picture-option-button", 2);
    42   private static final int ZOOM_BUTTON = Main.pref.getInteger(
    43       "mapillary.picture-zoom-button", 1);
     38  private static final int DRAG_BUTTON = Main.pref.getInteger("mapillary.picture-drag-button", 3);
     39  private static final int OPTION_BUTTON = Main.pref.getInteger("mapillary.picture-option-button", 2);
     40  private static final int ZOOM_BUTTON = Main.pref.getInteger("mapillary.picture-zoom-button", 1);
    4441
    4542  /** The image currently displayed */
     
    6158  protected HyperlinkLabel hyperlink;
    6259
    63   private class ImgDisplayMouseListener implements MouseListener,
    64       MouseWheelListener, MouseMotionListener {
     60  private class ImgDisplayMouseListener implements MouseListener, MouseWheelListener, MouseMotionListener {
    6561    private boolean mouseIsDragging;
    6662    private long lastTimeForMousePoint;
     
    431427  private final Point comp2imgCoord(Rectangle visibleRect, int xComp, int yComp) {
    432428    Rectangle drawRect = calculateDrawImageRectangle(visibleRect);
    433     return new Point(visibleRect.x + ((xComp - drawRect.x) * visibleRect.width)
    434         / drawRect.width, visibleRect.y
    435         + ((yComp - drawRect.y) * visibleRect.height) / drawRect.height);
     429    return new Point(
     430        visibleRect.x + ((xComp - drawRect.x) * visibleRect.width) / drawRect.width,
     431        visibleRect.y + ((yComp - drawRect.y) * visibleRect.height) / drawRect.height
     432    );
    436433  }
    437434
    438435  private static final Point getCenterImgCoord(Rectangle visibleRect) {
    439     return new Point(visibleRect.x + visibleRect.width / 2, visibleRect.y
    440         + visibleRect.height / 2);
     436    return new Point(visibleRect.x + visibleRect.width / 2, visibleRect.y + visibleRect.height / 2);
    441437  }
    442438
    443439  private Rectangle calculateDrawImageRectangle(Rectangle visibleRect) {
    444     return calculateDrawImageRectangle(visibleRect, new Rectangle(0, 0,
    445         getSize().width, getSize().height));
     440    return calculateDrawImageRectangle(visibleRect, new Rectangle(0, 0, getSize().width, getSize().height));
    446441  }
    447442
     
    482477    Rectangle visibleRect;
    483478    synchronized (this) {
    484       image = MapillaryImageDisplay.this.image;
    485       visibleRect = MapillaryImageDisplay.this.visibleRect;
     479      image = this.image;
     480      visibleRect = this.visibleRect;
    486481    }
    487482    if (image == null)
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java

    r31972 r32374  
    575575      this.buttonsPanel = new JPanel(new GridLayout(1, 1));
    576576      if (!buttons.isEmpty() && buttons.get(0) != null) {
    577         final JPanel buttonRowPanel = new JPanel(Main.pref.getBoolean(
    578                 "dialog.align.left", false) ? new FlowLayout(FlowLayout.LEFT)
    579                 : new GridLayout(1, buttons.size()));
     577        final JPanel buttonRowPanel = new JPanel(
     578            Main.pref.getBoolean("dialog.align.left", false)
     579            ? new FlowLayout(FlowLayout.LEFT)
     580            : new GridLayout(1, buttons.size())
     581        );
    580582        this.buttonsPanel.add(buttonRowPanel);
    581583        for (SideButton button : buttons) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r32373 r32374  
    184184  }
    185185
    186   protected static void tooBigErrorDialog() {
     186  private static void tooBigErrorDialog() {
    187187    if (SwingUtilities.isEventDispatchThread()) {
    188188      MapillaryLayer.getInstance().tempSemiautomatic = true;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/ImageUtil.java

    r32034 r32374  
    136136    private final byte[] magic = new byte[Math.max(JFIF_MAGIC.length, PNG_MAGIC.length)];
    137137
    138     ImageFileFilter() { }
    139 
    140138    @Override
    141139    public synchronized boolean accept(File f) {
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/TestUtil.java

    r32067 r32374  
    1717
    1818/**
    19  *
    2019 * Utilities for tests.
    21  *
    22  * @author floscher
    2320 */
    2421public final class TestUtil {
     
    3532   * That is needed e.g. to use {@link MapillaryLayer#getInstance()}
    3633   */
    37   public static final synchronized void initPlugin() {
     34  public static synchronized void initPlugin() {
    3835    if (!isInitialized) {
    3936      System.setProperty("josm.home", "test/data/preferences");
Note: See TracChangeset for help on using the changeset viewer.