Ignore:
Timestamp:
2017-06-22T18:15:31+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] fixes from sonar

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java

    r33367 r33408  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.pt_assistant.actions;
    23
     
    5051
    5152    private static Cursor getCursor() {
    52         try {
    53             return ImageProvider.getCursor("crosshair", "bus");
    54         } catch (Exception e) {
    55             Main.error(e);
    56         }
    57         return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
     53        Cursor cursor = ImageProvider.getCursor("crosshair", "bus");
     54        if(cursor == null)
     55                cursor = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
     56        return cursor;
    5857    }
    5958
     
    7372
    7473    @Override
    75     public void mouseMoved (MouseEvent e) {
     74    public void mouseMoved(MouseEvent e) {
    7675
    7776        //while the mouse is moving, surroundings are checked
     
    8887                                Main.map.mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable);
    8988
    90                 if(wss.size() > 0) {
     89                if(!wss.isEmpty()) {
    9190                        for(WaySegment ws : wss) {
    9291                                newHighlights.add(ws.way);
     
    101100
    102101    @Override
    103     public void mouseClicked (MouseEvent e) {
     102    public void mouseClicked(MouseEvent e) {
    104103
    105104        Boolean newNode = false;
     
    150149    private void updateHighlights()
    151150    {
    152         if(oldHighlights.size() > 0 || newHighlights.size() > 0) {
     151        if(oldHighlights.isEmpty() && newHighlights.isEmpty()) {
     152                return;
     153        }
    153154
    154                 for(OsmPrimitive osm : oldHighlights) {
    155                         osm.setHighlighted(false);
    156                 }
     155                for(OsmPrimitive osm : oldHighlights) {
     156                osm.setHighlighted(false);
     157        }
    157158
    158                 for(OsmPrimitive osm : newHighlights) {
    159                         osm.setHighlighted(true);
    160                 }
     159        for(OsmPrimitive osm : newHighlights) {
     160                osm.setHighlighted(true);
     161        }
    161162
    162                 Main.getLayerManager().getEditLayer().invalidate();
     163                Main.getLayerManager().getEditLayer().invalidate();
    163164
    164                 oldHighlights.clear();
    165                 oldHighlights.addAll(newHighlights);
    166                 newHighlights.clear();
    167         }
     165        oldHighlights.clear();
     166        oldHighlights.addAll(newHighlights);
     167        newHighlights.clear();
    168168    }
    169169
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/EdgeSelectionAction.java

    r33407 r33408  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.pt_assistant.actions;
    23
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutAction.java

    r33404 r33408  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.pt_assistant.actions;
    23
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayerManager.java

    r33362 r33408  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.pt_assistant.gui;
    23
     
    1112import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;
    1213
    13 public class PTAssistantLayerManager implements SelectionChangedListener{
     14public class PTAssistantLayerManager implements SelectionChangedListener {
    1415
    15         public static PTAssistantLayerManager PTLM = new PTAssistantLayerManager();
    16     private PTAssistantLayer layer;
     16        public final static PTAssistantLayerManager PTLM = new PTAssistantLayerManager();
     17        private PTAssistantLayer layer;
    1718
    1819    public PTAssistantLayer getLayer() {
     
    2324    }
    2425
    25     public void resetLayer()
    26     {
     26    public void resetLayer() {
    2727        layer = null;
    2828    }
     
    3737
    3838        for (OsmPrimitive primitive : newSelection) {
    39             if (primitive.getType().equals(OsmPrimitiveType.RELATION)) {
    40                 if (RouteUtils.isTwoDirectionRoute((Relation) primitive)) {
     39            if (primitive.getType().equals(OsmPrimitiveType.RELATION)
     40                        && RouteUtils.isTwoDirectionRoute((Relation) primitive)) {
    4141                    routes.add(primitive);
    42                 }
    4342            }
    4443        }
Note: See TracChangeset for help on using the changeset viewer.