Skip to content

Commit

Permalink
[mapillary] More sonar issues resolved, some tests added and v1.1.0 r…
Browse files Browse the repository at this point in the history
…eleased

git-svn-id: http://svn.openstreetmap.org/applications/editors/josm/plugins/mapillary@31799 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
  • Loading branch information
floscher committed Dec 4, 2015
1 parent 372819e commit 14e20dc
Show file tree
Hide file tree
Showing 23 changed files with 294 additions and 198 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=...
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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 <code>null</code>
*/
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);
}
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
50 changes: 24 additions & 26 deletions src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down
Loading

2 comments on commit 14e20dc

@nokutu
Copy link
Collaborator

@nokutu nokutu commented on 14e20dc Dec 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone has posted this error:

Fehler: java.lang.StackOverflowError
java.lang.StackOverflowError
at java.util.concurrent.locks.AbstractOwnableSynchronizer.(AbstractOwnableSynchronizer.java:59)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.(AbstractQueuedSynchronizer.java:299)
at java.util.concurrent.locks.ReentrantLock$Sync.(ReentrantLock.java:119)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.(ReentrantLock.java:203)
at java.util.concurrent.locks.ReentrantLock.(ReentrantLock.java:262)
at java.util.concurrent.CopyOnWriteArrayList.(CopyOnWriteArrayList.java:83)
at org.openstreetmap.josm.plugins.mapillary.MapillaryData.(MapillaryData.java:31)
at org.openstreetmap.josm.plugins.mapillary.MapillaryLayer.(MapillaryLayer.java:99)
at org.openstreetmap.josm.plugins.mapillary.MapillaryLayer.getInstance(MapillaryLayer.java:175)
at org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode.(AbstractMode.java:31)
at org.openstreetmap.josm.plugins.mapillary.mode.SelectMode.(SelectMode.java:45)
at org.openstreetmap.josm.plugins.mapillary.MapillaryLayer.init(MapillaryLayer.java:109)
at org.openstreetmap.josm.plugins.mapillary.MapillaryLayer.(MapillaryLayer.java:101)
at org.openstreetmap.josm.plugins.mapillary.MapillaryLayer.getInstance(MapillaryLayer.java:175)
at org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode.(AbstractMode.java:31)
at org.openstreetmap.josm.plugins.mapillary.mode.SelectMode.(SelectMode.java:45)
...

He said it worked fine in version 31784

@floscher
Copy link
Member Author

@floscher floscher commented on 14e20dc Dec 7, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.