Examples of VisualizationViewer


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

    public static void main(String[] args) throws IOException
    {
        JFrame jf = new JFrame();
        Graph g = getGraph();
        VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
        jf.getContentPane().add(vv);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.pack();
        jf.setVisible(true);
    }
View Full Code Here

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

        layout = new FRLayout(graph);

        Dimension preferredSize = new Dimension(400,400);
        final VisualizationModel visualizationModel =
            new DefaultVisualizationModel(layout, preferredSize);
        vv =  new VisualizationViewer(visualizationModel, preferredSize);
       
        vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
       
        final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
        final Set exclusions = new HashSet();
View Full Code Here

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

   */
    public void mouseWheelMoved(MouseWheelEvent e) {
        boolean accepted = checkModifiers(e);
        float delta = this.delta;
        if(accepted == true) {
            VisualizationViewer vv = (VisualizationViewer)e.getSource();
            MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
            int amount = e.getWheelRotation();
            if(amount < 0) {
                delta = -delta;
            }
            changeMagnification(modelTransformer, delta);
            changeMagnification(viewTransformer, delta);
            vv.repaint();
            e.consume();
        }
    }
View Full Code Here

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

     * save the 'down' point and check the modifiers. If the
     * modifiers are accepted, set the cursor to the 'hand' cursor
   * @param e the event
   */
    public void mousePressed(MouseEvent e) {
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
           boolean accepted = checkModifiers(e);
           down = e.getPoint();
          if(accepted) {
               vv.setCursor(cursor);
           }
    }
View Full Code Here

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

   
  /**
     * unset the down point and change the cursor back to the default
   */
    public void mouseReleased(MouseEvent e) {
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        down = null;
        vv.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
View Full Code Here

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

     * check the modifiers. If accepted, use the mouse drag motion
     * to rotate the graph
   */
    public void mouseDragged(MouseEvent e) {
        if(down == null) return;
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        boolean accepted = checkModifiers(e);
        if(accepted) {
            MutableTransformer modelTransformer =
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            // rotate
            vv.setCursor(cursor);
           
            Point2D center = vv.getCenter();
            Point2D q = down;
            Point2D p = e.getPoint();
            Point2D v1 = new Point2D.Double(center.getX()-p.getX(), center.getY()-p.getY());
            Point2D v2 = new Point2D.Double(center.getX()-q.getX(), center.getY()-q.getY());
            double theta = angleBetween(v1, v2);
            modelTransformer.rotate(theta, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, center));
            down.x = e.getX();
            down.y = e.getY();
       
            e.consume();
        }
View Full Code Here

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

        layout = new FRLayout(graph);

        Dimension preferredSize = new Dimension(400,400);
        final VisualizationModel visualizationModel =
            new DefaultVisualizationModel(layout, preferredSize);
        vv =  new VisualizationViewer(visualizationModel, preferredSize);
       
        vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
       
        final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
        final Set exclusions = new HashSet();
View Full Code Here

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

     * mouse wheel motion.
     */
    public void mouseWheelMoved(MouseWheelEvent e) {
        boolean accepted = checkModifiers(e);
        if(accepted == true) {
            VisualizationViewer vv = (VisualizationViewer)e.getSource();

            if(vv instanceof SatelliteVisualizationViewer) {
                VisualizationViewer vvMaster =
                    ((SatelliteVisualizationViewer)vv).getMaster();

                int amount = e.getWheelRotation();
               
                if(amount > 0) {
                    scaler.scale(vvMaster, in, vvMaster.getCenter());

                } else if(amount < 0) {
                    scaler.scale(vvMaster, out, vvMaster.getCenter());
                }
                e.consume();
                vv.repaint();
            }
        }
View Full Code Here

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

     * chack the modifiers. If accepted, translate the main view according
     * to the dragging of the mouse pointer in the satellite view
     * @param e the event
     */
    public void mouseDragged(MouseEvent e) {
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        boolean accepted = checkModifiers(e);
        if(accepted) {
            if(vv instanceof SatelliteVisualizationViewer) {
                VisualizationViewer vvMaster =
                    ((SatelliteVisualizationViewer)vv).getMaster();
               
                MutableTransformer modelTransformerMaster =
                  vvMaster.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
                vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                try {
                    Point2D q = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
                    Point2D p = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());
                    float dx = (float) (p.getX()-q.getX());
View Full Code Here

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

     * check the modifiers. If accepted, use the mouse drag motion
     * to rotate the graph in the master view
     */
    public void mouseDragged(MouseEvent e) {
        if(down == null) return;
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        boolean accepted = checkModifiers(e);
        if(accepted) {
            if(vv instanceof SatelliteVisualizationViewer) {
                VisualizationViewer vvMaster =
                    ((SatelliteVisualizationViewer)vv).getMaster();
               
                MutableTransformer modelTransformerMaster =
                  vvMaster.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);

                // rotate
                vv.setCursor(cursor);
                // I want to compute rotation based on the view coordinates of the
                // lens center in the satellite view.
                // translate the master view center to layout coords, then translate
                // that point to the satellite view's view coordinate system....
                Point2D center = vv.getRenderContext().getMultiLayerTransformer().transform(vvMaster.getRenderContext().getMultiLayerTransformer().inverseTransform(vvMaster.getCenter()));
                Point2D q = down;
                Point2D p = e.getPoint();
                Point2D v1 = new Point2D.Double(center.getX()-p.getX(), center.getY()-p.getY());
                Point2D v2 = new Point2D.Double(center.getX()-q.getX(), center.getY()-q.getY());
                double theta = angleBetween(v1, v2);
                modelTransformerMaster.rotate(-theta,
                        vvMaster.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, vvMaster.getCenter()));
                down.x = e.getX();
                down.y = e.getY();
            }
            e.consume();
        }
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.