Package org.netbeans.api.visual.widget

Examples of org.netbeans.api.visual.widget.ConnectionWidget


                }
            }

            Collection<String> edges = scene.getEdges();
            for (String id: edges) {
                ConnectionWidget cw = (ConnectionWidget) scene.findWidget(id);
                boolean isSourceIn;
                boolean isTargetIn;

                LabelWidget source = (LabelWidget) scene.findWidget(scene
                        .getEdgeSource(id));
                Rectangle rect = source.getPreferredBounds();
                Point location = source.getPreferredLocation();
                Point pa = new Point(location.x + rect.x, location.y + rect.y);
                Point pb = new Point(location.x + rect.x + rect.width,
                        location.y + rect.y + rect.height);
                isSourceIn = isInSelectedArea(pa) && isInSelectedArea(pb);

                LabelWidget target = (LabelWidget) scene.findWidget(scene
                        .getEdgeTarget(id));
                rect = target.getPreferredBounds();
                location = target.getPreferredLocation();
                pa = new Point(location.x + rect.x, location.y + rect.y);
                pb = new Point(location.x + rect.x + rect.width, location.y
                        + rect.y + rect.height);
                isTargetIn = isInSelectedArea(pa) && isInSelectedArea(pb);

                if (!isSourceIn && !isTargetIn)
                    continue;
                cwList.add(cw);
                List<Point> cps = cw.getControlPoints();
                boolean isCpIn[] = new boolean[cps.size()];
                cpsList.add(cps);
                for (int i = 0; i < cps.size(); ++i) {
                    if (isInSelectedArea(cps.get(i)))
                        isCpIn[i] = true;
                    else
                        isCpIn[i] = false;
                }
                if (!isSourceIn)
                    isCpIn[0] = false;
                if (!isTargetIn)
                    isCpIn[cps.size() - 1] = false;

                isCpsValid.add(isCpIn);
            }

            for (Widget lw: nodeList) {
                Border border = lw.getBorder();
                if (border instanceof LozengeBorder)
                    ((LozengeBorder) border).setColor(Color.blue);
                if (border instanceof TriangleBorder)
                    ((TriangleBorder) border).setColor(Color.blue);
                if (border instanceof RectangleBorder)
                    ((RectangleBorder) border).setColor(Color.blue);
                lw.setForeground(Color.blue);
                lw.repaint();
            }
            for (ConnectionWidget cw: cwList) {
                cw.setLineColor(Color.blue);
                cw.setPaintControlPoints(true);
            }

        }

        isSelecting = false;
View Full Code Here


                        - lastPosition.y;
                lw.setPreferredLocation(new Point(xx, yy));

            }
            for (int i = 0; i < cwList.size(); ++i) {
                ConnectionWidget cw = cwList.get(i);
                List<Point> cps = cpsList.get(i);
                boolean[] isCpIn = isCpsValid.get(i);
                for (int j = 0; j < cps.size(); ++j)
                    if (isCpIn[j]) {
                        cps.get(j).x += event.getPoint().x - lastPosition.x;
                        cps.get(j).y += event.getPoint().y - lastPosition.y;
                    }
                cw.setControlPoints(cps, true);
            }
            selectedAreaStart.x += event.getPoint().x - lastPosition.x;
            selectedAreaStart.y += event.getPoint().y - lastPosition.y;
            selectedAreaEnd.x += event.getPoint().x - lastPosition.x;
            selectedAreaEnd.y += event.getPoint().y - lastPosition.y;
