Ignore:
Timestamp:
2023-07-24T15:55:23+02:00 (16 months ago)
Author:
taylor.smock
Message:

reltoolbox: Clean up a bunch of lint warnings

Location:
applications/editors/josm/plugins/reltoolbox/src/relcontext
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java

    r34130 r36102  
    1111import java.awt.geom.GeneralPath;
    1212import java.util.HashSet;
     13import java.util.Objects;
    1314import java.util.Set;
    1415
     
    4142public class ChosenRelation implements ActiveLayerChangeListener, MapViewPaintable, DataSetListener {
    4243    protected Relation chosenRelation = null;
    43     private Set<ChosenRelationListener> chosenRelationListeners = new HashSet<>();
     44    private final Set<ChosenRelationListener> chosenRelationListeners = new HashSet<>();
    4445
    4546    public void set(Relation rel) {
    46         if (rel == chosenRelation || (rel != null && chosenRelation != null && rel.equals(chosenRelation)))
     47        if (Objects.equals(rel, chosenRelation))
    4748            return; // new is the same as old
    4849        Relation oldRel = chosenRelation;
     
    7374            return false;
    7475        else
    75             return chosenRelation != null && r.equals(chosenRelation);
     76            return r.equals(chosenRelation);
    7677    }
    7778
     
    150151        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f * opacity));
    151152
    152         drawRelations(g, mv, bbox, chosenRelation, new HashSet<Relation>());
     153        drawRelations(g, mv, bbox, chosenRelation, new HashSet<>());
    153154
    154155        g.setComposite(oldComposite);
     
    178179                            }
    179180                            g.draw(b);
    180                         }   break;
     181                        }
     182                        break;
    181183                    case RELATION:
    182184                        Color oldColor = g.getColor();
     
    195197    @Override
    196198    public void relationMembersChanged(RelationMembersChangedEvent event) {
    197         if (chosenRelation != null && event.getRelation().equals(chosenRelation)) {
     199        if (event.getRelation().equals(chosenRelation)) {
    198200            fireRelationChanged(chosenRelation);
    199201        }
     
    202204    @Override
    203205    public void tagsChanged(TagsChangedEvent event) {
    204         if (chosenRelation != null && event.getPrimitive().equals(chosenRelation)) {
     206        if (event.getPrimitive().equals(chosenRelation)) {
    205207            fireRelationChanged(chosenRelation);
    206208        }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java

    r32398 r36102  
    6161
    6262        StringBuilder sb = new StringBuilder();
    63         sb.append(type.substring(0, 1));
     63        sb.append(type.charAt(0));
    6464        if (type.equals("boundary") && rel.hasKey("admin_level")) {
    6565            sb.append(rel.get("admin_level"));
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java

    r35829 r36102  
    1414import java.awt.event.ActionListener;
    1515import java.awt.event.ItemEvent;
    16 import java.awt.event.ItemListener;
    1716import java.awt.event.KeyEvent;
    1817import java.awt.event.MouseAdapter;
     
    112111
    113112    private final DefaultTableModel relationsData;
    114     private ChosenRelation chosenRelation;
    115     private JPanel chosenRelationPanel;
    116     private ChosenRelationPopupMenu popupMenu;
    117     private MultipolygonSettingsPopup multiPopupMenu;
    118     private RoleComboBoxModel roleBoxModel;
    119     private SortAndFixAction sortAndFixAction;
     113    private final ChosenRelation chosenRelation;
     114    private final JPanel chosenRelationPanel;
     115    private final ChosenRelationPopupMenu popupMenu;
     116    private final MultipolygonSettingsPopup multiPopupMenu;
     117    private final RoleComboBoxModel roleBoxModel;
     118    private final SortAndFixAction sortAndFixAction;
    120119    // actions saved for unregistering on dialog destroying
    121120    private final EnterRoleAction enterRoleAction;
     
    149148        roleBox.setModel(roleBoxModel);
    150149        roleBox.addMouseListener(relationMouseAdapter);
    151         roleBox.addItemListener(new ItemListener() {
    152             @Override
    153             public void itemStateChanged(ItemEvent e) {
    154                 if (e.getStateChange() == ItemEvent.DESELECTED) return;
    155                 String memberRole = roleBoxModel.getSelectedMembersRole();
    156                 String selectedRole = roleBoxModel.isAnotherRoleSelected() ? askForRoleName() : roleBoxModel.getSelectedRole();
    157                 if (memberRole != null && selectedRole != null && !memberRole.equals(selectedRole)) {
    158                     applyRoleToSelection(selectedRole.trim());
    159                 }
     150        roleBox.addItemListener(e -> {
     151            if (e.getStateChange() == ItemEvent.DESELECTED) return;
     152            String memberRole = roleBoxModel.getSelectedMembersRole();
     153            String selectedRole = roleBoxModel.isAnotherRoleSelected() ? askForRoleName() : roleBoxModel.getSelectedRole();
     154            if (memberRole != null && selectedRole != null && !memberRole.equals(selectedRole)) {
     155                applyRoleToSelection(selectedRole.trim());
    160156            }
    161157        });
     
    652648        private List<String> roles = new ArrayList<>();
    653649        private int selectedIndex = -1;
    654         private JComboBox<String> combobox;
     650        private final JComboBox<String> combobox;
    655651        private String membersRole;
    656652        private final String EMPTY_ROLE = tr("<empty>");
     
    709705
    710706        public String getSelectedMembersRole() {
    711             return membersRole == EMPTY_ROLE ? "" : membersRole;
     707            return EMPTY_ROLE.equals(membersRole) ? "" : membersRole;
    712708        }
    713709
     
    756752        @Override
    757753        public void setSelectedItem(Object anItem) {
    758             int newIndex = anItem == null ? -1 : roles.indexOf(anItem);
     754            int newIndex = anItem instanceof String ? roles.indexOf((String) anItem) : -1;
    759755            if (newIndex != selectedIndex) {
    760756                selectedIndex = newIndex;
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextPlugin.java

    r33530 r36102  
    77import org.openstreetmap.josm.plugins.PluginInformation;
    88
     9/**
     10 * The entry-point for the reltoolbox plugin
     11 */
    912public class RelContextPlugin extends Plugin {
    10     private RelContextDialog dialog;
    1113
    1214    public RelContextPlugin(PluginInformation info) {
     
    1921        if (oldFrame == null && newFrame != null) {
    2022            //            if (dialog!=null) dialog.destroy();
    21             dialog = new RelContextDialog();
     23            RelContextDialog dialog = new RelContextDialog();
    2224            newFrame.addToggleDialog(dialog);
    2325        }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/AddRemoveMemberAction.java

    r34551 r36102  
    3535 */
    3636public class AddRemoveMemberAction extends JosmAction implements ChosenRelationListener {
    37     private ChosenRelation rel;
    38     private SortAndFixAction sortAndFix;
     37    private final ChosenRelation rel;
     38    private final SortAndFixAction sortAndFix;
    3939
    4040    public AddRemoveMemberAction(ChosenRelation rel, SortAndFixAction sortAndFix) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ClearChosenRelationAction.java

    r32395 r36102  
    1616
    1717public class ClearChosenRelationAction extends AbstractAction implements ChosenRelationListener {
    18     private ChosenRelation rel;
     18    private final ChosenRelation rel;
    1919
    2020    public ClearChosenRelationAction(ChosenRelation rel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java

    r34551 r36102  
    7171
    7272    public static boolean getDefaultPropertyValue(String property) {
    73         if (property.equals("boundary"))
    74             return false;
    75         else if (property.equals("boundaryways"))
    76             return true;
    77         else if (property.equals("tags"))
    78             return true;
    79         else if (property.equals("alltags"))
    80             return false;
    81         else if (property.equals("single"))
    82             return true;
    83         else if (property.equals("allowsplit"))
    84             return false;
     73        switch (property) {
     74            case "boundary":
     75            case "alltags":
     76            case "allowsplit":
     77                return false;
     78            case "boundaryways":
     79            case "tags":
     80            case "single":
     81                return true;
     82        }
    8583        throw new IllegalArgumentException(property);
    8684    }
     
    274272    }
    275273
    276     public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
    277 
    278     private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS = new TreeSet<>(Arrays.asList(new String[] {
    279             "boundary", "boundary_type", "type", "admin_level"
    280     }));
     274    public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList("barrier", "source");
     275
     276    private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS =
     277            new TreeSet<>(Arrays.asList("boundary", "boundary_type", "type", "admin_level"));
    281278
    282279    /**
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java

    r35829 r36102  
    77import java.awt.GridBagLayout;
    88import java.awt.event.ActionEvent;
    9 import java.awt.event.ActionListener;
    109import java.awt.event.KeyEvent;
    1110import java.util.Arrays;
     
    9392
    9493    // Thanks to TagInfo for the list
    95     private static final List<String> RELATION_TYPES = Arrays.asList(new String[] {
    96             "multipolygon", "boundary", "route", "site", "restriction", "associatedStreet", "public_transport",
    97             "street", "collection", "address", "enforcement", "destination_sign", "route_master", "junction",
    98             "waterway", "bridge", "tunnel", "surveillance"
    99     });
     94    private static final List<String> RELATION_TYPES = Arrays.asList("multipolygon", "boundary", "route", "site",
     95            "restriction", "associatedStreet", "public_transport", "street", "collection", "address", "enforcement",
     96            "destination_sign", "route_master", "junction", "waterway", "bridge", "tunnel", "surveillance");
    10097
    10198    private String askForType() {
     
    122119        dlg.setModalityType(ModalityType.DOCUMENT_MODAL);
    123120
    124         keys.getEditor().addActionListener(new ActionListener() {
    125             @Override
    126             public void actionPerformed(ActionEvent e) {
    127                 dlg.setVisible(false);
    128                 optionPane.setValue(JOptionPane.OK_OPTION);
    129             }
     121        keys.getEditor().addActionListener(e -> {
     122            dlg.setVisible(false);
     123            optionPane.setValue(JOptionPane.OK_OPTION);
    130124        });
    131125
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java

    r34551 r36102  
    1919
    2020public class DeleteChosenRelationAction extends AbstractAction implements ChosenRelationListener {
    21     private ChosenRelation rel;
     21    private final ChosenRelation rel;
    2222
    2323    public DeleteChosenRelationAction(ChosenRelation rel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java

    r33530 r36102  
    2828 */
    2929public class DownloadChosenRelationAction extends AbstractAction implements ChosenRelationListener {
    30     private ChosenRelation rel;
     30    private final ChosenRelation rel;
    3131
    3232    public DownloadChosenRelationAction(ChosenRelation rel) {
     
    7474    protected void downloadIncomplete(Relation rel) {
    7575        if (rel.isNew()) return;
    76         Set<OsmPrimitive> ret = new HashSet<>();
    77         ret.addAll(rel.getIncompleteMembers());
     76        Set<OsmPrimitive> ret = new HashSet<>(rel.getIncompleteMembers());
    7877        if (ret.isEmpty()) return;
    7978        MainApplication.worker.submit(
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java

    r33530 r36102  
    3030 */
    3131public class DownloadParentsAction extends AbstractAction implements ChosenRelationListener {
    32     private ChosenRelation rel;
     32    private final ChosenRelation rel;
    3333
    3434    public DownloadParentsAction(ChosenRelation rel) {
     
    6666    protected void downloadIncomplete(Relation rel) {
    6767        if (rel.isNew()) return;
    68         Set<OsmPrimitive> ret = new HashSet<>();
    69         ret.addAll(rel.getIncompleteMembers());
     68        Set<OsmPrimitive> ret = new HashSet<>(rel.getIncompleteMembers());
    7069        if (ret.isEmpty()) return;
    7170        MainApplication.worker.submit(
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java

    r35529 r36102  
    2222 */
    2323public class EditChosenRelationAction extends AbstractAction implements ChosenRelationListener {
    24     private ChosenRelation rel;
     24    private final ChosenRelation rel;
    2525
    2626    public EditChosenRelationAction(ChosenRelation rel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java

    r35196 r36102  
    88import java.awt.Dimension;
    99import java.awt.event.ActionEvent;
    10 import java.awt.event.ActionListener;
    1110import java.awt.event.KeyAdapter;
    1211import java.awt.event.KeyEvent;
     
    1514import java.util.ArrayList;
    1615import java.util.Collection;
    17 import java.util.Collections;
    1816import java.util.List;
    1917
     
    8785        });
    8886
    89         searchField.addActionListener(new ActionListener() {
    90             @Override
    91             public void actionPerformed(ActionEvent e) {
    92                 if (!relationsList.isSelectionEmpty()) {
    93                     dlg.setVisible(false);
    94                     optionPane.setValue(JOptionPane.OK_OPTION);
    95                 }
     87        searchField.addActionListener(e1 -> {
     88            if (!relationsList.isSelectionEmpty()) {
     89                dlg.setVisible(false);
     90                optionPane.setValue(JOptionPane.OK_OPTION);
    9691            }
    9792        });
     
    10095            @Override
    10196            public void keyTyped(KeyEvent e) {
    102                 SwingUtilities.invokeLater(new Runnable() {
    103                     @Override
    104                     public void run() {
    105                         updateRelationData(relationsData, searchField.getText());
    106                     }
    107                 });
     97                SwingUtilities.invokeLater(() -> updateRelationData(relationsData, searchField.getText()));
    10898            }
    10999
     
    196186        }
    197187
    198         Collections.sort(relations, DefaultNameFormatter.getInstance().getRelationComparator());
     188        relations.sort(DefaultNameFormatter.getInstance().getRelationComparator());
    199189        data.setRelations(relations);
    200190    }
     
    214204    protected static class FindRelationListModel extends AbstractListModel<Relation> {
    215205        private final ArrayList<Relation> relations = new ArrayList<>();
    216         private DefaultListSelectionModel selectionModel;
     206        private final DefaultListSelectionModel selectionModel;
    217207
    218208        public FindRelationListModel(DefaultListSelectionModel selectionModel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/PublicTransportHelper.java

    r34095 r36102  
    88/**
    99 * @author freeExec
    10  * @see https://wiki.openstreetmap.org/wiki/Key:public_transport
     10 * @see <a href="https://wiki.openstreetmap.org/wiki/Key:public_transport">osmwiki:Key:public_transport</a>
    1111 */
    1212public final class PublicTransportHelper {
     
    4949            if (p.hasKey(PUBLIC_TRANSPORT)) {
    5050                String pt = p.get(PUBLIC_TRANSPORT);
    51                 if (STOP_POSITION.equals(pt)) return true;
     51                return STOP_POSITION.equals(pt);
    5252            } else if (p.hasKey(RAILWAY)) {
    5353                String rw = p.get(RAILWAY);
    54                 if (RAILWAY_HALT.equals(rw) || RAILWAY_STATION.equals(rw)) return true;
     54                return RAILWAY_HALT.equals(rw) || RAILWAY_STATION.equals(rw);
    5555            }
    5656        }
     
    6666            if (p.hasKey(PUBLIC_TRANSPORT)) {
    6767                String pt = p.get(PUBLIC_TRANSPORT);
    68                 if (PLATFORM.equals(pt)) return true;
     68                return PLATFORM.equals(pt);
    6969            } else if (p.hasKey(HIGHWAY)) {
    7070                String hw = p.get(HIGHWAY);
    7171                if (BUS_STOP.equals(hw)) return true;
    72                 else if (PLATFORM.equals(hw)) return true;
     72                else return PLATFORM.equals(hw);
    7373            } else if (p.hasKey(RAILWAY)) {
    7474                String rw = p.get(RAILWAY);
    75                 if (PLATFORM.equals(rw)) return true;
     75                return PLATFORM.equals(rw);
    7676            }
    7777        }
     
    8787            if (p.hasKey(PUBLIC_TRANSPORT)) {
    8888                String pt = p.get(PUBLIC_TRANSPORT);
    89                 if (PLATFORM.equals(pt)) return true;
     89                return PLATFORM.equals(pt);
    9090            } else if (p.hasKey(HIGHWAY)) {
    9191                String hw = p.get(HIGHWAY);
    92                 if (PLATFORM.equals(hw)) return true;
     92                return PLATFORM.equals(hw);
    9393            } else if (p.hasKey(RAILWAY)) {
    9494                String rw = p.get(RAILWAY);
    95                 if (PLATFORM.equals(rw)) return true;
     95                return PLATFORM.equals(rw);
    9696            }
    9797        }
     
    124124            }
    125125        }
    126         return result;
     126        return null;
    127127    }
    128128}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java

    r35829 r36102  
    1010import java.util.Collections;
    1111import java.util.HashSet;
    12 import java.util.Iterator;
    1312import java.util.List;
    1413import java.util.Map;
     
    4443 */
    4544public class ReconstructPolygonAction extends JosmAction implements ChosenRelationListener {
    46     private ChosenRelation rel;
    47 
    48     private static final List<String> IRRELEVANT_KEYS = Arrays.asList(new String[] {
    49             "source", "created_by", "note"});
     45    private final ChosenRelation rel;
     46
     47    private static final List<String> IRRELEVANT_KEYS = Arrays.asList("source", "created_by", "note");
    5048
    5149    public ReconstructPolygonAction(ChosenRelation rel) {
     
    109107                // this ring has inner rings, so we leave a multipolygon in
    110108                // place and don't reconstruct the rings.
    111                 Relation n = null;
     109                Relation n;
    112110                if (relationReused) {
    113111                    n = new Relation();
     
    153151                }
    154152                List<OsmPrimitive> referrers = w.getReferrers();
    155                 for (Iterator<OsmPrimitive> ref1 = relations.iterator(); ref1.hasNext();) {
    156                     if (!referrers.contains(ref1.next())) {
    157                         ref1.remove();
    158                     }
    159                 }
     153                relations.removeIf(osmPrimitive -> !referrers.contains(osmPrimitive));
    160154            }
    161155            tags.putAll(r.getKeys());
     
    169163                    Set<String> keys = new HashSet<>(w.keySet());
    170164                    keys.removeAll(tags.keySet());
    171                     keys.removeAll(IRRELEVANT_KEYS);
     165                    IRRELEVANT_KEYS.forEach(keys::remove);
    172166                    if (keys.isEmpty()) {
    173167                        if (candidateWay == null) {
     
    211205
    212206    private boolean isSuitableRelation(Relation newRelation) {
    213         if (newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0)
    214             return false;
    215         else
    216             return true;
     207        return newRelation != null && "multipolygon".equals(newRelation.get("type")) && newRelation.getMembersCount() != 0;
    217208    }
    218209}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructRouteAction.java

    r34551 r36102  
    99import java.util.List;
    1010import java.util.Map;
     11import java.util.Objects;
    1112
    1213import javax.swing.AbstractAction;
     
    9697                if (routeMembers.size() > 2) {
    9798                    Way nextWay = (Way) routeMembers.get(rIndex + 1).getMember();
    98                     if (w.lastNode().equals(nextWay.lastNode()) || w.lastNode().equals(nextWay.firstNode())) {
     99                    if (Objects.equals(w.lastNode(), nextWay.lastNode()) || Objects.equals(w.lastNode(), nextWay.firstNode())) {
    99100                        dirForward = true;
    100101                        lastNode = w.lastNode();
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectInRelationPanelAction.java

    r33530 r36102  
    1616
    1717public class SelectInRelationPanelAction extends AbstractAction implements ChosenRelationListener {
    18     private ChosenRelation rel;
     18    private final ChosenRelation rel;
    1919
    2020    public SelectInRelationPanelAction(ChosenRelation rel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java

    r33530 r36102  
    55
    66import java.awt.event.ActionEvent;
     7import java.util.Collections;
    78
    89import javax.swing.AbstractAction;
     
    1617
    1718public class SelectMembersAction extends AbstractAction implements ChosenRelationListener {
    18     private ChosenRelation rel;
     19    private final ChosenRelation rel;
    1920
    2021    public SelectMembersAction(ChosenRelation rel) {
     
    2829    @Override
    2930    public void actionPerformed(ActionEvent e) {
    30         MainApplication.getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());
     31        MainApplication.getLayerManager().getEditLayer().data.setSelected(
     32                rel.get() == null ? Collections.emptyList() : rel.get().getMemberPrimitives());
    3133    }
    3234
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java

    r33530 r36102  
    1616
    1717public class SelectRelationAction extends AbstractAction implements ChosenRelationListener {
    18     private ChosenRelation rel;
     18    private final ChosenRelation rel;
    1919
    2020    public SelectRelationAction(ChosenRelation rel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java

    r34551 r36102  
    2828public class SortAndFixAction extends AbstractAction implements ChosenRelationListener {
    2929    private static final long serialVersionUID = 1L;
    30     private ChosenRelation rel;
    31     private List<RelationFixer> fixers;
     30    private final ChosenRelation rel;
     31    private final List<RelationFixer> fixers;
    3232
    3333    public SortAndFixAction(ChosenRelation rel) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java

    r35976 r36102  
    1212import java.util.List;
    1313import java.util.Map;
     14import java.util.Objects;
    1415
    1516import org.openstreetmap.josm.command.AddCommand;
     
    1920import org.openstreetmap.josm.data.UndoRedoHandler;
    2021import org.openstreetmap.josm.data.coor.EastNorth;
    21 import org.openstreetmap.josm.data.coor.LatLon;
    2222import org.openstreetmap.josm.data.osm.DataSet;
    2323import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
     24import org.openstreetmap.josm.data.osm.INode;
    2425import org.openstreetmap.josm.data.osm.Node;
    2526import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    206207                for (int i = 0; i < rel.getMembersCount(); i++) {
    207208                    if (rel.getMember(i).getMember().equals(w)) {
    208                         references.put(rel, Integer.valueOf(i));
     209                        references.put(rel, i);
    209210                    }
    210211                }
     
    253254            return null;
    254255
     256        final Node segmentFirstNode = segment.firstNode();
     257        final Node segmentLastNode = segment.lastNode();
     258
     259        if (segmentLastNode == null || segmentFirstNode == null) {
     260            return null;
     261        }
     262
    255263        List<Way> ways = intersection(
    256                 Utils.filteredCollection(segment.firstNode().getReferrers(), Way.class),
    257                 Utils.filteredCollection(segment.lastNode().getReferrers(), Way.class));
     264                Utils.filteredCollection(segmentFirstNode.getReferrers(), Way.class),
     265                Utils.filteredCollection(segmentLastNode.getReferrers(), Way.class));
    258266        ways.remove(segment);
    259267        for (Iterator<Way> iter = ways.iterator(); iter.hasNext();) {
    260268            boolean save = false;
    261269            for (OsmPrimitive ref : iter.next().getReferrers()) {
    262                 if (ref instanceof Relation && ((Relation) ref).isMultipolygon() && !ref.isDeleted()) {
     270                if (ref instanceof Relation && ref.isMultipolygon() && !ref.isDeleted()) {
    263271                    save = true;
    264272                }
     
    292300
    293301        // now split the way, at last
    294         List<Way> newWays = new ArrayList<>(splitWay(target, segment.firstNode(), segment.lastNode(), commands));
     302        List<Way> newWays = new ArrayList<>(splitWay(target, segmentFirstNode, segmentLastNode, commands));
    295303
    296304        Way addingWay = null;
     
    303311        } else {
    304312            for (Way w : newWays) {
    305                 if ((w.firstNode().equals(segment.firstNode()) && w.lastNode().equals(segment.lastNode()))
    306                         || (w.firstNode().equals(segment.lastNode()) && w.lastNode().equals(segment.firstNode()))) {
     313                final INode wFirstNode = w.firstNode();
     314                final INode wLastNode = w.lastNode();
     315                if ((Objects.equals(wFirstNode, segmentFirstNode) && Objects.equals(wLastNode, segmentLastNode))
     316                        || (Objects.equals(wFirstNode, segmentLastNode) && Objects.equals(wLastNode, segmentFirstNode))) {
    307317                    addingWay = w;
    308318                    break;
     
    341351                if (p instanceof Way && !p.equals(ring)) {
    342352                    for (OsmPrimitive r : p.getReferrers()) {
    343                         if (r instanceof Relation && ((Relation) r).hasKey("type") && ((Relation) r).get("type").equals("multipolygon")) {
     353                        if (r instanceof Relation && r.hasKey("type") && r.get("type").equals("multipolygon")) {
    344354                            if (touchingWays.containsKey(p)) {
    345355                                touchingWays.put((Way) p, Boolean.TRUE);
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java

    r34551 r36102  
    3737    private static final String PREF_MULTIPOLY = "reltoolbox.multipolygon.";
    3838
    39     private Way source;
    40     private List<RingSegment> segments;
     39    private final Way source;
     40    private final List<RingSegment> segments;
    4141    private Relation relation = null;
    4242
     
    277277
    278278        // rearrange references
    279         for (int i = 0; i < rings.size(); i++) {
    280             TheRing ring = rings.get(i);
     279        for (TheRing ring : rings) {
    281280            if (ring.countNonReferenceSegments() == 0) {
    282281                // need to find one non-reference segment
     
    331330        Way sourceCopy = new Way(source);
    332331        if (createMultipolygon) {
    333             Collection<String> linearTags = Config.getPref().getList(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
     332            Collection<String> linearTags = Config.getPref().getList(PREF_MULTIPOLY + "lineartags",
     333                    CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);
    334334            relation = new Relation();
    335335            relation.put("type", "multipolygon");
     
    351351        for (OsmPrimitive p : source.getReferrers()) {
    352352            if (p instanceof Relation) {
    353                 Relation rel = null;
     353                Relation rel;
    354354                if (relationChangeMap != null) {
    355355                    if (relationChangeMap.containsKey(p)) {
     
    365365                for (int i = 0; i < rel.getMembersCount(); i++) {
    366366                    if (rel.getMember(i).getMember().equals(source)) {
    367                         referencingRelations.put(rel, Integer.valueOf(i));
     367                        referencingRelations.put(rel, i);
    368368                    }
    369369                }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java

    r33708 r36102  
    155155         */
    156156        // return results
    157         if (commandList.size() == 0)
     157        if (commandList.isEmpty()) {
    158158            return null;
    159         if (commandList.size() == 1)
    160             return commandList.get(0);
    161         return new SequenceCommand(tr("fix associatedStreet relation"), commandList);
     159        }
     160        return SequenceCommand.wrapIfNeeded(tr("fix associatedStreet relation"), commandList);
    162161    }
    163162}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/BoundaryFixer.java

    r34095 r36102  
    1212import org.openstreetmap.josm.gui.MainApplication;
    1313
    14 
    1514/**
    16  * @see https://wiki.openstreetmap.org/wiki/Relation:boundary
     15 * Fix multipolygon boundaries
     16 * @see <a href="https://wiki.openstreetmap.org/wiki/Relation:boundary">osmwiki:Relation:boundary</a>
    1717 */
    1818public class BoundaryFixer extends MultipolygonFixer {
     
    2525     * For boundary relations both "boundary" and "multipolygon" types are applicable, but
    2626     * it should also have key boundary=administrative to be fully boundary.
    27      * @see https://wiki.openstreetmap.org/wiki/Relation:boundary
     27     * @see <a href="https://wiki.openstreetmap.org/wiki/Relation:boundary">osmwiki:Relation:boundary</a>
    2828     */
    2929    @Override
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java

    r34095 r36102  
    2020
    2121/**
    22  * @see https://wiki.openstreetmap.org/wiki/Relation:multipolygon
     22 * @see <a href="https://wiki.openstreetmap.org/wiki/Relation:multipolygon">osmwiki:Relation:multipolygon</a>
    2323 */
    2424public class MultipolygonFixer extends RelationFixer {
     
    6969        Set<Way> outerWays = new HashSet<>();
    7070        for (MultipolygonBuilder.JoinedPolygon poly : mpc.outerWays) {
    71             for (Way w : poly.ways) {
    72                 outerWays.add(w);
    73             }
     71            outerWays.addAll(poly.ways);
    7472        }
    7573        Set<Way> innerWays = new HashSet<>();
    7674        for (MultipolygonBuilder.JoinedPolygon poly : mpc.innerWays) {
    77             for (Way w : poly.ways) {
    78                 innerWays.add(w);
    79             }
     75            innerWays.addAll(poly.ways);
    8076        }
    8177        for (int i = 0; i < r.getMembersCount(); i++) {
    8278            RelationMember m = r.getMember(i);
    8379            if (m.isWay()) {
     80                final Way way = m.getWay();
    8481                String role = null;
    85                 if (outerWays.contains(m.getMember())) {
     82                if (outerWays.contains(way)) {
    8683                    role = "outer";
    87                 } else if (innerWays.contains(m.getMember())) {
     84                } else if (innerWays.contains(way)) {
    8885                    role = "inner";
    8986                }
    9087                if (role != null && !role.equals(m.getRole())) {
    91                     r.setMember(i, new RelationMember(role, m.getMember()));
     88                    r.setMember(i, new RelationMember(role, way));
    9289                    fixed = true;
    9390                }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/PublicTransportFixer.java

    r34095 r36102  
    1414
    1515/**
    16  * @see https://wiki.openstreetmap.org/wiki/Key:public_transport
    17  */
    18 
    19 /**
    2016 * Helper function for determinate role in public_transport relation
    2117 * @author freeExec
     18 * @see <a href="https://wiki.openstreetmap.org/wiki/Key:public_transport">osmwiki:Key:public_transport</a>
    2219 */
    2320public class PublicTransportFixer extends RelationFixer {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java

    r34551 r36102  
    1717public abstract class RelationFixer {
    1818
    19     private List<String> applicableTypes;
     19    private final List<String> applicableTypes;
    2020    private SortAndFixAction sortAndFixAction;
    2121
Note: See TracChangeset for help on using the changeset viewer.