Package edu.uci.ics.jung.visualization

Examples of edu.uci.ics.jung.visualization.Layout


        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        PickSupport pickSupport = vv.getPickSupport();
        PickedState pickedState = vv.getPickedState();

        if(pickSupport != null && pickedState != null) {
            Layout layout = vv.getGraphLayout();
            if(e.getModifiers() == getModifiers()) {
                vv.addPostRenderPaintable(lensPaintable);
                rect.setFrameFromDiagonal(down,down);
                // p is the screen point for the mouse event
                Point2D p = e.getPoint();
                // take away the view transform
                Point2D ip = vv.inverseViewTransform(p);
               
                vertex = pickSupport.getVertex(ip.getX(), ip.getY());
                if(vertex != null) {
                    if(pickedState.isPicked(vertex) == false) {
                        pickedState.clearPickedVertices();
                        pickedState.pick(vertex, true);
                        vv.fireStateChanged();
                    }
                    // layout.getLocation applies the layout transformer so
                    // q is transformed by the layout transformer only
                    Point2D q = layout.getLocation(vertex);
                    // transform the mouse point to graph coordinate system
                    Point2D gp = vv.inverseLayoutTransform(ip);

                    offsetx = (float) (gp.getX()-q.getX());
                    offsety = (float) (gp.getY()-q.getY());
                } else if(isPickingEdges() &&
                        (edge = pickSupport.getEdge(ip.getX(), ip.getY())) != null) {
                    pickedState.clearPickedEdges();
                    pickedState.pick(edge, true);
                } else {
                    pickedState.clearPickedEdges();
                    pickedState.clearPickedVertices();
                    vv.fireStateChanged();
                }
               
            } else if(e.getModifiers() == (addToSelectionModifiers)) {
                vv.addPostRenderPaintable(lensPaintable);
                rect.setFrameFromDiagonal(down,down);
                Point2D p = e.getPoint();
                // remove view transform
                Point2D ip = vv.inverseViewTransform(p);
                vertex = pickSupport.getVertex(ip.getX(), ip.getY());
                if(vertex != null) {
                    boolean wasThere = pickedState.pick(vertex, !pickedState.isPicked(vertex));
                    if(wasThere) {
                        vertex = null;
                    } else {
                        // layout.getLocation applies the layout transformer so
                        // q is transformed by the layout transformer only
                        Point2D q = layout.getLocation(vertex);
                        // translate mouse point to graph coord system
                        Point2D gp = vv.inverseLayoutTransform(ip);

                        offsetx = (float) (gp.getX()-q.getX());
                        offsety = (float) (gp.getY()-q.getY());
View Full Code Here


            VisualizationViewer vv = (VisualizationViewer)e.getSource();
            if(vertex != null) {
                Point p = e.getPoint();
                Point2D graphPoint = vv.inverseTransform(p);
                Point2D graphDown = vv.inverseTransform(down);
                Layout layout = vv.getGraphLayout();
                double dx = graphPoint.getX()-graphDown.getX();
                double dy = graphPoint.getY()-graphDown.getY();
                PickedState ps = vv.getPickedState();
               
                for(Iterator iterator=ps.getPickedVertices().iterator(); iterator.hasNext(); ) {
                    Vertex v = (Vertex)iterator.next();
                    Point2D vp = layout.getLocation(v);
                    if (!layout.isLocked(v)) {
                        layout.forceMove(v, vp.getX()+dx, vp.getY()+dy);
                    }
                }
                down = p;

            } else {
View Full Code Here

    public void moveToNextHost(String key) {
        final VisualizationViewer vv = (VisualizationViewer) getVV(key);
        if (pickedVerticesIt != null && pickedVerticesIt.hasNext()) {
            Vertex vertex = (Vertex)pickedVerticesIt.next();
            if (vertex != null) {
                Layout layout = vv.getGraphLayout();
                Point2D q = layout.getLocation(vertex);
                Point2D lvc = vv.inverseTransform(vv.getCenter());
                final double dx = (lvc.getX() - q.getX()) / 10;
                final double dy = (lvc.getY() - q.getY()) / 10;
               
                Runnable animator = new Runnable() {
View Full Code Here

    }
   
    public void alignSelectedVertices(String key, Location loc) {
        PickedState pickedstate = getVV(key).getPickedState();
        Set vertices = pickedstate.getPickedVertices();
        Layout l = getVV(key).getGraphLayout();
        Vertex v = null;
        if (!vertices.isEmpty()) {
            Iterator it = vertices.iterator();
            v = (Vertex)it.next();
            Point2D p = l.getLocation(v);
           
            while (it.hasNext()) {
                v = (Vertex)it.next();
                if (loc == Location.Top) {
                    moveVertex(v, new Coordinates(l.getLocation(v).getX(), p.getY()), key);
                } else if (loc == Location.Left) {
                    moveVertex(v, new Coordinates(p.getX(), l.getLocation(v).getY()), key);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.visualization.Layout

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.