Package diva.canvas

Examples of diva.canvas.Figure


     * figure associated with it.  The location of the figure should be
     * set if some location is appropriate for it.
     */
    public Figure drawNode(Object node, Object parent) {
        NodeController nc = getNodeController(node);
        Figure f = nc.drawNode(node, parent);
        return f;
    }
View Full Code Here


        // selection on an edge before getting rid of the endpoints of
        // the edge.
        Iterator figures = (new HashSet(_map.values())).iterator();

        while (figures.hasNext()) {
            Figure figure = (Figure) figures.next();
            Object object = figure.getUserObject();

            if (_model.isEdge(object)) {
                if (!GraphUtilities.isPartiallyContainedEdge(object, _model
                        .getRoot(), _model)) {
                    if (_selectionModel.containsSelection(figure)) {
                        _selectionModel.removeSelection(figure);
                    }

                    clearEdge(object);

                    // Previously, the figure was being left in _map,
                    // which results in an accumulation over time
                    // of figures that should not be rendered.
                    // EAL 4/29/04.
                    _map.remove(object);
                }
            }
        }

        figures = (new HashSet(_map.values())).iterator();

        while (figures.hasNext()) {
            Figure figure = (Figure) figures.next();
            Object object = figure.getUserObject();

            if (_model.isNode(object)) {
                if (!GraphUtilities.isContainedNode(object, _model.getRoot(),
                        _model)) {
                    if (_selectionModel.containsSelection(figure)) {
                        _selectionModel.removeSelection(figure);
                    }

                    clearNode(object);

                    // Previously, the figure was being left in _map,
                    // which results in an accumulation over time
                    // of figures that should not be rendered.
                    // EAL 4/29/04.
                    _map.remove(object);
                }
            }
        }

        // Save the selected edges.
        Iterator edges = GraphUtilities.totallyContainedEdges(_model.getRoot(),
                _model);

        while (edges.hasNext()) {
            Object edge = edges.next();
            Figure oldFigure = getFigure(edge);
            boolean selected = _selectionModel.containsSelection(oldFigure);

            if (selected) {
                selectedEdges.add(edge);
            }
        }

        // Save the selected nodes.
        Iterator nodes = (GraphUtilities.nodeSet(_model.getRoot(), _model))
                .iterator();

        while (nodes.hasNext()) {
            Object node = nodes.next();
            Figure oldFigure = getFigure(node);
            boolean selected = _selectionModel.containsSelection(oldFigure);

            if (selected) {
                selectedNodes.add(node);
            }
View Full Code Here

    /**
     * Render a visual representation of the given edge.
     */
    public Connector render(Object edge, Site tailSite, Site headSite) {
        AbstractConnector c;
        Figure tf = tailSite.getFigure();
        Figure hf = headSite.getFigure();

        //if the edge is a self loop, create an ArcConnector instead!
        if ((tf != null) && (hf != null) && (tf == hf)) {
            c = new ArcConnector(tailSite, headSite);
        } else {
View Full Code Here

     * valid site on the node's figure.
     */
    public void addEdge(Object edge, Object node, int end, double x, double y) {
        MutableGraphModel model = (MutableGraphModel) _controller
                .getGraphModel();
        Figure nf = _controller.getFigure(node);
        FigureLayer layer = _controller.getGraphPane().getForegroundLayer();
        Site headSite;
        Site tailSite;

        // Temporary sites.  One of these will get blown away later.
View Full Code Here

    /**
     * Remove the figure for the given edge, but do not remove the
     * edge from the graph model.
     */
    public void clearEdge(Object edge) {
        Figure f = _controller.getFigure(edge);

        if (f != null) {
            CanvasComponent container = f.getParent();
            f.setUserObject(null);
            _controller.setFigure(edge, null);

            if (container instanceof FigureLayer) {
                ((FigureLayer) container).remove(f);
            } else if (container instanceof CompositeFigure) {
View Full Code Here

        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.
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 {
                switch (evt.getEnd()) {
View Full Code Here

        GraphModel model = _controller.getGraphModel();
        Iterator i = targets();
        Set edgeSet = new HashSet();

        while (i.hasNext()) {
            Figure t = (Figure) i.next();

            // Translate anything that is not an edge
            // FIXME: we want to drag edges that are not connected
            // at either end
            // FIXME: translate edges that are connected on both ends
            // to targets?
            if (!(model.isEdge(t.getUserObject()))) {
                // Perform an inverse transform on coordinates for
                // composite nodes??
                // FIXME: This isn't right for scaling canvases... so I
                // doubt it is right for composite nodes.
                // TransformContext tc = t.getParent().getTransformContext();
                // tc.getInverseTransform().deltaTransform(pt, localpt);
                //t.translate(localpt.x,localpt.y);
                t.translate(x, y);
            }
        }

        edgeSet.addAll(GraphUtilities.edgeSet(model.getRoot(), model));
View Full Code Here

    public void addNode(Object node, double x, double y) {
        MutableGraphModel model = (MutableGraphModel) _controller
                .getGraphModel();
        model.addNode(_controller, node, model.getRoot());

        Figure nf = drawNode(node);
        CanvasUtilities.translateTo(nf, x, y);
    }
View Full Code Here

    public void addNode(Object node, Object parent, double x, double y) {
        MutableGraphModel model = (MutableGraphModel) _controller
                .getGraphModel();
        model.addNode(_controller, node, parent);

        Figure nf = drawNode(node, parent);
        CanvasUtilities.translateTo(nf, x, y);
    }
View Full Code Here

TOP

Related Classes of diva.canvas.Figure

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.