View Full Code Here

            String edge = (String) e.next();
            outEdges.writeObject(edge);
            outEdges.writeObject(scene.getEdgeSource(edge));
            outEdges.writeObject(scene.getEdgeTarget(edge));

            ConnectionWidget we = (ConnectionWidget) scene.findWidget(edge);
            Collection<Point> cp = we.getControlPoints();
            int cpNum = cp.size();
            outEdges.writeInt(cpNum);
            Iterator i = cp.iterator();
            while (i.hasNext()) {
                Point x = (Point) i.next();
View Full Code Here

        int edgeNum = inEdges.readInt();
        for (int i = 0; i < edgeNum; ++i) {
            String edge = (String) inEdges.readObject();
            String source = (String) inEdges.readObject();
            String target = (String) inEdges.readObject();
            ConnectionWidget e = (ConnectionWidget) scene.addEdge(edge);
            scene.setEdgeSource(edge, source);
            scene.setEdgeTarget(edge, target);
            int cpNum = inEdges.readInt();
            System.out.println("readedge: " + edge + "  " + source + "  "
                    + target + "  " + cpNum);
            Collection<Point> cp = new ArrayList<Point>();
            for (int j = 0; j < cpNum; ++j) {
                Point p = (Point) inEdges.readObject();
                cp.add(p);
            }
            e.setControlPoints(cp, true);
        }
        inEdges.close();
        inNodes.close();
        scene.validate();
    }
View Full Code Here

            return label;
        }
    }

    protected Widget attachEdgeWidget(String edge) {
        ConnectionWidget connection = new ConnectionWidget(this);
        connection.setRouter(router);
        // �����ɾ�� connection.setToolTipText("������Ƶ㣺���˫��");
        connection.setTargetAnchorShape(new TriangleAnchorShape(6, true, false,
                false, 6.0));
        connection.setControlPointShape(PointShape.SQUARE_FILLED_BIG);
        connection.setEndPointShape(PointShape.SQUARE_FILLED_BIG);
        connection.setLineColor(backgroundColor); // ������ɫ
        /*
         * float[] dash1 = { 10.0f }; //������ connection.setStroke(new
         * BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
         * 10.0f, dash1, 0.0f));
         */
 
View Full Code Here

        return connection;
    }

    protected void attachEdgeSourceAnchor(String edge, String oldSourceNode,
            String sourceNode) {
        ConnectionWidget widget = (ConnectionWidget) findWidget(edge);
        Widget sourceNodeWidget = findWidget(sourceNode);
        widget.setSourceAnchor(sourceNodeWidget != null ? AnchorFactory
                .createFreeRectangularAnchor(sourceNodeWidget, true) : null);
    }
View Full Code Here

                .createFreeRectangularAnchor(sourceNodeWidget, true) : null);
    }

    protected void attachEdgeTargetAnchor(String edge, String oldTargetNode,
            String targetNode) {
        ConnectionWidget widget = (ConnectionWidget) findWidget(edge);
        Widget targetNodeWidget = findWidget(targetNode);
        widget.setTargetAnchor(targetNodeWidget != null ? AnchorFactory
                .createFreeRectangularAnchor(targetNodeWidget, true) : null);
    }
View Full Code Here

        return widget;
    }

    @Override
    protected Widget attachEdgeWidget(String arg0) {
        ConnectionWidget connectionWidget = new ConnectionWidget(this);
        connectionLayer.addChild(connectionWidget);
        //connectionLayer.setLabel(arg0);
        return connectionWidget;
    }
View Full Code Here

        public Widget resolveTargetWidget(Scene arg0, Point arg1) {
            return null;
        }

        public void createConnection(Widget source, Widget target) {
            ConnectionWidget conn = new ConnectionWidget(GraphEditorScene.this);
            conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
            conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(target));
            conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(source));
            connectionLayer.addChild(conn);
        }
View Full Code Here

        w.getActions().addAction(moveAction);
        return w;
    }

    protected Widget attachEdgeWidget(InputBlockEdge edge) {
        ConnectionWidget w = new BlockConnectionWidget(this, edge);
        w.setRouter(RouterFactory.createDirectRouter());
        w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
        edgeLayer.addChild(w);
        return w;
    }
View Full Code Here

TOP

Related Classes of org.netbeans.api.visual.widget.ConnectionWidget

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.