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

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.Cursor;`
14 |  | `import java.awt.event.MouseEvent;`
15 |  | `import java.awt.geom.Point2D;`
16 |  | ``
17 |  | `import edu.uci.ics.jung.visualization.VisualizationViewer;`
18 |  | `import edu.uci.ics.jung.visualization.transform.MutableTransformer;`
19 |  | ``
20 |  | `/**`
21 |  | `* Overrides TranslatingGraphMousePlugin so that mouse events in`
22 |  | `* the satellite view cause translating of the main view`
23 |  | `*`
24 |  | `* @see TranslatingGraphMousePlugin`
25 |  | `* @author Tom Nelson - RABA Technologies`
26 |  | `*`
27 |  | `*/`
28 |  | `public class SatelliteTranslatingGraphMousePlugin extends`
29 |  | `TranslatingGraphMousePlugin {`
30 |  | ``
31 |  | `public SatelliteTranslatingGraphMousePlugin() {`
32 | 0 | `super();`
33 | 0 | `}`
34 |  | ``
35 |  | `public SatelliteTranslatingGraphMousePlugin(int modifiers) {`
36 | 0 | `super(modifiers);`
37 | 0 | `}`
38 |  | ``
39 |  | `/**`
40 |  | `* chack the modifiers. If accepted, translate the main view according`
41 |  | `* to the dragging of the mouse pointer in the satellite view`
42 |  | `* @param e the event`
43 |  | `*/`
44 |  | `public void mouseDragged(MouseEvent e) {`
45 | 0 | `VisualizationViewer vv = (VisualizationViewer)e.getSource();`
46 | 0 | `boolean accepted = checkModifiers(e);`
47 | 0 | `if(accepted) {`
48 | 0 | `if(vv instanceof SatelliteVisualizationViewer) {`
49 | 0 | `VisualizationViewer vvMaster =`
50 |  | `((SatelliteVisualizationViewer)vv).getMaster();`
51 |  | ``
52 | 0 | `MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();`
53 | 0 | `vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));`
54 |  | `try {`
55 | 0 | `Point2D q = vv.inverseTransform(down);`
56 | 0 | `Point2D p = vv.inverseTransform(e.getPoint());`
57 | 0 | `float dx = (float) (p.getX()-q.getX());`
58 | 0 | `float dy = (float) (p.getY()-q.getY());`
59 |  | ``
60 | 0 | `modelTransformerMaster.translate(-dx, -dy);`
61 | 0 | `down.x = e.getX();`
62 | 0 | `down.y = e.getY();`
63 | 0 | `} catch(RuntimeException ex) {`
64 | 0 | `System.err.println("down = "+down+", e = "+e);`
65 | 0 | `throw ex;`
66 | 0 | `}`
67 |  | `}`
68 | 0 | `e.consume();`
69 |  | `}`
70 | 0 | `}`
71 |  | ``
72 |  | ``
73 |  | `}`

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.