Package diva.graph

Examples of diva.graph.GraphModel


    /**
     * Called in response to the edge head being changed.
     */
    public void edgeDrawn(Object edge) {
        GraphModel model = _target.getGraphModel();

        // FIXME this is probably not quite right.
        Object root = model.getRoot();
        layout(root);
    }
View Full Code Here


    /**
     * Called in response to the edge tail being changed.
     */
    public void edgeRouted(Object edge) {
        GraphModel model = _target.getGraphModel();

        // FIXME this is probably not quite right.
        Object root = model.getRoot();
        layout(root);
    }
View Full Code Here

    /**
     * Return the viewport of the given graph as a rectangle
     * in logical coordinates.
     */
    public Rectangle2D getViewport(Object composite) {
        GraphModel model = _controller.getGraphModel();

        if (composite == getRootGraph()) {
            Point2D p = getGraphicsPane().getSize();

            double borderPercentage = (1 - getLayoutPercentage()) / 2;
            double x = borderPercentage * p.getX();
            double y = borderPercentage * p.getY();
            double w = getLayoutPercentage() * p.getX();
            double h = getLayoutPercentage() * p.getY();
            return new Rectangle2D.Double(x, y, w, h);
        } else if (model.isComposite(composite)) {
            CompositeFigure cf = (CompositeFigure) _controller
                    .getFigure(composite);

            if (cf != null) {
                return cf.getShape().getBounds2D();
View Full Code Here

    /**
     * Return an iterator over the nodes which intersect the given
     * rectangle in the top-level graph.
     */
    public Iterator intersectingNodes(Rectangle2D r) {
        final GraphModel model = _controller.getGraphModel();
        ZList zlist = getGraphicsPane().getForegroundLayer().getFigures();
        Iterator i = zlist.getIntersectedFigures(r).figuresFromFront();
        Iterator j = new FilteredIterator(i, new Filter() {
            public boolean accept(Object o) {
                Figure f = (Figure) o;
                return (model.isNode(f.getUserObject()));
            }
        });

        return new ProxyIterator(j) {
            public Object next() {
View Full Code Here

    /**
     * Copy the given graph and make the nodes/edges in the copied
     * graph point to the nodes/edges in the original.
     */
    protected Object copyComposite(Object origComposite) {
        GraphModel model = getLayoutTarget().getGraphModel();
        Object copyComposite = _local.createComposite(null);
        HashMap map = new HashMap();

        for (Iterator i = model.nodes(origComposite); i.hasNext();) {
            Object origNode = i.next();

            if (getLayoutTarget().isNodeVisible(origNode)) {
                Rectangle2D r = getLayoutTarget().getBounds(origNode);
                LevelInfo inf = new LevelInfo();
                inf.origNode = origNode;
                inf.x = r.getX();
                inf.y = r.getY();
                inf.width = r.getWidth();
                inf.height = r.getHeight();

                Object copyNode = _local.createNode(inf);
                _local.addNode(this, copyNode, copyComposite);
                map.put(origNode, copyNode);
            }
        }

        for (Iterator i = model.nodes(origComposite); i.hasNext();) {
            Object origTail = i.next();

            for (Iterator j = model.outEdges(origTail); j.hasNext();) {
                Object origEdge = j.next();
                Object origHead = model.getHead(origEdge);

                if (origHead != null) {
                    Object copyTail = map.get(origTail);
                    Object copyHead = map.get(origHead);

View Full Code Here

     * </li>
     * To apply this layout to the target environment, call applyLayout
     * with the returned LevelData.
     */
    public LevelData calculateLayout(Object composite) {
        GraphModel model = getLayoutTarget().getGraphModel();

        if (model.getNodeCount(composite) > 0) {
            LevelData levelData = new LevelData(getLayoutTarget(), composite);
            levelData._copyGraph = copyComposite(composite);
            breakCycles(levelData._copyGraph, _local);

            //Assign level numbers to the nodes in the composite.
View Full Code Here

    /**
     * Return the rendered visual representation of this node.
     */
    public Figure render(Object node) {
        GraphModel model = _controller.getGraphModel();
        Shape shape = (model.isComposite(node)) ? _compositeShape : _nodeShape;

        if (shape instanceof RectangularShape) {
            RectangularShape r = (RectangularShape) shape;
            shape = (Shape) (r.clone());
        } else {
            shape = new GeneralPath(shape);
        }

        Paint fill = model.isComposite(node) ? _compositeFill : _nodeFill;

        BasicFigure bf = new BasicFigure(shape);
        bf.setFillPaint(fill);

        if (model.isComposite(node)) {
            CompositeFigure rep = new CompositeFigure(bf);
            double scale = getCompositeScale();
            rep.getTransformContext().getTransform().scale(scale, scale);
            return rep;
        }
View Full Code Here

     * about the layout except that it will fall into the required
     * viewport.
     */
    public void layout(Object composite) {
        LayoutTarget target = getLayoutTarget();
        GraphModel model = target.getGraphModel();

        for (Iterator ns = model.nodes(composite); ns.hasNext();) {
            Object node = ns.next();

            if (target.isNodeVisible(node)) {
                Rectangle2D vp = target.getViewport(composite);
                Rectangle2D bounds = target.getBounds(node);
View Full Code Here

     * Place the given node at the given position and
     * reroute its edges.
     */
    public static final void place(LayoutTarget target, Object node, double x,
            double y) {
        GraphModel model = target.getGraphModel();
        placeNoReroute(target, node, x, y);

        for (Iterator i = model.inEdges(node); i.hasNext();) {
            Object edge = i.next();

            if (target.isEdgeVisible(edge)) {
                target.route(edge); //XXX reroute
            }
        }

        for (Iterator i = model.outEdges(node); i.hasNext();) {
            Object edge = i.next();

            if (target.isEdgeVisible(edge)) {
                target.route(edge); //XXX reroute
            }
View Full Code Here

     *        CROSSING_PENALTY * num_crossing(e)
     ]
     * </pre>
     */
    protected double edgeCost(Object edge) {
        GraphModel model = getLayoutTarget().getGraphModel();
        Object tail = model.getTail(edge);
        Object head = model.getHead(edge);

        head = _getParentInGraph(head);
        tail = _getParentInGraph(tail);

        if ((head == null) || (tail == null)) {
View Full Code Here

TOP

Related Classes of diva.graph.GraphModel

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.