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

Line | Hits | Source
--- | --- | ---
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() {`
29 | 0 | `super();`
30 | 0 | `}`
31 |  | ``
32 |  | `public SatelliteRotatingGraphMousePlugin(int modifiers) {`
33 | 0 | `super(modifiers);`
34 | 0 | `}`
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) {`
40 | 0 | `if(down == null) return;`
41 | 0 | `VisualizationViewer vv = (VisualizationViewer)e.getSource();`
42 | 0 | `boolean accepted = checkModifiers(e);`
43 | 0 | `if(accepted) {`
44 | 0 | `if(vv instanceof SatelliteVisualizationViewer) {`
45 | 0 | `VisualizationViewer vvMaster =`
46 |  | `((SatelliteVisualizationViewer)vv).getMaster();`
47 |  | ``
48 | 0 | `MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();`
49 |  | ``
50 |  | `// rotate`
51 | 0 | `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....`
56 | 0 | `Point2D center = vv.transform(vvMaster.inverseTransform(vvMaster.getCenter()));`
57 | 0 | `Point2D q = down;`
58 | 0 | `Point2D p = e.getPoint();`
59 | 0 | `Point2D v1 = new Point2D.Double(center.getX()-p.getX(), center.getY()-p.getY());`
60 | 0 | `Point2D v2 = new Point2D.Double(center.getX()-q.getX(), center.getY()-q.getY());`
61 | 0 | `double theta = angleBetween(v1, v2);`
62 | 0 | `modelTransformerMaster.rotate(-theta,`
63 |  | `vvMaster.inverseViewTransform(vvMaster.getCenter()));`
64 | 0 | `down.x = e.getX();`
65 | 0 | `down.y = e.getY();`
66 |  | `}`
67 | 0 | `e.consume();`
68 |  | `}`
69 | 0 | `}`
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.