Package org.openstreetmap.josm.command

Examples of org.openstreetmap.josm.command.Command


        List<Node> selectedNodes = new ArrayList<>(getCurrentDataSet().getSelectedNodes());
        List<Way> selectedWays = new ArrayList<>(getCurrentDataSet().getSelectedWays());

        try {
            Command cmd = null;
            //// Decide what to align based on selection:

            /// Only ways selected -> For each way align their nodes taking care of intersection
            if(selectedNodes.isEmpty() && !selectedWays.isEmpty()) {
                cmd = alignMultiWay(selectedWays);
View Full Code Here


                Way way = referers.get(0);
                if(n == way.firstNode() || n == way.lastNode()) continue;
                cmds.add(lines.get(way).projectionCommand(n));
            }
            else if(referers.size() == 2) {
                Command cmd = lines.get(referers.get(0)).intersectionCommand(n, lines.get(referers.get(1)));
                cmds.add(cmd);
            }
            else
                throw new InvalidSelection(tr("Intersection of three or more ways can not be solved. Abort."));
        }
View Full Code Here

            selectedNodes.addAll(nearestNodes);
        }

        Node targetNode = selectTargetNode(selectedNodes);
        Node targetLocationNode = selectTargetLocationNode(selectedNodes);
        Command cmd = mergeNodes(Main.main.getEditLayer(), selectedNodes, targetNode, targetLocationNode);
        if (cmd != null) {
            Main.main.undoRedo.add(cmd);
            Main.main.getEditLayer().data.setSelected(targetNode);
        }
    }
View Full Code Here

            target = targetLocationNode; // keep existing targetLocationNode as target to avoid unnecessary changes (see #2447)
        } else {
            target = selectTargetNode(allNodes);
        }

        Command cmd = mergeNodes(layer, nodes, target, targetLocationNode);
        if (cmd != null) {
            Main.main.undoRedo.add(cmd);
            getCurrentDataSet().setSelected(target);
        }
    }
View Full Code Here

        Collection<OsmPrimitive> sel = createSelection(Main.main.getCurrentDataSet().getSelected());
        int answer = showDialog(sel, supportsRelation());

        if (!sel.isEmpty() && answer == DIALOG_ANSWER_APPLY) {
            Command cmd = createCommand(sel, getChangedTags());
            if (cmd != null) {
                Main.main.undoRedo.add(cmd);
            }
        } else if (answer == DIALOG_ANSWER_NEW_RELATION) {
            final Relation r = new Relation();
View Full Code Here

        public void run() {
            final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation);
            if (commandAndRelation == null) {
                return;
            }
            final Command command = commandAndRelation.a;
            final Relation relation = commandAndRelation.b;


            // to avoid EDT violations
            SwingUtilities.invokeLater(new Runnable() {
View Full Code Here

            return getErrorForPrimitive(p, whichSelectorMatchesEnvironment(env), env);
        }

        TestError getErrorForPrimitive(OsmPrimitive p, Selector matchingSelector, Environment env) {
            if (matchingSelector != null && !errors.isEmpty()) {
                final Command fix = fixPrimitive(p);
                final String description = getDescriptionForMatchingSelector(p, matchingSelector);
                final List<OsmPrimitive> primitives;
                if (env.child != null) {
                    primitives = Arrays.asList(p, env.child);
                } else {
View Full Code Here

        commitCommands(marktr("Delete relations"));

        // Delete the discarded inner ways
        if (!discardedWays.isEmpty()) {
            Command deleteCmd = DeleteCommand.delete(Main.main.getEditLayer(), discardedWays, true);
            if (deleteCmd != null) {
                cmds.add(deleteCmd);
                commitCommands(marktr("Delete Ways that are not part of an inner multipolygon"));
            }
        }
View Full Code Here

            return;
        case 1:
            Main.main.undoRedo.add(cmds.getFirst());
            break;
        default:
            Command c = new SequenceCommand(tr(description), cmds);
            Main.main.undoRedo.add(c);
            break;
        }

        cmds.clear();
View Full Code Here

                    // move nodes to new position
                    if (moveCommand == null || moveCommand2 == null) {
                        // make a new move commands
                        moveCommand = new MoveCommand(movingNodeList.get(0), movement1.getX(), movement1.getY());
                        moveCommand2 = new MoveCommand(movingNodeList.get(1), movement2.getX(), movement2.getY());
                        Command c = new SequenceCommand(tr("Extrude Way"), moveCommand, moveCommand2);
                        Main.main.undoRedo.add(c);
                    } else {
                        // reuse existing move commands
                        moveCommand.moveAgainTo(movement1.getX(), movement1.getY());
                        moveCommand2.moveAgainTo(movement2.getX(), movement2.getY());
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.command.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.