Skip to content

Commit

Permalink
Code improved, typos corrected and small enhances
Browse files Browse the repository at this point in the history
  • Loading branch information
nokutu committed Aug 21, 2015
1 parent 7e318d6 commit a6cf730
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.openstreetmap.josm.data.coor.LatLon;

/**
* Abstract superclass for all image objects. At the moment there is just 2,
* Abstract superclass for all image objects. At the moment there are just 2,
* {@link MapillaryImportedImage} and {@link MapillaryImage}.
*
* @author nokutu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
import org.openstreetmap.josm.gui.layer.Layer;
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord;
import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode;
import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode;
import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode;
Expand Down Expand Up @@ -311,7 +311,6 @@ public synchronized void paint(Graphics2D g, MapView mv, Bounds box) {
if (!imageAbs.isVisible())
continue;
Point p = mv.getPoint(imageAbs.getLatLon());

Point nextp = null;
// Draw sequence line
if (imageAbs.getSequence() != null) {
Expand All @@ -326,7 +325,7 @@ public synchronized void paint(Graphics2D g, MapView mv, Bounds box) {
if (nextp != null)
g.drawLine(p.x, p.y, nextp.x, nextp.y);
}

// Draws icons
if (imageAbs instanceof MapillaryImage) {
MapillaryImage image = (MapillaryImage) imageAbs;
ImageIcon icon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryUploadAction;
import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryWalkAction;
import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryZoomAction;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryHistoryDialog;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryPreferenceSetting;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser;
import org.openstreetmap.josm.tools.ImageProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.awt.event.KeyEvent;

import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
import org.openstreetmap.josm.tools.ImageProvider;
import org.openstreetmap.josm.tools.Shortcut;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryExportManager;
import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryExportDialog;
import org.openstreetmap.josm.plugins.mapillary.io.export.MapillaryExportManager;
import org.openstreetmap.josm.tools.Shortcut;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,5 @@ public void actionPerformed(ActionEvent e) {
Main.error(e1);
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void mouseWheelMoved(MouseWheelEvent e) {
this.lastTimeForMousePoint = e.getWhen();
this.mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
}
// Applicate the zoom to the visible rectangle in image coordinates
// Set the zoom to the visible rectangle in image coordinates
if (e.getWheelRotation() > 0) {
visibleRect.width = visibleRect.width * 3 / 2;
visibleRect.height = visibleRect.height * 3 / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser;
import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthPortListener;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
Expand Down Expand Up @@ -51,18 +51,15 @@ public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
@Override
public void addGui(PreferenceTabbedPane gui) {
JPanel panel = new JPanel();

this.reverseButtons.setSelected(Main.pref
.getBoolean("mapillary.reverse-buttons"));
this.displayHour.setSelected(Main.pref.getBoolean("mapillary.display-hour",
true));
this.format24.setSelected(Main.pref.getBoolean("mapillary.format-24"));
this.moveTo.setSelected(Main.pref.getBoolean("mapillary.move-to-picture",
true));

panel.setLayout(new FlowLayout(FlowLayout.LEFT));
panel.add(this.reverseButtons);

// Sets the value of the ComboBox.
if (Main.pref.get("mapillary.download-mode").equals(
MapillaryDownloader.MODES[0]))
Expand All @@ -77,7 +74,6 @@ public void addGui(PreferenceTabbedPane gui) {
downloadModePanel.add(new JLabel(tr("Download mode: ")));
downloadModePanel.add(this.downloadMode);
panel.add(downloadModePanel);

panel.add(this.displayHour);
panel.add(this.format24);
panel.add(this.moveTo);
Expand All @@ -87,12 +83,10 @@ public void addGui(PreferenceTabbedPane gui) {
else
this.login.setText("Logged as: " + MapillaryUser.getUsername()
+ ". Click to relogin.");

panel.add(this.login);
if (MapillaryUser.getUsername() != null) {
JButton logout = new JButton(new LogoutAction());
logout.setText("Logout");

panel.add(logout);
}
gui.getDisplayPreference().addSubTab(this, "Mapillary", panel);
Expand All @@ -116,7 +110,6 @@ public boolean ok() {
Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES[2]);
MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true);
}

Main.pref.put("mapillary.display-hour", this.displayHour.isSelected());
Main.pref.put("mapillary.format-24", this.format24.isSelected());
Main.pref.put("mapillary.move-to-picture", this.moveTo.isSelected());
Expand All @@ -142,7 +135,6 @@ 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";
try {
MapillaryUtils.browse(new URL(url));
Expand All @@ -169,5 +161,4 @@ public void actionPerformed(ActionEvent arg0) {
MapillaryPreferenceSetting.this.login.setText("Login");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser;

/**
* JPanel used when uploading pictures.
*
* @author nokutu
*
*/
Expand All @@ -30,27 +32,25 @@ public class MapillaryUploadDialog extends JPanel {
public JCheckBox delete;

/**
* Main constructor.
* Creates the JPanel and adds the needed elements.
*/
public MapillaryUploadDialog() {
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
if (MapillaryUser.getUsername() != null) {
this.group = new ButtonGroup();

this.sequence = new JRadioButton(tr("Upload selected sequence"));
if (MapillaryLayer.getInstance().getData().getSelectedImage() == null
|| !(MapillaryLayer.getInstance().getData().getSelectedImage() instanceof MapillaryImportedImage))
this.sequence.setEnabled(false);
this.group.add(this.sequence);
add(this.sequence);
this.group.setSelected(this.sequence.getModel(), true);

this.delete = new JCheckBox(tr("Delete after upload"));
this.delete.setSelected(Main.pref.getBoolean(
"mapillary.delete-after-upload", true));
add(this.delete);
} else {
this.add(new JLabel("Go to setting and log in to Mapillary before uploading."));
}
} else
this.add(new JLabel(
"Go to setting and log in to Mapillary before uploading."));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.download;

import static org.openstreetmap.josm.tools.I18n.tr;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.download;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.download;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.download;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.download;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.export;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.export;

import static org.openstreetmap.josm.tools.I18n.tr;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openstreetmap.josm.plugins.mapillary.downloads;
package org.openstreetmap.josm.plugins.mapillary.io.export;

import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;

/**
* Superclass for all the mode of the {@link MapillaryLayer}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class SelectMode extends AbstractMode {
private MapillaryAbstractImage closest;
private MapillaryAbstractImage lastClicked;
private MapillaryRecord record;

private boolean nothingHighlighted;
private boolean imageHighlighted = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,24 @@ public static HashMap<String, String> getSecrets() {
if (!isTokenValid)
return null;
HashMap<String, String> hash = new HashMap<>();
if (images_hash == null)
try {
try {
if (images_hash == null)
images_hash = OAuthUtils
.getWithHeader(
new URL(
"https://a.mapillary.com/v2/me/uploads/secrets?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
.getString("images_hash");
} catch (IOException e) {
Main.error(e);
isTokenValid = false;
}
hash.put("images_hash", images_hash);
if (images_policy == null)
try {
hash.put("images_hash", images_hash);
if (images_policy == null)
images_policy = OAuthUtils
.getWithHeader(
new URL(
"https://a.mapillary.com/v2/me/uploads/secrets?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
.getString("images_policy");
} catch (IOException e) {
Main.error(e);
isTokenValid = false;
}
} catch (IOException e) {
Main.error(e);
isTokenValid = false;
}
hash.put("images_policy", images_policy);
return hash;
}
Expand All @@ -84,6 +79,7 @@ public static void reset() {
username = null;
images_policy = null;
images_hash = null;
isTokenValid = true;
isTokenValid = false;
Main.pref.put("mapillary.access-token", null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void run() {
Main.info("Successful login with Mapillary, the access token is: "
+ accessToken);
// Saves the access token in preferences.
MapillaryUser.isTokenValid = true;
if (Main.main != null) {
Main.pref.put("mapillary.access-token", accessToken);
Main.info("The username is: " + MapillaryUser.getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ public static File updateFile(MapillaryImportedImage image)
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(image.getImage(), "jpg", outputStream);
byte[] imageBytes = outputStream.toByteArray();

new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);

return tempFile;
}

Expand All @@ -202,7 +200,6 @@ public static File updateFile(MapillaryImportedImage image)
*/
public static void upload(MapillaryImportedImage image) {
upload(image, UUID.randomUUID());

}

/**
Expand All @@ -227,7 +224,6 @@ public static void upload(MapillaryImportedImage image, UUID uuid) {
hash.put("policy", policy);
hash.put("signature", signature);
hash.put("Content-Type", "image/jpeg");

try {
uploadFile(updateFile(image), hash);
} catch (ImageReadException | ImageWriteException | IOException e) {
Expand Down Expand Up @@ -256,7 +252,6 @@ public static void uploadFile(File file, HashMap<String, String> hash)
ContentType.TEXT_PLAIN));
}
entityBuilder.addPart("file", new FileBody(file));

HttpEntity entity = entityBuilder.build();
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public void run() {
}

/**
* Returns the string to be written in the status bar.
* Returns the text to be written in the status bar.
*
* @return The String that is going to be written in the status bar.
* @return The {@code String} that is going to be written in the status bar.
*/
public static String getUploadString() {
return tr("Uploading: {0}", "(" + imagesUploaded + "/" + imagesToUpload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
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.downloads.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.downloads.MapillarySequenceDownloadThread;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader;
import org.openstreetmap.josm.plugins.mapillary.io.download.MapillarySequenceDownloadThread;

/**
*
Expand All @@ -24,7 +24,7 @@ public class MapillarySequenceDownloadThreadTest extends AbstractTest {

/**
* Test method for
* {@link org.openstreetmap.josm.plugins.mapillary.downloads.MapillarySequenceDownloadThread#run()}
* {@link org.openstreetmap.josm.plugins.mapillary.io.download.MapillarySequenceDownloadThread#run()}
* .
*
* This downloads a small area of mapillary-sequences where we know that
Expand Down

0 comments on commit a6cf730

Please sign in to comment.