Changeset 4724 in josm


Ignore:
Timestamp:
27.12.2011 16:31:36 (5 months ago)
Author:
jttt
Message:

Fix some of errors found by FindBugs

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

Legend:

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

    r4719 r4724  
    3939import javax.swing.JTextArea; 
    4040import javax.swing.KeyStroke; 
    41 import javax.swing.RepaintManager; 
    4241import javax.swing.UIManager; 
    4342 
     
    887886                while(it.hasNext()){ 
    888887                    WeakReference<ProjectionChangeListener> wr = it.next(); 
    889                     if (wr.get() == null) { 
     888                    ProjectionChangeListener listener = wr.get(); 
     889                    if (listener == null) { 
    890890                        it.remove(); 
    891891                        continue; 
    892892                    } 
    893                     wr.get().projectionChanged(oldValue, newValue); 
     893                    listener.projectionChanged(oldValue, newValue); 
    894894                } 
    895895            } 
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r4580 r4724  
    208208 
    209209    /* 
    210     * Holding bin for changeset tag information, to be applied when or if this is ever uploaded. 
    211     */ 
     210     * Holding bin for changeset tag information, to be applied when or if this is ever uploaded. 
     211     */ 
    212212    private Map<String, String> changeSetTags = new HashMap<String, String>(); 
    213213 
     
    586586            selectedPrimitives = new LinkedHashSet<OsmPrimitive>(); 
    587587            changed = addSelected(selection, false) 
    588             || (!wasEmpty && selectedPrimitives.isEmpty()); 
     588                    || (!wasEmpty && selectedPrimitives.isEmpty()); 
    589589            if (changed) { 
    590590                selectionSnapshot = null; 
     
    783783    } 
    784784 
    785     /** 
    786      * 
    787      * @param primitiveId 
    788      * @param createNew 
    789      * @return 
    790      * @deprecated This method can created inconsistent dataset when called for node with id < 0 and createNew=true. That will add 
    791      * complete node without coordinates to dataset which is not allowed. 
    792      */ 
    793     @Deprecated 
    794     public OsmPrimitive getPrimitiveById(PrimitiveId primitiveId, boolean createNew) { 
    795         OsmPrimitive result = primitivesMap.get(primitiveId); 
    796  
    797         if (result == null && createNew) { 
    798             switch (primitiveId.getType()) { 
    799             case NODE: result = new Node(primitiveId.getUniqueId(), true); break; 
    800             case WAY: result = new Way(primitiveId.getUniqueId(), true); break; 
    801             case RELATION: result = new Relation(primitiveId.getUniqueId(), true); break; 
    802             } 
    803             addPrimitive(result); 
    804         } 
    805  
    806         return result; 
    807     } 
    808785 
    809786    /** 
     
    11751152        return ret; 
    11761153    } 
    1177      
     1154 
    11781155    /** 
    11791156     * Moves all primitives and datasources from DataSet "from" to this DataSet 
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r4431 r4724  
    2323 
    2424    private boolean isLatLonKnown() { 
    25         return lat != Double.NaN && lon != Double.NaN; 
     25        return !Double.isNaN(lat) && !Double.isNaN(lon); 
    2626    } 
    2727 
  • trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java

    r4099 r4724  
    33 
    44import java.util.ArrayList; 
     5import java.util.Arrays; 
    56import java.util.Collection; 
    67import java.util.List; 
     
    2728        this.id = id; 
    2829    } 
    29      
     30 
    3031    public void setVersion(int version) { 
    3132        this.version = version; 
    3233    } 
    33      
     34 
    3435    /** 
    3536     * override to make it public 
     
    4546    public String toString() { 
    4647        StringBuilder builder = new StringBuilder(); 
    47         builder.append(id).append(keys).append(getFlagsAsString()); 
     48        builder.append(id).append(Arrays.toString(keys)).append(getFlagsAsString()); 
    4849        return builder.toString(); 
    4950    } 
  • trunk/src/org/openstreetmap/josm/data/osm/history/History.java

    r4602 r4724  
    7171                    } 
    7272                } 
    73         ); 
     73                ); 
    7474        return new History(id, type, copy); 
    7575    } 
     
    8484                    } 
    8585                } 
    86         ); 
     86                ); 
    8787        return new History(id, type,copy); 
    8888    } 
     
    9696                    } 
    9797                } 
    98         ); 
     98                ); 
    9999    } 
    100100 
     
    107107                    } 
    108108                } 
    109         ); 
     109                ); 
    110110    } 
    111111 
     
    122122                    } 
    123123                } 
    124         ); 
     124                ); 
    125125    } 
    126126 
     
    133133                    } 
    134134                } 
    135         ); 
     135                ); 
    136136    } 
    137137 
     
    140140    } 
    141141 
    142     public History forUser(final String user) { 
    143         return filter( 
    144                 this, 
    145                 new FilterPredicate() { 
    146                     public boolean matches(HistoryOsmPrimitive primitive) { 
    147                         return primitive.getUser().equals(user); 
    148                     } 
    149                 } 
    150         ); 
    151     } 
    152  
    153142    public History forUserId(final long uid) { 
    154143        return filter( 
     
    159148                    } 
    160149                } 
    161         ); 
     150                ); 
    162151    } 
    163152 
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java

    r4627 r4724  
    252252     * represent a line that is shifted by a certain offset perpendicular 
    253253     * to the way direction. 
    254      *  
     254     * 
    255255     * There is no intention, to handle consecutive duplicate Nodes in a 
    256256     * perfect way, but it is should not throw an exception. 
     
    328328                int m = dx_next*(y_current0 - y_prev0) - dy_next*(x_current0 - x_prev0); 
    329329 
    330                 int cx_ = x_prev0 + Math.round(m * dx_prev / det); 
    331                 int cy_ = y_prev0 + Math.round(m * dy_prev / det); 
     330                int cx_ = x_prev0 + Math.round((float)m * dx_prev / det); 
     331                int cy_ = y_prev0 + Math.round((float)m * dy_prev / det); 
    332332                ++idx; 
    333333                prev = current; 
     
    809809 
    810810        Shape area = path.createTransformedShape(nc.getAffineTransform()); 
    811          
     811 
    812812        if (!isOutlineOnly) { 
    813813            if (fillImage == null) { 
     
    816816            } else { 
    817817                TexturePaint texture = new TexturePaint(fillImage, 
    818 //                        new Rectangle(polygon.xpoints[0], polygon.ypoints[0], fillImage.getWidth(), fillImage.getHeight())); 
    819                       new Rectangle(0, 0, fillImage.getWidth(), fillImage.getHeight())); 
     818                        //                        new Rectangle(polygon.xpoints[0], polygon.ypoints[0], fillImage.getWidth(), fillImage.getHeight())); 
     819                        new Rectangle(0, 0, fillImage.getWidth(), fillImage.getHeight())); 
    820820                g.setPaint(texture); 
    821821                if (fillImageAlpha != 1f) { 
     
    858858 
    859859            if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check 
    860                   area.contains(centeredNBounds) // slow but nice 
    861             ) { 
     860                    area.contains(centeredNBounds) // slow but nice 
     861                    ) { 
    862862                g.setColor(text.color); 
    863863                Font defaultFont = g.getFont(); 
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r3851 r4724  
    4545    { 
    4646        return tr("Remote Control has been asked to load data from the API.") + 
    47         "<br>" + tr("Request details: {0}", request); 
     47                "<br>" + tr("Request details: {0}", request); 
    4848    } 
    4949 
     
    8181                    Area toDownload = null; 
    8282                    DataSet ds = Main.main.getCurrentDataSet(); 
    83                     if (ds != null) 
     83                    if (ds != null) { 
    8484                        present = ds.getDataSourceArea(); 
     85                    } 
    8586                    if (present != null && !present.isEmpty()) { 
    8687                        toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat)); 
     
    168169                    } 
    169170                    ds.setSelected(newSel); 
    170                     if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) 
     171                    if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) { 
    171172                        new AutoScaleAction("selection").actionPerformed(null); 
     173                    } 
    172174                } 
    173175            }); 
     
    189191                        tags = URLDecoder.decode(args.get("addtags"), "UTF-8").split("\\|"); 
    190192                    } catch (UnsupportedEncodingException e) { 
    191                         new RuntimeException(); 
     193                        throw new RuntimeException(); 
    192194                    } 
    193195                    String[][] keyValue = new String[tags.length][2]; 
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    r4546 r4724  
    171171            List<OsmPrimitive> lhsList = lhs.getPrimitives(root); 
    172172            for (OsmPrimitive o: rhs.getPrimitives(root)) { 
    173                 if (lhsList.contains(o) && condition == null && condition.match(o)) { 
     173                if (lhsList.contains(o) && (condition == null || condition.match(o))) { 
    174174                    result.add(o); 
    175175                } 
Note: See TracChangeset for help on using the changeset viewer.