Changeset 8387 in josm for trunk/src


Ignore:
Timestamp:
2015-05-17T17:21:01+02:00 (9 years ago)
Author:
Don-vip
Message:

fix some Findbugs warnings

Location:
trunk/src/org/openstreetmap/josm
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java

    r7466 r8387  
    244244        );
    245245
    246         pane.getValue();
    247246        final JDialog dialog = new JDialog(
    248247                JOptionPane.getFrameForComponent(parentComponent),
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r8377 r8387  
    559559                            }
    560560                        }
    561                     } catch (Exception e) {
     561                    } catch (IOException | SecurityException e) {
     562                        if (Main.isDebugEnabled()) {
     563                            Main.debug("Exception while checking IPv6 connectivity: "+e);
     564                        }
    562565                    }
    563566                    if(wasv6 && !hasv6) {
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r8384 r8387  
    306306
    307307        this.bbox = bbox;
    308         double minLon = bbox.getMinLon();
    309         double maxLon = bbox.getMaxLon();
    310 
    311         if (bbox.crosses180thMeridian()) {
    312             minLon -= 360.0;
    313         }
    314 
    315308        iSelectionRectStart = new Coordinate(bbox.getMinLat(), bbox.getMinLon());
    316309        iSelectionRectEnd = new Coordinate(bbox.getMaxLat(), bbox.getMaxLon());
    317310
    318311        // calc the screen coordinates for the new selection rectangle
    319         MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMinLat(), bbox.getMinLon());
    320         MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMaxLat(), bbox.getMaxLon());
     312        MapMarkerDot min = new MapMarkerDot(bbox.getMinLat(), bbox.getMinLon());
     313        MapMarkerDot max = new MapMarkerDot(bbox.getMaxLat(), bbox.getMaxLon());
    321314
    322315        List<MapMarker> marker = new ArrayList<>(2);
    323         marker.add(xmin_ymin);
    324         marker.add(xmax_ymax);
     316        marker.add(min);
     317        marker.add(max);
    325318        setMapMarkerList(marker);
    326319        setDisplayToFitMapMarkers();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r8308 r8387  
    376376        public void actionPerformed(ActionEvent e) {
    377377            TreePath path;
    378             undoTree.getSelectionPath();
    379378            if (!undoTree.isSelectionEmpty()) {
    380379                path = undoTree.getSelectionPath();
     
    386385            OsmDataLayer editLayer = Main.main.getEditLayer();
    387386            if (editLayer == null) return;
    388             editLayer.data.setSelected( getAffectedPrimitives(path));
     387            editLayer.data.setSelected(getAffectedPrimitives(path));
    389388        }
    390389
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java

    r8365 r8387  
    1010import java.awt.Font;
    1111import java.util.Map;
     12import java.util.Objects;
    1213
    1314import javax.swing.JLabel;
     
    6566                    if (otherCount == 1) {
    6667                        for (Map.Entry<?, ?> entry : v.entrySet()) { // Find the non-blank value in the map
    67                             if ( entry.getKey() != "") {
     68                            if (!Objects.equals(entry.getKey(), "")) {
    6869                                /* I18n: properties display partial string joined with comma, frst is count, second is value */
    6970                                sb.append(tr("{0} ''{1}''", entry.getValue().toString(), entry.getKey()));
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r8379 r8387  
    124124     */
    125125    public static void notifyDownloadResults(final Component parent, PluginDownloadTask task, boolean restartRequired) {
    126         final Collection<PluginInformation> downloaded = task.getDownloadedPlugins();
    127126        final Collection<PluginInformation> failed = task.getFailedPlugins();
    128127        final StringBuilder sb = new StringBuilder();
  • trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java

    r6084 r8387  
    33
    44import java.awt.Component;
    5 import java.awt.Dialog;
    6 import java.awt.Frame;
    7 import java.awt.Window;
    85import java.awt.event.ActionEvent;
    96import java.awt.event.ActionListener;
     
    3532
    3633    public static final int PROGRESS_BAR_MAX = 10000;
    37     private final Window dialogParent;
     34    private final Component dialogParent;
    3835
    3936    private int currentProgressValue = 0;
     
    154151            public void run() {
    155152                Main.currentProgressMonitor = PleaseWaitProgressMonitor.this;
    156                 if (dialogParent instanceof Frame && dialog == null) {
    157                     dialog = new PleaseWaitDialog(dialogParent);
    158                 } else if (dialogParent instanceof Dialog && dialog == null) {
     153                if (dialogParent != null && dialog == null) {
    159154                    dialog = new PleaseWaitDialog(dialogParent);
    160155                } else
    161                     throw new ProgressException("PleaseWaitDialog parent must be either Frame or Dialog");
     156                    throw new ProgressException("PleaseWaitDialog parent must be set");
    162157
    163158                if (windowTitle != null) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java

    r8130 r8387  
    8888    @Override
    8989    public int compareTo(AutoCompletionItemPriority other) {
    90         int ui = -Integer.compare(userInput, other.userInput);
     90        int ui = Integer.compare(other.userInput, userInput);
    9191        if (ui != 0) return ui;
    9292
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r8073 r8387  
    468468        checkOfflineAccess(downloadString);
    469469
    470         HttpURLConnection con = null;
    471470        int numRedirects = 0;
    472471        while(true) {
    473             con = Utils.openHttpConnection(downloadUrl);
    474             if (con == null) {
    475                 throw new IOException("Cannot open http connection to "+downloadString);
    476             }
     472            HttpURLConnection con = Utils.openHttpConnection(downloadUrl);
    477473            if (ifModifiedSince != null) {
    478474                con.setIfModifiedSince(ifModifiedSince);
  • trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java

    r7937 r8387  
    6262
    6363    private char filter(char in) {
    64         if (in < 0x20 && in >= 0 && INVALID_CHARS[in]) {
     64        if (in < 0x20 && INVALID_CHARS[in]) {
    6565            if (firstWarning) {
    6666                Main.warn("Invalid xml character encountered: '"+in+"'.");
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r8384 r8387  
    631631        for (Node n : way.getNodes()) {
    632632            if (lastN != null) {
    633                 n.getEastNorth().getX();
    634 
    635633                area += (calcX(n) * calcY(lastN)) - (calcY(n) * calcX(lastN));
    636634            }
  • trunk/src/org/openstreetmap/josm/tools/ImageOverlay.java

    r8365 r8387  
    8484        int x, y;
    8585        if (width == -1 && offsetLeft < 0) {
    86             x = new Double(w*offsetRight).intValue() - overlay.getIconWidth();
     86            x = (int)(w*offsetRight) - overlay.getIconWidth();
    8787        } else {
    88             x = new Double(w*offsetLeft).intValue();
     88            x = (int)(w*offsetLeft);
    8989        }
    9090        if (height == -1 && offsetTop < 0) {
    91             y = new Double(h*offsetBottom).intValue() - overlay.getIconHeight();
     91            y = (int)(h*offsetBottom) - overlay.getIconHeight();
    9292        } else {
    93             y = new Double(h*offsetTop).intValue();
     93            y = (int)(h*offsetTop);
    9494        }
    9595        overlay.paintIcon(null, ground.getGraphics(), x, y);
Note: See TracChangeset for help on using the changeset viewer.