Changeset 31810 in osm for applications/editors


Ignore:
Timestamp:
2015-12-10T23:24:30+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Fix some Sonar issues

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
4 edited

Legend:

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

    r31799 r31810  
    2626import org.openstreetmap.josm.tools.I18n;
    2727
    28 public class MapillaryTrafficSignLayer extends AbstractModifiableLayer {
     28public final class MapillaryTrafficSignLayer extends AbstractModifiableLayer {
    2929  private static final String TRAFFICO_PATH = "data/fonts/traffico/traffico.ttf";
    3030  private static MapillaryTrafficSignLayer instance;
     
    4949   *         if the traffico font has the wrong format
    5050   */
    51   public static MapillaryTrafficSignLayer getInstance() throws IOException {
     51  public static synchronized MapillaryTrafficSignLayer getInstance() throws IOException {
    5252    if (instance == null)
    5353      instance = new MapillaryTrafficSignLayer();
     
    8989      for (TrafficoSignElement layer : signs[i]) { // TODO: NPE
    9090        g.setColor(layer.getColor());
    91         g.drawString("" + layer.getGlyph(), points[i].x - 25, points[i].y + 25);
     91        g.drawString(Character.toString(layer.getGlyph()), points[i].x - 25, points[i].y + 25);
    9292      }
    9393    }
     
    9898      if (img instanceof MapillaryImage) {
    9999        g.fillOval(mv.getPoint(img.getLatLon()).x - 3, mv.getPoint(img.getLatLon()).y - 3, 6, 6);
    100         if (((MapillaryImage) img).getSigns().size() >= 1) {
     100        if (!((MapillaryImage) img).getSigns().isEmpty()) {
    101101          Point imgLoc = mv.getPoint(img.getLatLon());
    102102          for (TrafficoSignElement e : TrafficoSign.getSign("de", ((MapillaryImage) img).getSigns().get(0))) {
    103103            g.setColor(e.getColor());
    104             g.drawString("" + e.getGlyph(), imgLoc.x, imgLoc.y);
     104            g.drawString(Character.toString(e.getGlyph()), imgLoc.x, imgLoc.y);
    105105          }
    106106        }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java

    r31809 r31810  
    33
    44import java.awt.FlowLayout;
    5 import java.awt.GridBagConstraints;
    65import java.awt.GridBagLayout;
    76import java.awt.event.ActionEvent;
     
    98import java.net.URL;
    109
    11 import javax.json.Json;
    1210import javax.swing.AbstractAction;
    1311import javax.swing.BorderFactory;
     
    4240public class MapillaryPreferenceSetting implements SubPreferenceSetting, MapillaryLoginListener {
    4341
    44   private JCheckBox reverseButtons = new JCheckBox(I18n.tr("Reverse buttons position when displaying images."));
    45   private JComboBox<String> downloadMode = new JComboBox<>(new String[]{
     42  private final JCheckBox reverseButtons = new JCheckBox(I18n.tr("Reverse buttons position when displaying images."));
     43  private final JComboBox<String> downloadMode = new JComboBox<>(new String[]{
    4644      MapillaryDownloader.MODES.Automatic.toString(),
    4745      MapillaryDownloader.MODES.Semiautomatic.toString(),
    4846      MapillaryDownloader.MODES.Manual.toString()
    4947  });
    50   private JCheckBox displayHour = new JCheckBox(I18n.tr("Display hour when the picture was taken"));
    51   private JCheckBox format24 = new JCheckBox(I18n.tr("Use 24 hour format"));
    52   private JCheckBox moveTo = new JCheckBox(I18n.tr("Move to picture''s location with next/previous buttons"));
     48  private final JCheckBox displayHour = new JCheckBox(I18n.tr("Display hour when the picture was taken"));
     49  private final JCheckBox format24 = new JCheckBox(I18n.tr("Use 24 hour format"));
     50  private final JCheckBox moveTo = new JCheckBox(I18n.tr("Move to picture''s location with next/previous buttons"));
    5351
    54   private JButton loginButton = new JButton(new LoginAction(this));
    55   private JButton logoutButton = new JButton(new LogoutAction());
    56   private JLabel loginLabel = new JLabel();
    57   private JPanel loginPanel = new JPanel();
     52  private final JButton loginButton = new JButton(new LoginAction(this));
     53  private final JButton logoutButton = new JButton(new LogoutAction());
     54  private final JLabel loginLabel = new JLabel();
     55  private final JPanel loginPanel = new JPanel();
    5856
    5957  @Override
     
    113111  }
    114112
    115   /**
    116    * Should be called whenever the user logs into a mapillary account.
    117    * This updates the GUI to reflect the login status.
    118    * @param username the username that the user is now logged in with
    119    */
     113  @Override
    120114  public void onLogin(final String username) {
    121115    loginPanel.add(logoutButton, 1);
     
    125119  }
    126120
    127   /**
    128    * Should be called whenever the user logs out of a mapillary account.
    129    * This updates the GUI to reflect the login status.
    130    */
     121  @Override
    131122  public void onLogout() {
    132123    loginPanel.remove(logoutButton);
     
    168159  public class LoginAction extends AbstractAction {
    169160    private static final long serialVersionUID = -3908477563072057344L;
    170     final transient MapillaryLoginListener callback;
     161    private final transient MapillaryLoginListener callback;
    171162
    172163    public LoginAction(MapillaryLoginListener loginCallback) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryLoginListener.java

    r31808 r31810  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.mapillary.oauth;
    23
     4/**
     5 * This interface should be implemented by components that want to get notified when the user
     6 * logs in or logs out of his Mapillary account.
     7 * Such listeners can be registered e.g. at a {@link OAuthPortListener}.
     8 */
    39public interface MapillaryLoginListener {
     10  /**
     11   * Should be called whenever the user logs into a mapillary account.
     12   * E.g. for updating the GUI to reflect the login status.
     13   * @param username the username that the user is now logged in with
     14   */
    415  public void onLogin(final String username);
     16  /**
     17   * Should be called whenever the user logs out of a mapillary account.
     18   * E.g. for updating the GUI to reflect the login status.
     19   */
    520  public void onLogout();
    621}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java

    r31807 r31810  
    1717 *
    1818 */
    19 public class MapillaryUser {
     19public final class MapillaryUser {
    2020
    2121  private static String username;
Note: See TracChangeset for help on using the changeset viewer.