Changeset 16175 in josm


Ignore:
Timestamp:
2020-03-19T21:52:26+01:00 (2 years ago)
Author:
Don-vip
Message:

fix #18953 - OrthogonalizeAction: don't produce empty commands sequence

File:
1 edited

Legend:

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

    r16119 r16175  
    210210        final int nodesCount = nodeList.size();
    211211        if (wayDataList.isEmpty() && nodesCount > 2) {
    212             final WayData data = new WayData(nodeList);
    213             final Collection<Command> commands = orthogonalize(Collections.singletonList(data), Collections.<Node>emptyList());
    214             return new SequenceCommand(tr("Orthogonalize"), commands);
    215         } else if (wayDataList.isEmpty()) {
    216             throw new InvalidUserInputException("usage");
    217         } else {
    218             if (nodesCount <= 2) {
    219                 OrthogonalizeAction.rememberMovements.clear();
    220                 final Collection<Command> commands = new LinkedList<>();
    221 
    222                 if (nodesCount == 2) {  // fixed direction, or single node to move
    223                     commands.addAll(orthogonalize(wayDataList, nodeList));
    224                 } else if (nodesCount == 1) {
    225                     commands.add(orthogonalize(wayDataList, nodeList.get(0)));
    226                 } else if (nodesCount == 0) {
    227                     for (List<WayData> g : buildGroups(wayDataList)) {
    228                         commands.addAll(orthogonalize(g, nodeList));
    229                     }
    230                 }
    231 
     212            return new SequenceCommand(tr("Orthogonalize"),
     213                    orthogonalize(Collections.singletonList(new WayData(nodeList)), Collections.<Node>emptyList()));
     214        } else if (!wayDataList.isEmpty() && nodesCount <= 2) {
     215            OrthogonalizeAction.rememberMovements.clear();
     216            final Collection<Command> commands = new LinkedList<>();
     217
     218            if (nodesCount == 2) {  // fixed direction, or single node to move
     219                commands.addAll(orthogonalize(wayDataList, nodeList));
     220            } else if (nodesCount == 1) {
     221                commands.add(orthogonalize(wayDataList, nodeList.get(0)));
     222            } else if (nodesCount == 0) {
     223                for (List<WayData> g : buildGroups(wayDataList)) {
     224                    commands.addAll(orthogonalize(g, nodeList));
     225                }
     226            }
     227
     228            if (!commands.isEmpty()) {
    232229                return new SequenceCommand(tr("Orthogonalize"), commands);
    233 
    234             } else {
    235                 throw new InvalidUserInputException("usage");
    236             }
    237         }
     230            }
     231        }
     232        throw new InvalidUserInputException("usage");
    238233    }
    239234
Note: See TracChangeset for help on using the changeset viewer.