diff --git a/build.gradle b/build.gradle
index 85fe3dd07..83a30d93d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -104,7 +104,7 @@ test {
jar {
manifest {
attributes("Plugin-Mainversion": project.property('plugin.main.version'),
- "Plugin-Version": "31784",
+ "Plugin-Version": "31799",
"Plugin-Class": project.property('plugin.class'),
"Plugin-Description": project.property('plugin.description'),
"Plugin-Date": String.format("%1\$tY-%1\$tm-%1\$tdT%1\$tH:%1\$tM:%1\$tS%1\$tz", new GregorianCalendar()),
diff --git a/gradle.properties b/gradle.properties
index 15c3c591d..90dc9e00e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,6 +6,6 @@ plugin.icon=images/icon24.png
plugin.link=https://wiki.openstreetmap.org/wiki/JOSM/Plugins/Mapillary
plugin.main.version=8433
plugin.requires=apache-commons;apache-http
-plugin.version=1.0.4
-#plugin.early=…
-#plugin.stage=…
+plugin.version=1.1.0
+#plugin.early=...
+#plugin.stage=...
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
index eec50c349..2851ba139 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
@@ -4,6 +4,7 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.Locale;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.data.coor.LatLon;
@@ -16,6 +17,10 @@
*
*/
public abstract class MapillaryAbstractImage {
+ /**
+ * If two values for field ca differ by less than EPSILON both values are considered equal.
+ */
+ private static final float EPSILON = 1e-5f;
/** The time the image was captured, in Epoch format. */
protected long capturedAt;
@@ -86,7 +91,7 @@ public long getCapturedAt() {
* @return A String object containing the date when the picture was taken.
*/
public String getDate() {
- StringBuilder format = new StringBuilder("");
+ StringBuilder format = new StringBuilder(26);
if (Main.pref.getBoolean("iso.dates"))
format.append("yyyy-MM-dd");
else
@@ -107,11 +112,12 @@ public String getDate() {
* Format of the date. See {@link SimpleDateFormat}.
* @return A String containing the date the picture was taken using the given
* format.
+ * @throws NullPointerException if parameter format is null
*/
public String getDate(String format) {
Date date = new Date(getCapturedAt());
- SimpleDateFormat formatter = new SimpleDateFormat(format);
+ SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
formatter.setTimeZone(Calendar.getInstance().getTimeZone());
return formatter.format(date);
}
@@ -164,7 +170,7 @@ public LatLon getTempLatLon() {
* @return true if the object has been modified; false otherwise.
*/
public boolean isModified() {
- return (this.getLatLon() != this.latLon || this.getCa() != this.ca);
+ return !this.getLatLon().equals(this.latLon) || Math.abs(this.getCa() - this.ca) < EPSILON;
}
/**
@@ -196,7 +202,7 @@ public void move(double x, double y) {
* @return The following MapillaryImage, or null if there is none.
*/
public MapillaryAbstractImage next() {
- synchronized (this.getClass()) {
+ synchronized (MapillaryAbstractImage.class) {
if (this.getSequence() == null)
return null;
return this.getSequence().next(this);
@@ -210,7 +216,7 @@ public MapillaryAbstractImage next() {
* @return The previous MapillaryImage, or null if there is none.
*/
public MapillaryAbstractImage previous() {
- synchronized (this.getClass()) {
+ synchronized (MapillaryAbstractImage.class) {
if (this.getSequence() == null)
return null;
return this.getSequence().previous(this);
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
index 9991012b5..06b726995 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
@@ -41,9 +41,9 @@ protected MapillaryData() {
this.selectedImage = null;
// Adds the basic set of listeners.
- addListener(MapillaryPlugin.walkAction);
- addListener(MapillaryPlugin.zoomAction);
- addListener(MapillaryPlugin.uploadAction);
+ addListener(MapillaryPlugin.getWalkAction());
+ addListener(MapillaryPlugin.getZoomAction());
+ addListener(MapillaryPlugin.getUploadAction());
if (Main.main != null)
addListener(MapillaryMainDialog.getInstance());
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
index f1eb0fe0a..426b7a7d7 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
@@ -94,9 +94,9 @@ public File getFile() {
}
@Override
- public boolean equals(Object object) {
- if (object instanceof MapillaryImportedImage)
- return this.file.equals(((MapillaryImportedImage) object).file);
+ public boolean equals(Object other) {
+ if (other != null && other.getClass() == this.getClass())
+ return this.file.equals(((MapillaryImportedImage) other).file);
return false;
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
index c0f6d9e32..86ea3e294 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
@@ -17,8 +17,6 @@
import java.awt.geom.Area;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.AbstractAction;
@@ -77,7 +75,7 @@ public class MapillaryLayer extends AbstractModifiableLayer implements
"mapillary.sequence-max-jump-distance", 100);
/** If the download is in semiautomatic during this object lifetime. */
- public boolean TEMP_SEMIAUTOMATIC = false;
+ public boolean tempSemiautomatic;
/** Unique instance of the class. */
private static MapillaryLayer instance;
@@ -91,10 +89,8 @@ public class MapillaryLayer extends AbstractModifiableLayer implements
/** Mode of the layer. */
public AbstractMode mode;
- private int highlightPointRadius = Main.pref.getInteger(
- "mappaint.highlight.radius", 7);
- private int highlightStep = Main.pref
- .getInteger("mappaint.highlight.step", 4);
+ private final int highlightPointRadius = Main.pref.getInteger("mappaint.highlight.radius", 7);
+ private final int highlightStep = Main.pref.getInteger("mappaint.highlight.step", 4);
private volatile TexturePaint hatched;
@@ -122,8 +118,8 @@ private void init() {
this.mode.zoomChanged();
}
// Does not execute when in headless mode
- if (MapillaryPlugin.EXPORT_MENU != null) {
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, true);
+ if (MapillaryPlugin.getExportMenu() != null) {
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getExportMenu(), true);
if (!MapillaryMainDialog.getInstance().isShowing())
MapillaryMainDialog.getInstance().getButton().doClick();
}
@@ -219,8 +215,8 @@ public void destroy() {
MapillaryDownloader.stopAll();
MapillaryMainDialog.getInstance().setImage(null);
MapillaryMainDialog.getInstance().updateImage();
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false);
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.ZOOM_MENU, false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getExportMenu(), false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getZoomMenu(), false);
Main.map.mapView.removeMouseListener(this.mode);
Main.map.mapView.removeMouseMotionListener(this.mode);
MapView.removeEditLayerChangeListener(this);
@@ -463,11 +459,13 @@ public Action[] getMenuEntries() {
*/
private MapillaryImage[] getClosestImagesFromDifferentSequences() {
if (!(this.data.getSelectedImage() instanceof MapillaryImage))
- return new MapillaryImage[2];
+ return new MapillaryImage[]{null, null};
MapillaryImage selected = (MapillaryImage) this.data.getSelectedImage();
MapillaryImage[] ret = new MapillaryImage[2];
- double[] distances = { SEQUENCE_MAX_JUMP_DISTANCE,
- SEQUENCE_MAX_JUMP_DISTANCE };
+ double[] distances = {
+ SEQUENCE_MAX_JUMP_DISTANCE,
+ SEQUENCE_MAX_JUMP_DISTANCE
+ };
LatLon selectedCoords = this.data.getSelectedImage().getLatLon();
for (MapillaryAbstractImage imagePrev : this.data.getImages()) {
if (!(imagePrev instanceof MapillaryImage))
@@ -500,19 +498,19 @@ private MapillaryImage[] getClosestImagesFromDifferentSequences() {
@Override
public Object getInfoComponent() {
- StringBuilder sb = new StringBuilder();
- sb.append(tr("Mapillary layer"));
- sb.append("\n");
- sb.append(tr("Total images:"));
- sb.append(" ");
- sb.append(this.data.size());
- sb.append("\n");
- return sb.toString();
+ return new StringBuilder(35)
+ .append(tr("Mapillary layer"))
+ .append('\n')
+ .append(tr("Total images:"))
+ .append(' ')
+ .append(this.data.size())
+ .append('\n')
+ .toString();
}
@Override
public String getToolTipText() {
- return this.data.size() + " " + tr("images");
+ return this.data.size() + (' ' + tr("images"));
}
@Override
@@ -567,9 +565,9 @@ public void visitBoundingBox(BoundingXYVisitor v) {
public void activeLayerChange(Layer oldLayer, Layer newLayer) {
if (newLayer == this) {
MapillaryUtils.updateHelpText();
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getJoinMenu(), true);
} else
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getJoinMenu(), false);
}
@Override
@@ -588,7 +586,7 @@ public void layerRemoved(Layer oldLayer) {
* @author nokutu
*
*/
- private class DelayedDownload extends Thread {
+ private static class DelayedDownload extends Thread {
@Override
public void run() {
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
index 08d151281..7e0f4e51c 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
@@ -40,6 +40,7 @@
*
*/
public class MapillaryPlugin extends Plugin {
+ public static final String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
/** OS route separator */
public static final String SEPARATOR = System.getProperty("file.separator");
@@ -62,35 +63,35 @@ public class MapillaryPlugin extends Plugin {
private final MapillaryDownloadAction downloadAction;
private final MapillaryExportAction exportAction;
/** Import action */
- public static MapillaryImportAction importAction;
+ private final MapillaryImportAction importAction;
/** Zoom action */
- public static MapillaryZoomAction zoomAction;
+ private static MapillaryZoomAction zoomAction;
private final MapillaryDownloadViewAction downloadViewAction;
private final MapillaryImportIntoSequenceAction importIntoSequenceAction;
private final MapillaryJoinAction joinAction;
/** Walk action */
- public static MapillaryWalkAction walkAction;
+ private static MapillaryWalkAction walkAction;
/** Upload action */
- public static MapillaryUploadAction uploadAction;
+ private static MapillaryUploadAction uploadAction;
/** Menu button for the {@link MapillaryDownloadAction} action. */
- public static JMenuItem DOWNLOAD_MENU;
+ private JMenuItem downloadMenu;
/** Menu button for the {@link MapillaryExportAction} action. */
- public static JMenuItem EXPORT_MENU;
+ private static JMenuItem exportMenu;
/** Menu button for the {@link MapillaryImportAction} action. */
- public static JMenuItem IMPORT_MENU;
+ private JMenuItem importMenu;
/** Menu button for the {@link MapillaryZoomAction} action. */
- public static JMenuItem ZOOM_MENU;
+ private static JMenuItem zoomMenu;
/** Menu button for the {@link MapillaryDownloadViewAction} action. */
- public static JMenuItem DOWNLOAD_VIEW_MENU;
+ private static JMenuItem downloadViewMenu;
/** Menu button for the {@link MapillaryImportIntoSequenceAction} action. */
- public static JMenuItem IMPORT_INTO_SEQUENCE_MENU;
+ private JMenuItem importIntoSequenceMenu;
/** Menu button for the {@link MapillaryJoinAction} action. */
- public static JMenuItem JOIN_MENU;
+ private static JMenuItem joinMenu;
/** Menu button for the {@link MapillaryWalkAction} action. */
- public static JMenuItem WALK_MENU;
+ private static JMenuItem walkMenu;
/** Menu button for the {@link MapillaryUploadAction} action. */
- public static JMenuItem UPLOAD_MENU;
+ private static JMenuItem uploadMenu;
/**
* Main constructor.
@@ -101,46 +102,39 @@ public class MapillaryPlugin extends Plugin {
public MapillaryPlugin(PluginInformation info) {
super(info);
- this.downloadAction = new MapillaryDownloadAction();
+ downloadAction = new MapillaryDownloadAction();
walkAction = new MapillaryWalkAction();
- this.exportAction = new MapillaryExportAction();
+ exportAction = new MapillaryExportAction();
importAction = new MapillaryImportAction();
zoomAction = new MapillaryZoomAction();
- this.downloadViewAction = new MapillaryDownloadViewAction();
- this.importIntoSequenceAction = new MapillaryImportIntoSequenceAction();
- this.joinAction = new MapillaryJoinAction();
+ downloadViewAction = new MapillaryDownloadViewAction();
+ importIntoSequenceAction = new MapillaryImportIntoSequenceAction();
+ joinAction = new MapillaryJoinAction();
uploadAction = new MapillaryUploadAction();
if (Main.main != null) { // important for headless mode
- DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu,
- this.downloadAction, false);
- EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, this.exportAction,
- false, 14);
- IMPORT_INTO_SEQUENCE_MENU = MainMenu.add(Main.main.menu.fileMenu,
- this.importIntoSequenceAction, false, 14);
- IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, importAction, false,
- 14);
- UPLOAD_MENU = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false,
- 14);
- ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
- DOWNLOAD_VIEW_MENU = MainMenu.add(Main.main.menu.fileMenu,
- this.downloadViewAction, false, 14);
- JOIN_MENU = MainMenu.add(Main.main.menu.dataMenu, this.joinAction, false);
- WALK_MENU = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
-
- EXPORT_MENU.setEnabled(false);
- DOWNLOAD_MENU.setEnabled(false);
- IMPORT_MENU.setEnabled(false);
- IMPORT_INTO_SEQUENCE_MENU.setEnabled(false);
- ZOOM_MENU.setEnabled(false);
- DOWNLOAD_VIEW_MENU.setEnabled(false);
- JOIN_MENU.setEnabled(false);
- WALK_MENU.setEnabled(false);
+ downloadMenu = MainMenu.add(Main.main.menu.imageryMenu, this.downloadAction, false);
+ exportMenu = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14);
+ importIntoSequenceMenu = MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14);
+ importMenu = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14);
+ uploadMenu = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14);
+ zoomMenu = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
+ downloadViewMenu = MainMenu.add(Main.main.menu.fileMenu, this.downloadViewAction, false, 14);
+ joinMenu = MainMenu.add(Main.main.menu.dataMenu, this.joinAction, false);
+ walkMenu = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
+
+ exportMenu.setEnabled(false);
+ downloadMenu.setEnabled(false);
+ importMenu.setEnabled(false);
+ importIntoSequenceMenu.setEnabled(false);
+ zoomMenu.setEnabled(false);
+ downloadViewMenu.setEnabled(false);
+ joinMenu.setEnabled(false);
+ walkMenu.setEnabled(false);
}
try {
- CACHE = JCSCacheManager.getCache("mapillary", 10, 10000,
- this.getPluginDir() + "/cache/");
+ CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, this.getPluginDir() + "/cache/");
} catch (IOException e) {
Main.error(e);
}
@@ -149,6 +143,69 @@ public MapillaryPlugin(PluginInformation info) {
MapillaryUser.isTokenValid = false;
}
+ /**
+ * @return the menu-item associated with the {@link MapillaryDownloadViewAction}
+ */
+ public static JMenuItem getDownloadViewMenu() {
+ return downloadViewMenu;
+ }
+
+ /**
+ * @return the menu-item associated with the {@link MapillaryExportAction}
+ */
+ public static JMenuItem getExportMenu() {
+ return exportMenu;
+ }
+
+ /**
+ * @return the menu-item associated with the {@link MapillaryJoinAction}
+ */
+ public static JMenuItem getJoinMenu() {
+ return joinMenu;
+ }
+
+ /**
+ * @return the {@link MapillaryUploadAction} for the plugin
+ */
+ public static MapillaryDataListener getUploadAction() {
+ return uploadAction;
+ }
+
+ /**
+ * @return the menu-item associated with the {@link MapillaryUploadAction}
+ */
+ public static JMenuItem getUploadMenu() {
+ return uploadMenu;
+ }
+
+ /**
+ * @return the {@link MapillaryWalkAction} for the plugin
+ */
+ public static MapillaryWalkAction getWalkAction() {
+ return walkAction;
+ }
+
+ /**
+ * @return the menu-item associated with the {@link MapillaryWalkAction}
+ */
+ public static JMenuItem getWalkMenu() {
+ return walkMenu;
+ }
+
+ /**
+ * @return the {@link MapillaryZoomAction} for the plugin
+ */
+ public static MapillaryDataListener getZoomAction() {
+ return zoomAction;
+ }
+
+ /**
+ * @return the menu-item associated with the {@link MapillaryZoomAction}
+ */
+ public static JMenuItem getZoomMenu() {
+ return zoomMenu;
+ }
+
/**
* Called when the JOSM map frame is created or destroyed.
*/
@@ -158,20 +215,20 @@ public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
Main.map.addToggleDialog(MapillaryMainDialog.getInstance(), false);
Main.map.addToggleDialog(MapillaryHistoryDialog.getInstance(), false);
Main.map.addToggleDialog(MapillaryFilterDialog.getInstance(), false);
- setMenuEnabled(DOWNLOAD_MENU, true);
+ setMenuEnabled(downloadMenu, true);
if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Manual)
- setMenuEnabled(DOWNLOAD_VIEW_MENU, true);
- setMenuEnabled(IMPORT_MENU, true);
- setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, true);
+ setMenuEnabled(downloadViewMenu, true);
+ setMenuEnabled(importMenu, true);
+ setMenuEnabled(importIntoSequenceMenu, true);
}
if (oldFrame != null && newFrame == null) { // map frame destroyed
MapillaryMainDialog.destroyInstance();
MapillaryHistoryDialog.destroyInstance();
MapillaryFilterDialog.destroyInstance();
- setMenuEnabled(DOWNLOAD_MENU, false);
- setMenuEnabled(DOWNLOAD_VIEW_MENU, false);
- setMenuEnabled(IMPORT_MENU, false);
- setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, false);
+ setMenuEnabled(downloadMenu, false);
+ setMenuEnabled(downloadViewMenu, false);
+ setMenuEnabled(importMenu, false);
+ setMenuEnabled(importIntoSequenceMenu, false);
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java
index b5a069bd0..e95c557a7 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java
@@ -2,6 +2,7 @@
package org.openstreetmap.josm.plugins.mapillary;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics2D;
@@ -12,6 +13,7 @@
import javax.swing.Action;
import javax.swing.Icon;
+import javax.swing.JLabel;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.coor.LatLon;
@@ -21,25 +23,35 @@
import org.openstreetmap.josm.gui.layer.Layer;
import org.openstreetmap.josm.plugins.mapillary.traffico.TrafficoSign;
import org.openstreetmap.josm.plugins.mapillary.traffico.TrafficoSignElement;
+import org.openstreetmap.josm.tools.I18n;
public class MapillaryTrafficSignLayer extends AbstractModifiableLayer {
+ private static final String TRAFFICO_PATH = "data/fonts/traffico/traffico.ttf";
private static MapillaryTrafficSignLayer instance;
+ private final Font traffico;
+
+ private MapillaryTrafficSignLayer() throws IOException {
+ super("Mapillary traffic signs");
+ try {
+ traffico = Font.createFont(Font.TRUETYPE_FONT, new File("data/fonts/traffico/traffico.ttf")).deriveFont(50.0f);
+ } catch (FontFormatException e) {
+ throw new IOException(I18n.tr("Traffic sign font at ''{0}'' has wrong format.", TRAFFICO_PATH), e);
+ } catch (IOException e) {
+ throw new IOException(I18n.tr("Could not read font-file from ''{{0}}''.", TRAFFICO_PATH), e);
+ }
+ }
/**
* Returns and when needed instantiates the Mapillary traffic sign layer.
*
* @return the only instance of the traffic sign layer
+ * @throws IOException if some error occured while reading the icon-font traffico or
+ * if the traffico font has the wrong format
*/
- public static MapillaryTrafficSignLayer getInstance() {
- return instance == null ? (instance = new MapillaryTrafficSignLayer())
- : instance;
- }
-
- /**
- * @param name
- */
- private MapillaryTrafficSignLayer() {
- super("Mapillary traffic signs");
+ public static MapillaryTrafficSignLayer getInstance() throws IOException {
+ if (instance == null)
+ instance = new MapillaryTrafficSignLayer();
+ return instance;
}
/*
@@ -60,16 +72,8 @@ public boolean isModified() {
*/
@Override
public void paint(Graphics2D g, MapView mv, Bounds box) {
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- try {
- g.setFont(Font.createFont(Font.TRUETYPE_FONT,
- new File("data/fonts/traffico/traffico.ttf")).deriveFont(50.0f));
- } catch (FontFormatException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setFont(traffico);
Point[] points = new Point[3];
points[0] = mv.getPoint(new LatLon(49.01058, 8.40743));
@@ -90,15 +94,12 @@ public void paint(Graphics2D g, MapView mv, Bounds box) {
// Start iterating the images
g.setColor(Color.MAGENTA);
- for (MapillaryAbstractImage img : MapillaryLayer.getInstance()
- .getData().getImages()) {
+ for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) {
if (img instanceof MapillaryImage) {
- g.fillOval(mv.getPoint(img.getLatLon()).x - 3,
- mv.getPoint(img.getLatLon()).y - 3, 6, 6);
+ g.fillOval(mv.getPoint(img.getLatLon()).x - 3, mv.getPoint(img.getLatLon()).y - 3, 6, 6);
if (((MapillaryImage) img).getSigns().size() >= 1) {
Point imgLoc = mv.getPoint(img.getLatLon());
- for (TrafficoSignElement e : TrafficoSign.getSign("de",
- ((MapillaryImage) img).getSigns().get(0))) {
+ for (TrafficoSignElement e : TrafficoSign.getSign("de", ((MapillaryImage) img).getSigns().get(0))) {
g.setColor(e.getColor());
g.drawString("" + e.getGlyph(), imgLoc.x, imgLoc.y);
}
@@ -136,8 +137,7 @@ public String getToolTipText() {
*/
@Override
public void mergeFrom(Layer from) {
- // Does nothing as this layer is not mergeable (see method
- // isMergable(Layer))
+ // Does nothing as this layer is not mergeable (see method isMergable(Layer))
}
/*
@@ -162,7 +162,6 @@ public boolean isMergable(Layer other) {
@Override
public void visitBoundingBox(BoundingXYVisitor v) {
// TODO Auto-generated method stub
-
}
/*
@@ -171,9 +170,8 @@ public void visitBoundingBox(BoundingXYVisitor v) {
* @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent()
*/
@Override
- public Object getInfoComponent() {
- // TODO Auto-generated method stub
- return null;
+ public Component getInfoComponent() {
+ return new JLabel("Mapillary traffic sign layer");
}
/*
@@ -183,8 +181,7 @@ public Object getInfoComponent() {
*/
@Override
public Action[] getMenuEntries() {
- // TODO Auto-generated method stub
- return null;
+ return new Action[]{};
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java b/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
index ab55ab8a7..efa5df490 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
@@ -70,8 +70,8 @@ public void imagesAdded() {
public void selectedImageChanged(MapillaryAbstractImage oldImage,
MapillaryAbstractImage newImage) {
if (oldImage == null && newImage != null)
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.UPLOAD_MENU, true);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getUploadMenu(), true);
else if (oldImage != null && newImage == null)
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.UPLOAD_MENU, false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getUploadMenu(), false);
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java b/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java
index 3a154064e..32f8698fc 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java
@@ -100,9 +100,9 @@ private void fireWalkStarted() {
public void selectedImageChanged(MapillaryAbstractImage oldImage,
MapillaryAbstractImage newImage) {
if (newImage != null)
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.WALK_MENU, true);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getWalkMenu(), true);
else
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.WALK_MENU, false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getWalkMenu(), false);
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java b/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java
index 2b29247da..0a8e8e4bf 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java
@@ -50,9 +50,9 @@ public void actionPerformed(ActionEvent arg0) {
public void selectedImageChanged(MapillaryAbstractImage oldImage,
MapillaryAbstractImage newImage) {
if (oldImage == null && newImage != null)
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.ZOOM_MENU, true);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getZoomMenu(), true);
else if (oldImage != null && newImage == null)
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.ZOOM_MENU, false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getZoomMenu(), false);
}
@Override
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java b/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
index 302aa569f..e15d7f8fd 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
@@ -6,7 +6,7 @@
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.net.MalformedURLException;
+import java.io.IOException;
import java.net.URL;
import javax.swing.BoxLayout;
@@ -48,7 +48,7 @@ private class WebAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
try {
MapillaryUtils.browse(new URL("http://www.mapillary.com/map/upload/im"));
- } catch (MalformedURLException e1) {
+ } catch (IOException e1) {
Main.error(e1);
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java b/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
index 15223d181..884688603 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
@@ -11,6 +11,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -160,9 +161,8 @@ private class editAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent arg0) {
try {
- MapillaryUtils.browse(new URL("http://www.mapillary.com/map/e/"
- + HyperlinkLabel.this.key));
- } catch (MalformedURLException e) {
+ MapillaryUtils.browse(new URL("http://www.mapillary.com/map/e/" + HyperlinkLabel.this.key));
+ } catch (IOException e) {
Main.error(e);
}
}
@@ -210,6 +210,10 @@ protected void fireActionPerformed(ActionEvent evt) {
public void actionPerformed(ActionEvent e) {
if (this.url == null)
return;
- MapillaryUtils.browse(this.url);
+ try {
+ MapillaryUtils.browse(this.url);
+ } catch (IOException e1) {
+ Main.error(e1);
+ }
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java b/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
index 9b44cc810..afcba5b88 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
@@ -438,7 +438,7 @@ public StopAction() {
putValue(NAME, tr("Stop"));
putValue(SHORT_DESCRIPTION, tr("Stops the walk."));
putValue(SMALL_ICON, ImageProvider.get("dialogs/mapillaryStop.png"));
- MapillaryPlugin.walkAction.addListener(this);
+ MapillaryPlugin.getWalkAction().addListener(this);
}
@Override
@@ -456,13 +456,13 @@ public void walkStarted(WalkThread thread) {
private class PlayAction extends AbstractAction implements WalkListener {
private static final long serialVersionUID = -17943404752082788L;
- private WalkThread thread;
+ private transient WalkThread thread;
public PlayAction() {
putValue(NAME, tr("Play"));
putValue(SHORT_DESCRIPTION, tr("Continues with the paused walk."));
putValue(SMALL_ICON, ImageProvider.get("dialogs/mapillaryPlay.png"));
- MapillaryPlugin.walkAction.addListener(this);
+ MapillaryPlugin.getWalkAction().addListener(this);
}
@Override
@@ -488,7 +488,7 @@ public PauseAction() {
putValue(NAME, tr("Pause"));
putValue(SHORT_DESCRIPTION, tr("Pauses the walk."));
putValue(SMALL_ICON, ImageProvider.get("dialogs/mapillaryPause.png"));
- MapillaryPlugin.walkAction.addListener(this);
+ MapillaryPlugin.getWalkAction().addListener(this);
}
@Override
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java b/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
index 9c982d601..a9a90d6cd 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
@@ -5,7 +5,7 @@
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
-import java.net.MalformedURLException;
+import java.io.IOException;
import java.net.URL;
import javax.swing.AbstractAction;
@@ -98,14 +98,14 @@ public boolean ok() {
Main.pref
.put("mapillary.reverse-buttons", this.reverseButtons.isSelected());
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, false);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), false);
if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString()))
Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Automatic.toString());
if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES.Semiautomatic.toString()))
Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Semiautomatic.toString());
if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES.Manual.toString())) {
Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Manual.toString());
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true);
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true);
}
Main.pref.put("mapillary.display-hour", this.displayHour.isSelected());
Main.pref.put("mapillary.format-24", this.format24.isSelected());
@@ -132,10 +132,10 @@ public class LoginAction extends AbstractAction {
public void actionPerformed(ActionEvent arg0) {
OAuthPortListener portListener = new OAuthPortListener();
portListener.start();
- String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&response_type=token&scope=user:read%20public:upload%20public:write";
+ String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id="+MapillaryPlugin.CLIENT_ID+"&response_type=token&scope=user:read%20public:upload%20public:write";
try {
MapillaryUtils.browse(new URL(url));
- } catch (MalformedURLException e) {
+ } catch (IOException e) {
Main.error(e);
}
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java b/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
index fcceb8e8f..6057e39b8 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
@@ -39,8 +39,6 @@ public enum MODES {Automatic, Semiautomatic, Manual};
/** Base URL of the Mapillary API. */
public static final String BASE_URL = "https://a.mapillary.com/v2/";
- /** Client ID for the app */
- public static final String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
/** Executor that will run the petitions. */
private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5,
100, TimeUnit.SECONDS, new ArrayBlockingQueue(100));;
@@ -178,10 +176,10 @@ private static boolean isAreaTooBig() {
*/
public static MapillaryDownloader.MODES getMode() {
if (Main.pref.get("mapillary.download-mode").equals(MODES.Automatic.toString())
- && (!MapillaryLayer.hasInstance() || !MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC))
+ && (!MapillaryLayer.hasInstance() || !MapillaryLayer.getInstance().tempSemiautomatic))
return MODES.Automatic;
else if (Main.pref.get("mapillary.download-mode").equals(MODES.Semiautomatic.toString())
- || (MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC))
+ || (MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic))
return MODES.Semiautomatic;
else if (Main.pref.get("mapillary.download-mode").equals(MODES.Manual.toString()))
return MODES.Manual;
@@ -200,8 +198,8 @@ public void run() {
}
});
} else {
- MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC = true;
- MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true);
+ MapillaryLayer.getInstance().tempSemiautomatic = true;
+ MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true);
JOptionPane
.showMessageDialog(
Main.parent,
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java b/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java
index 69e3adffb..d262f896b 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java
@@ -4,13 +4,15 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Locale;
+import java.util.Map.Entry;
import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
@@ -48,8 +50,7 @@ public class MapillarySquareDownloadManagerThread extends Thread {
* The query data.
*
*/
- public MapillarySquareDownloadManagerThread(
- ConcurrentHashMap queryStringParts) {
+ public MapillarySquareDownloadManagerThread(ConcurrentMap queryStringParts) {
this.imageQueryString = buildQueryString(queryStringParts);
this.sequenceQueryString = buildQueryString(queryStringParts);
this.signQueryString = buildQueryString(queryStringParts);
@@ -59,16 +60,15 @@ public MapillarySquareDownloadManagerThread(
}
// TODO: Maybe move into a separate utility class?
- private static String buildQueryString(ConcurrentHashMap hash) {
- StringBuilder ret = new StringBuilder("?client_id="
- + MapillaryDownloader.CLIENT_ID);
- for (String key : hash.keySet())
- if (key != null)
+ private static String buildQueryString(ConcurrentMap hash) {
+ StringBuilder ret = new StringBuilder().append("?client_id=").append(MapillaryPlugin.CLIENT_ID);
+ for (Entry entry : hash.entrySet())
+ if (entry.getKey() != null)
try {
- ret.append("&" + URLEncoder.encode(key, "UTF-8")).append(
- "="
- + URLEncoder.encode(
- String.format(Locale.UK, "%f", hash.get(key)), "UTF-8"));
+ ret.append('&')
+ .append(URLEncoder.encode(entry.getKey(), "UTF-8"))
+ .append('=')
+ .append(URLEncoder.encode(String.format(Locale.UK, "%f", entry.getValue()), "UTF-8"));
} catch (UnsupportedEncodingException e) {
// This should not happen, as the encoding is hard-coded
}
@@ -105,8 +105,7 @@ private void downloadSequences() throws InterruptedException {
int page = 0;
while (!this.downloadExecutor.isShutdown()) {
this.downloadExecutor.execute(new MapillarySequenceDownloadThread(
- this.downloadExecutor, this.sequenceQueryString + "&page=" + page
- + "&limit=10"));
+ this.downloadExecutor, this.sequenceQueryString + "&page=" + page + "&limit=10"));
while (this.downloadExecutor.getQueue().remainingCapacity() == 0)
Thread.sleep(500);
page++;
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java b/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java
index 4c2d5de20..cdbc25754 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java
@@ -4,8 +4,10 @@
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
+import java.util.Map;
import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
/**
* Represents the current logged in user and stores its data.
@@ -16,8 +18,8 @@
public class MapillaryUser {
private static String username;
- private static String images_policy;
- private static String images_hash;
+ private static String imagesPolicy;
+ private static String imagesHash;
/** If the stored token is valid or not. */
public static boolean isTokenValid = true;
@@ -34,7 +36,7 @@ public static String getUsername() {
username = OAuthUtils
.getWithHeader(
new URL(
- "https://a.mapillary.com/v2/me?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+ "https://a.mapillary.com/v2/me?client_id="+MapillaryPlugin.CLIENT_ID))
.getString("username");
} catch (IOException e) {
Main.info("Invalid Mapillary token, reseting field");
@@ -47,29 +49,29 @@ public static String getUsername() {
* @return A HashMap object containing the images_policy and images_hash
* strings.
*/
- public static HashMap getSecrets() {
+ public static Map getSecrets() {
if (!isTokenValid)
return null;
- HashMap hash = new HashMap<>();
+ Map hash = new HashMap<>();
try {
- if (images_hash == null)
- images_hash = OAuthUtils
+ if (imagesHash == null)
+ imagesHash = OAuthUtils
.getWithHeader(
new URL(
- "https://a.mapillary.com/v2/me/uploads/secrets?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+ "https://a.mapillary.com/v2/me/uploads/secrets?client_id="+MapillaryPlugin.CLIENT_ID))
.getString("images_hash");
- hash.put("images_hash", images_hash);
- if (images_policy == null)
- images_policy = OAuthUtils
+ hash.put("images_hash", imagesHash);
+ if (imagesPolicy == null)
+ imagesPolicy = OAuthUtils
.getWithHeader(
new URL(
- "https://a.mapillary.com/v2/me/uploads/secrets?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+ "https://a.mapillary.com/v2/me/uploads/secrets?client_id="+MapillaryPlugin.CLIENT_ID))
.getString("images_policy");
} catch (IOException e) {
Main.info("Invalid Mapillary token, reseting field");
reset();
}
- hash.put("images_policy", images_policy);
+ hash.put("images_policy", imagesPolicy);
return hash;
}
@@ -78,8 +80,8 @@ public static HashMap getSecrets() {
*/
public static void reset() {
username = null;
- images_policy = null;
- images_hash = null;
+ imagesPolicy = null;
+ imagesHash = null;
isTokenValid = false;
Main.pref.put("mapillary.access-token", null);
}
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java b/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
index 1ed2ce201..ba2c38545 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
@@ -14,12 +14,12 @@
import javax.json.JsonObject;
public final class TrafficoSign {
+ private static Map> signs = new HashMap<>();
+
private TrafficoSign() {
// private constructor to avoid instantiation
}
- private static Map> signs = new HashMap<>();
-
public static TrafficoSignElement[] getSign(String country, String signName) {
if (signs.get(country) == null) {
System.out.println("Read signs for " + country);
diff --git a/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java b/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
index e0f4b4123..34382aba1 100644
--- a/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
+++ b/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
@@ -40,31 +40,34 @@
* @author nokutu
*
*/
-public class MapillaryUtils {
+public final class MapillaryUtils {
- private static double MIN_ZOOM_SQUARE_SIDE = 0.002;
+ private static final double MIN_ZOOM_SQUARE_SIDE = 0.002;
+
+ private MapillaryUtils() {
+ // Private constructor to avoid instantiation
+ }
/**
* Open the default browser in the given URL.
*
- * @param url
- * The URL that is going to be opened.
+ * @param url The (not-null) URL that is going to be opened.
+ * @throws IOException when the URL could not be opened
*/
- public static void browse(URL url) {
+ public static void browse(URL url) throws IOException {
+ if (url == null) {
+ throw new IllegalArgumentException();
+ }
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(url.toURI());
- } catch (IOException | URISyntaxException e1) {
- Main.error(e1);
+ } catch (URISyntaxException e1) {
+ throw new IOException(e1);
}
} else {
Runtime runtime = Runtime.getRuntime();
- try {
- runtime.exec("xdg-open " + url);
- } catch (IOException exc) {
- exc.printStackTrace();
- }
+ runtime.exec("xdg-open " + url);
}
}
diff --git a/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayerTest.java b/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayerTest.java
new file mode 100644
index 000000000..325575518
--- /dev/null
+++ b/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayerTest.java
@@ -0,0 +1,26 @@
+package org.openstreetmap.josm.plugins.mapillary;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openstreetmap.josm.data.imagery.ImageryInfo;
+import org.openstreetmap.josm.gui.layer.ImageryLayer;
+import org.openstreetmap.josm.gui.layer.Layer;
+
+public class MapillaryTrafficSignLayerTest extends AbstractTest {
+ private Layer dummyLayer = ImageryLayer.create(new ImageryInfo());
+
+ @Test
+ public void test() throws IOException {
+ assertFalse(MapillaryTrafficSignLayer.getInstance().isModified());
+ assertFalse(MapillaryTrafficSignLayer.getInstance().isMergable(dummyLayer));
+ assertFalse(MapillaryTrafficSignLayer.getInstance().isMergable(MapillaryTrafficSignLayer.getInstance()));
+ assertEquals(MapillaryPlugin.ICON16, MapillaryTrafficSignLayer.getInstance().getIcon());
+ assertEquals(null, MapillaryTrafficSignLayer.getInstance().getToolTipText());
+ assertNotEquals(null, MapillaryTrafficSignLayer.getInstance().getInfoComponent());
+ }
+}
diff --git a/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java b/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java
index fd48132ea..808259cdf 100644
--- a/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java
+++ b/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java
@@ -14,6 +14,7 @@
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.plugins.mapillary.AbstractTest;
import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillarySequenceDownloadThread;
@@ -46,7 +47,7 @@ public void testRun() throws InterruptedException {
Locale.UK,
"?max_lat=%.8f&max_lon=%.8f&min_lat=%.8f&min_lon=%.8f&limit=10&client_id=%s",
maxLatLon.lat(), maxLatLon.lon(), minLatLon.lat(), minLatLon.lon(),
- MapillaryDownloader.CLIENT_ID);
+ MapillaryPlugin.CLIENT_ID);
MapillaryLayer.getInstance().getData().bounds.add(new Bounds(minLatLon,
maxLatLon));
diff --git a/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java b/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java
index 76ec7ef19..222158adc 100644
--- a/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java
+++ b/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java
@@ -15,6 +15,11 @@
*/
public class MapillaryUtilsTest {
+ @Test
+ public void testUtilityClass() {
+ TestUtil.testUtilityClass(MapillaryUtils.class);
+ }
+
/**
* Test {@link MapillaryUtils#degMinSecToDouble(RationalNumber[], String)}
* method.