Package org.openstreetmap.josm.data.osm

Examples of org.openstreetmap.josm.data.osm.Way


    private void unglueWays() {
        LinkedList<Command> cmds = new LinkedList<>();
        LinkedList<Node> newNodes = new LinkedList<>();

        if (selectedWay == null) {
            Way wayWithSelectedNode = null;
            LinkedList<Way> parentWays = new LinkedList<>();
            for (OsmPrimitive osm : selectedNode.getReferrers()) {
                if (osm.isUsable() && osm instanceof Way) {
                    Way w = (Way) osm;
                    if (wayWithSelectedNode == null && !w.isFirstLastNode(selectedNode)) {
                        wayWithSelectedNode = w;
                    } else {
                        parentWays.add(w);
                    }
                }
View Full Code Here


     * @return true if action is OK false if there is nothing to do
     */
    private boolean unglueSelfCrossingWay() {
        // According to previous check, only one valid way through that node
        LinkedList<Command> cmds = new LinkedList<>();
        Way way = null;
        for (Way w: OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class))
            if (w.isUsable() && w.getNodesCount() >= 1) {
                way = w;
            }
        List<Node> oldNodes = way.getNodes();
        ArrayList<Node> newNodes = new ArrayList<>(oldNodes.size());
        ArrayList<Node> addNodes = new ArrayList<>();
        boolean seen = false;
        for (Node n: oldNodes) {
            if (n == selectedNode) {
View Full Code Here

     *
     */
    private void unglueWays2() {
        LinkedList<Command> cmds = new LinkedList<>();
        List<Node> allNewNodes = new LinkedList<>();
        Way tmpWay = selectedWay;

        for (Node n : selectedNodes) {
            List<Node> newNodes = new LinkedList<>();
            tmpWay = modifyWay(n, tmpWay, cmds, newNodes);
            fixRelations(n, cmds, newNodes);
View Full Code Here

        return new LineElemStyle(c, type.default_major_z_index, line, color, dashesLine, dashesBackground, offset, realWidth);
    }

    @Override
    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
        Way w = (Way)primitive;
        /* show direction arrows, if draw.segment.relevant_directions_only is not set,
        the way is tagged with a direction key
        (even if the tag is negated as in oneway=false) or the way is selected */
        boolean showOrientation = !isModifier && (selected || paintSettings.isShowDirectionArrow()) && !paintSettings.isUseRealWidth();
        boolean showOneway = !isModifier && !selected &&
                !paintSettings.isUseRealWidth() &&
                paintSettings.isShowOnewayArrow() && w.hasDirectionKeys();
        boolean onewayReversed = w.reversedDirection();
        /* head only takes over control if the option is true,
        the direction should be shown at all and not only because it's selected */
        boolean showOnlyHeadArrowOnly = showOrientation && !selected && paintSettings.isShowHeadArrowOnly();
        Node lastN;

        Color myDashedColor = dashesBackground;
        BasicStroke myLine = line, myDashLine = dashesLine;
        if (realWidth > 0 && paintSettings.isUseRealWidth() && !showOrientation) {
            float myWidth = (int) (100 (float) (painter.getCircum() / realWidth));
            if (myWidth < line.getLineWidth()) {
                myWidth = line.getLineWidth();
            }
            myLine = new BasicStroke(myWidth, line.getEndCap(), line.getLineJoin(),
                    line.getMiterLimit(), line.getDashArray(), line.getDashPhase());
            if (dashesLine != null) {
                myDashLine = new BasicStroke(myWidth, dashesLine.getEndCap(), dashesLine.getLineJoin(),
                        dashesLine.getMiterLimit(), dashesLine.getDashArray(), dashesLine.getDashPhase());
            }
        }

        Color myColor = color;
        if (selected) {
            myColor = paintSettings.getSelectedColor(color.getAlpha());
        } else if (member) {
            myColor = paintSettings.getRelationSelectedColor(color.getAlpha());
        } else if(w.isDisabled()) {
            myColor = paintSettings.getInactiveColor();
            myDashedColor = paintSettings.getInactiveColor();
        }

        painter.drawWay(w, myColor, myLine, myDashLine, myDashedColor, offset, showOrientation,
                showOnlyHeadArrowOnly, showOneway, onewayReversed);

        if(paintSettings.isShowOrderNumber() && !painter.isInactiveMode()) {
            int orderNumber = 0;
            lastN = null;
            for(Node n : w.getNodes()) {
                if(lastN != null) {
                    orderNumber++;
                    painter.drawOrderNumber(lastN, n, orderNumber, myColor);
                }
                lastN = n;
View Full Code Here

        return new RepeatImageElemStyle(c, pattern, offset, spacing, phase, align);
    }

    @Override
    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
        Way w = (Way) primitive;
        painter.drawRepeatImage(w, pattern.getImage(), offset, spacing, phase, align);
    }
View Full Code Here

        return new LineTextElemStyle(c, text);
    }

    @Override
    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
        Way w = (Way)primitive;
        painter.drawTextOnPath(w, text);
    }
View Full Code Here

    /*
     * This function creates the way with given coordinates of nodes
     */
    private void addWay() {
        addedNodes = new HashMap<>();
        Way way = new Way();
        List<Command> commands = new LinkedList<>();
        for (LatLon ll : allCoordinates) {
            Node node = findOrCreateNode(ll, commands);
            way.addNode(node);
        }
        allCoordinates.clear();
        commands.add(new AddCommand(way));
        Main.main.undoRedo.add(new SequenceCommand(tr("Add way"), commands));
        Main.main.getCurrentDataSet().setSelected(way);
View Full Code Here

            g.drawRect((int)(pVia.x+vx+vx2)-w/2-2,(int)(pVia.y+vy+vy2)-h/2-2, w+4, h+4);
        }
    }

    public void drawRestriction(Relation r, MapImage icon) {
        Way fromWay = null;
        Way toWay = null;
        OsmPrimitive via = null;

        /* find the "from", "via" and "to" elements */
        for (RelationMember m : r.getMembers()) {
            if(m.getMember().isIncomplete())
                return;
            else {
                if(m.isWay()) {
                    Way w = m.getWay();
                    if(w.getNodesCount() < 2) {
                        continue;
                    }

                    switch(m.getRole()) {
                    case "from":
                        if(fromWay == null) {
                            fromWay = w;
                        }
                        break;
                    case "to":
                        if(toWay == null) {
                            toWay = w;
                        }
                        break;
                    case "via":
                        if(via == null) {
                            via = w;
                        }
                    }
                } else if(m.isNode()) {
                    Node n = m.getNode();
                    if("via".equals(m.getRole()) && via == null) {
                        via = n;
                    }
                }
            }
        }

        if (fromWay == null || toWay == null || via == null)
            return;

        Node viaNode;
        if(via instanceof Node)
        {
            viaNode = (Node) via;
            if(!fromWay.isFirstLastNode(viaNode))
                return;
        }
        else
        {
            Way viaWay = (Way) via;
            Node firstNode = viaWay.firstNode();
            Node lastNode = viaWay.lastNode();
            Boolean onewayvia = false;

            String onewayviastr = viaWay.get("oneway");
            if(onewayviastr != null)
            {
                if("-1".equals(onewayviastr)) {
                    onewayvia = true;
                    Node tmp = firstNode;
View Full Code Here

        for (RelationMember m : r.getMembers()) {
            if (m.getMember().isIncomplete()) {
                this.incomplete = true;
            } else if (m.getMember().isDrawable()) {
                if (m.isWay()) {
                    Way w = m.getWay();

                    if (w.getNodesCount() < 2) {
                        continue;
                    }

                    if (matcher.isInnerRole(m.getRole())) {
                        innerWays.add(w);
View Full Code Here

    public static Collection<JoinedWay> joinWays(Collection<Way> waysToJoin) {
        final Collection<JoinedWay> result = new ArrayList<>();
        final Way[] joinArray = waysToJoin.toArray(new Way[waysToJoin.size()]);
        int left = waysToJoin.size();
        while (left > 0) {
            Way w = null;
            boolean selected = false;
            List<Node> nodes = null;
            Set<Long> wayIds = new HashSet<>();
            boolean joined = true;
            while (joined && left > 0) {
                joined = false;
                for (int i = 0; i < joinArray.length && left != 0; ++i) {
                    if (joinArray[i] != null) {
                        Way c = joinArray[i];
                        if (c.getNodesCount() == 0) {
                            continue;
                        }
                        if (w == null) {
                            w = c;
                            selected = w.isSelected();
                            joinArray[i] = null;
                            --left;
                        } else {
                            int mode = 0;
                            int cl = c.getNodesCount()-1;
                            int nl;
                            if (nodes == null) {
                                nl = w.getNodesCount()-1;
                                if (w.getNode(nl) == c.getNode(0)) {
                                    mode = 21;
                                } else if (w.getNode(nl) == c.getNode(cl)) {
                                    mode = 22;
                                } else if (w.getNode(0) == c.getNode(0)) {
                                    mode = 11;
                                } else if (w.getNode(0) == c.getNode(cl)) {
                                    mode = 12;
                                }
                            } else {
                                nl = nodes.size()-1;
                                if (nodes.get(nl) == c.getNode(0)) {
                                    mode = 21;
                                } else if (nodes.get(0) == c.getNode(cl)) {
                                    mode = 12;
                                } else if (nodes.get(0) == c.getNode(0)) {
                                    mode = 11;
                                } else if (nodes.get(nl) == c.getNode(cl)) {
                                    mode = 22;
                                }
                            }
                            if (mode != 0) {
                                joinArray[i] = null;
                                joined = true;
                                if (c.isSelected()) {
                                    selected = true;
                                }
                                --left;
                                if (nodes == null) {
                                    nodes = w.getNodes();
                                    wayIds.add(w.getUniqueId());
                                }
                                nodes.remove((mode == 21 || mode == 22) ? nl : 0);
                                if (mode == 21) {
                                    nodes.addAll(c.getNodes());
                                } else if (mode == 12) {
                                    nodes.addAll(0, c.getNodes());
                                } else if (mode == 22) {
                                    for (Node node : c.getNodes()) {
                                        nodes.add(nl, node);
                                    }
                                } else /* mode == 11 */ {
                                    for (Node node : c.getNodes()) {
                                        nodes.add(0, node);
                                    }
                                }
                                wayIds.add(c.getUniqueId());
                            }
                        }
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.osm.Way

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.