Examples of VisualizationViewer


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

        this.lensPaintable = new LensPaintable();
//        this.cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
    }

    public void mouseReleased(MouseEvent e) {
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        Point2D p = e.getPoint();
        if (checkModifiers(e) && isConsumer()) {
            if (rect.getHeight() > 10 && rect.getWidth() > 10) {
                Color c = JColorChooser.showDialog(vv, "Choose a background color", Color.GRAY);
                if (c != null) {
                    NexsmPaintableBox npb = new NexsmPaintableBox();
                    npb.setP1(vv.inverseTransform(down));
                    npb.setP2(vv.inverseTransform(p));
                    npb.setColor(c);
                    if (gm != null) {
                        gm.putRenderer(vv.getName(), npb);
                    }
                }
            }
            e.consume();
            setConsumer(false);
        }
        down = null;
        rect.setFrame(0,0,0,0);
        vv.removePostRenderPaintable(lensPaintable);
    }
View Full Code Here

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

        vv.removePostRenderPaintable(lensPaintable);
    }

    public void mousePressed(MouseEvent e) {
        down = e.getPoint();
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        if (checkModifiers(e) && isConsumer()) {
            vv.addPostRenderPaintable(lensPaintable);
            rect.setFrameFromDiagonal(down,down);
        }
    }
View Full Code Here

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

     * the event (in our case a VisualizationViewer) and the Point.
     */
    public void mousePressed(MouseEvent e) {
        Point p = e.getPoint();
        if (checkModifiers(e) || e.getModifiers() == mskbutton) {
            final VisualizationViewer vv = (VisualizationViewer)e.getSource();
            final Graph graph = vv.getGraphLayout().getGraph();
            //todo remove
            JPopupMenu jpm = new JPopupMenu();
            if (isInVV == false) {
               
                info.setVisible(false);
                info.setVV(vv);
                vv.add(info);
               
                isInVV = true;
            }
            Point2D ip = vv.inverseViewTransform(p);

            PickSupport picksupport = vv.getPickSupport();
            final PickedState pickedstate = vv.getPickedState();
            Vertex v = picksupport.getVertex(ip.getX(), ip.getY());
            if (v != null && info.hasSomethingToDisplay(v)) {
                info.refreshInfo(v);
                info.moveTo(v);
                info.setVisible(true);
View Full Code Here

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

        this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    }
   
    public void mousePressed(MouseEvent e) {
        down = e.getPoint();
        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());
                    }
                } else if(isPickingEdges() &&
View Full Code Here

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

     * Vertices contained in that rectangle
     *
     * clean up settings from mousePressed
     */
    public void mouseReleased(MouseEvent e) {
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        if(e.getModifiers() == modifiers) {
            if(down != null) {
                Point2D out = e.getPoint();
                if(vertex == null && heyThatsTooClose(down, out, 5) == false) {
                    pickContainedVertices(vv, true);
                }
            }
        } else if(e.getModifiers() == this.addToSelectionModifiers) {
            if(down != null) {
                Point2D out = e.getPoint();
                if(vertex == null && heyThatsTooClose(down,out,5) == false) {
                    pickContainedVertices(vv, false);
                }
            }
        }
        down = null;
        vertex = null;
        edge = null;
        rect.setFrame(0,0,0,0);
        vv.removePostRenderPaintable(lensPaintable);
    }
View Full Code Here

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

     * If the mouse is not over a Vertex, draw the rectangle
     * to select multiple Vertices
     */
    public void mouseDragged(MouseEvent e) {
        if(locked == false) {
            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)) {
View Full Code Here

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

     * Gets the Zoom In button (logical zoom) event and do something
     * @param evt The ActionEvent
     */
    public void zoominActionPerformed(ActionEvent evt) {
        Object src = evt.getSource();
        VisualizationViewer vv = null;
        if (src instanceof VisualizationViewer) {
            vv = (VisualizationViewer)src;
            if (slide.getValue() < slide.getMaximum()) {
                slide.setValue(slide.getValue() + slide.getMajorTickSpacing());
            }
            showError(vv.getName()"Btn IN");
        }
    }
View Full Code Here

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

     * Gets the Zoom Out button (logical zoom) event and do something
     * @param evt The ActionEvent
     */
    public void zoomoutActionPerformed(ActionEvent evt) {
        Object src = evt.getSource();
        VisualizationViewer vv = null;
        if (src instanceof VisualizationViewer) {
            vv = (VisualizationViewer)src;
            if (slide.getValue() > slide.getMinimum()) {
                slide.setValue(slide.getValue() - slide.getMajorTickSpacing());
            }
            showError(vv.getName(), "Btn Out");
        }
    }
View Full Code Here

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

        pickedVerticesIt = pickedVertices.iterator();
        moveToNextHost(key);
    }
   
    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() {
                   
                    public void run() {
                        for (int i = 0; i < 10; i++) {
                            vv.getLayoutTransformer().translate(dx, dy);
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException ex) {
                            }
                        }
View Full Code Here

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

        Set outE = v.getOutEdges();
        Boolean hide = null;
        Object tmp = null;
        Edge e = null;
        NexsmEdgeType et = null;
        VisualizationViewer vv = getVV(key);
        VisualizationViewer vvSatellite = getVV(key + "satellite");
        //the childs
        for (Object o: outE) {
            if (o instanceof Edge) {
                e = (Edge)o;
                if (isVisible(e, key)) {
                    lchilds.add(e.getOpposite(v));
                }
            }
        }
       
        // the parents
        for (Object o: inE) {
            et = null;
            hide = null;
            if (o instanceof Edge) {
                e = (Edge)o;
                if (isVisible(e, key)) {
                    lparents.add(e.getOpposite(v));
                }
            }
        }
       
        e = null;
        for (Vertex p: lparents) {
            for (Vertex c: lchilds) {
                // as we are hiding the vertex, the new edges are not real for
                // these childs so the new edge is a false or fictitious edge
                if (!p.equals(c)) {
                    if ((e = p.findEdge(c)) == null) {
                        try {
                            e = addFalseEdge(p, c);
                        } catch (GraphException ge) {}
                    }
                    if (e != null)
                        e.setUserDatum(userdatumkey+key, new Boolean(hidden), UserData.CLONE);
                }
            }
        }
        v.setUserDatum(userdatumkey+key, new Boolean(hidden), UserData.CLONE);
        if (vv != null)
            vv.repaint();
        if (vvSatellite != null)
            vvSatellite.repaint();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.