Coverage details for edu.uci.ics.jung.visualization.control.SatelliteRotatingGraphMousePlugin

LineHitsSource
1 /*
2  * Copyright (c) 2005, the JUNG Project and the Regents of the University of
3  * California All rights reserved.
4  *
5  * This software is open-source under the BSD license; see either "license.txt"
6  * or http://jung.sourceforge.net/license.txt for a description.
7  *
8  * Created on Aug 15, 2005
9  */
10  
11 package edu.uci.ics.jung.visualization.control;
12  
13 import java.awt.event.MouseEvent;
14 import java.awt.geom.Point2D;
15  
16 import edu.uci.ics.jung.visualization.VisualizationViewer;
17 import edu.uci.ics.jung.visualization.transform.MutableTransformer;
18  
19 /**
20  * Mouse events in the SatelliteView that match the modifiers
21  * will cause the Main view to rotate
22  * @see RotatingGraphMousePlugin
23  * @author Tom Nelson - RABA Technologies
24  *
25  */
26 public class SatelliteRotatingGraphMousePlugin extends RotatingGraphMousePlugin {
27  
28     public SatelliteRotatingGraphMousePlugin() {
290        super();
300    }
31  
32     public SatelliteRotatingGraphMousePlugin(int modifiers) {
330        super(modifiers);
340    }
35     /**
36      * check the modifiers. If accepted, use the mouse drag motion
37      * to rotate the graph in the master view
38      */
39     public void mouseDragged(MouseEvent e) {
400        if(down == null) return;
410        VisualizationViewer vv = (VisualizationViewer)e.getSource();
420        boolean accepted = checkModifiers(e);
430        if(accepted) {
440            if(vv instanceof SatelliteVisualizationViewer) {
450                VisualizationViewer vvMaster =
46                     ((SatelliteVisualizationViewer)vv).getMaster();
47                 
480                MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();
49  
50                 // rotate
510                vv.setCursor(cursor);
52                 // I want to compute rotation based on the view coordinates of the
53                 // lens center in the satellite view.
54                 // translate the master view center to layout coords, then translate
55                 // that point to the satellite view's view coordinate system....
560                Point2D center = vv.transform(vvMaster.inverseTransform(vvMaster.getCenter()));
570                Point2D q = down;
580                Point2D p = e.getPoint();
590                Point2D v1 = new Point2D.Double(center.getX()-p.getX(), center.getY()-p.getY());
600                Point2D v2 = new Point2D.Double(center.getX()-q.getX(), center.getY()-q.getY());
610                double theta = angleBetween(v1, v2);
620                modelTransformerMaster.rotate(-theta,
63                         vvMaster.inverseViewTransform(vvMaster.getCenter()));
640                down.x = e.getX();
650                down.y = e.getY();
66             }
670            e.consume();
68         }
690    }
70  
71 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.