Package diva.canvas.connector

Examples of diva.canvas.connector.Connector


    /**
     * Return whether or not the given edge is actually
     * visible in the view.
     */
    public boolean isEdgeVisible(Object edge) {
        Connector ef = (Connector) _controller.getFigure(edge);
        return ((ef != null) && ef.isVisible() && (ef.getParent() != null));
    }
View Full Code Here


                return (o instanceof Connector);
            }
        });
        return new ProxyIterator(j) {
            public Object next() {
                Connector ef = (Connector) super.next();
                return ef.getUserObject();
            }
        };
    }
View Full Code Here

    /**
     * Route absolutely the figure associated with the given edge in
     * the target's view.
     */
    public void route(Object edge) {
        Connector ef = (Connector) _controller.getFigure(edge);

        // FIXME this should just call route(), but the way connectors
        // handle rerouting is kindof broken.  see fixme in
        // abstractconnector.reroute();
        ef.reroute();
    }
View Full Code Here

        // Temporary sites.  One of these will get blown away later.
        headSite = new AutonomousSite(layer, x, y);
        tailSite = new AutonomousSite(layer, x, y);

        // Render the edge.
        Connector c = render(edge, layer, tailSite, headSite);

        try {
            //Attach the appropriate end of the edge to the node.
            if (end == ConnectorEvent.TAIL_END) {
                tailSite = getConnectorTarget().getTailSite(c, nf, x, y);

                if (tailSite == null) {
                    throw new RuntimeException("Invalid connector target: "
                            + "no valid site found for tail of new connector.");
                }

                model.setEdgeTail(_controller, edge, node);
                c.setTailSite(tailSite);
            } else {
                headSite = getConnectorTarget().getHeadSite(c, nf, x, y);

                if (headSite == null) {
                    throw new RuntimeException("Invalid connector target: "
                            + "no valid site found for head of new connector.");
                }

                model.setEdgeHead(_controller, edge, node);
                c.setHeadSite(headSite);
            }
        } catch (GraphException ex) {
            // If an error happened then blow away the edge, and rethrow
            // the exception
            removeEdge(edge);
View Full Code Here

        GraphModel model = _controller.getGraphModel();
        FigureLayer layer = _controller.getGraphPane().getForegroundLayer();
        Object tail = model.getTail(edge);
        Object head = model.getHead(edge);

        Connector connector = (Connector) _controller.getFigure(edge);
        Figure tailFigure = _controller.getFigure(tail);
        Figure headFigure = _controller.getFigure(head);

        Site tailSite;
        Site headSite;

        // If the tail is not attached,
        if (tailFigure == null) {
            // Then try to find the old tail site.
            if (connector != null) {
                tailSite = connector.getTailSite();
            } else {
                // FIXME try to manufacture a site.
                //throw new RuntimeException("drawEdge failed: could not find" +
                //                           " a tail site.");
                return null;
            }
        } else {
            // Get a new tail site based on the tail figure.
            Rectangle2D bounds = tailFigure.getBounds();
            tailSite = getConnectorTarget().getTailSite(tailFigure,
                    bounds.getCenterX(), bounds.getCenterY());
        }

        // If the head is not attached,
        if (headFigure == null) {
            // Then try to find the old head site.
            if (connector != null) {
                headSite = connector.getHeadSite();
            } else {
                // FIXME try to manufacture a site.
                //throw new RuntimeException("drawEdge failed: could not find" +
                //                           " a head site.");
                return null;
            }
        } else {
            // Get a new head site based on the head figure.
            Rectangle2D bounds = headFigure.getBounds();
            headSite = getConnectorTarget().getHeadSite(headFigure,
                    bounds.getCenterX(), bounds.getCenterY());
        }

        // If we did have an old figure, throw it away.
        if (connector != null) {
            clearEdge(edge);
        }

        // Create the figure
        Connector c = render(edge, layer, tailSite, headSite);
        _controller.dispatch(new GraphViewEvent(this,
                GraphViewEvent.EDGE_DRAWN, edge));
        return c;
    }
View Full Code Here

    /** Render the edge on the given layer between the two sites.
     */
    public Connector render(Object edge, FigureLayer layer, Site tailSite,
            Site headSite) {
        Connector ef = getEdgeRenderer().render(edge, tailSite, headSite);
        ef.setInteractor(getEdgeInteractor());
        ef.setUserObject(edge);
        _controller.setFigure(edge, ef);

        layer.add(ef);
        ef.route();
        return ef;
    }
View Full Code Here

        /**
         * Called when a connector end is dropped--attach or
         * detach the edge as appropriate.
         */
        public void connectorDropped(ConnectorEvent evt) {
            Connector c = evt.getConnector();
            Figure f = evt.getTarget();
            Object edge = c.getUserObject();
            Object node = (f == null) ? null : f.getUserObject();
            MutableGraphModel model = (MutableGraphModel) _controller
                    .getGraphModel();

            try {
View Full Code Here

        //                 }
        //             }
        //         }
        for (Iterator edges = edgeSet.iterator(); edges.hasNext();) {
            Object edge = edges.next();
            Connector c = (Connector) (_controller.getFigure(edge));

            if (c != null) {
                c.reroute();
            }
        }
    }
View Full Code Here

                        .getLayerY());
                tailSite = new AutonomousSite(layer, event.getLayerX(), event
                        .getLayerY());

                // Render the edge.
                Connector c = getEdgeController(link).render(link, layer,
                        tailSite, headSite);

                // get the actual attach site.
                tailSite = getEdgeController(link).getConnectorTarget()
                        .getTailSite(c, source, event.getLayerX(),
                                event.getLayerY());

                if (tailSite == null) {
                    throw new RuntimeException("Invalid connector target: "
                            + "no valid site found for tail of new connector.");
                }

                // And reattach the connector.
                c.setTailSite(tailSite);

                // Add it to the selection so it gets a manipulator, and
                // make events go to the grab-handle under the mouse
                getSelectionModel().addSelection(c);

                ConnectorManipulator cm = (ConnectorManipulator) c.getParent();
                GrabHandle gh = cm.getHeadHandle();
                layer.grabPointer(event, gh);
            } catch (Exception ex) {
                MessageHandler.error("Drag connection failed:", ex);
            }
View Full Code Here

         * Called when a connector end is dropped--attach or
         * detach the edge as appropriate.
         * @param evt The connector event.
         */
        public void connectorDropped(ConnectorEvent evt) {
            Connector c = evt.getConnector();
            Figure f = evt.getTarget();
            Link link = (Link) c.getUserObject();
            Object node = (f == null) ? null : f.getUserObject();
            ActorGraphModel model = (ActorGraphModel) getController()
                    .getGraphModel();

            switch (evt.getEnd()) {
View Full Code Here

TOP

Related Classes of diva.canvas.connector.Connector

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.