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

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.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() {
320        super();
330    }
34  
35     public SatelliteTranslatingGraphMousePlugin(int modifiers) {
360        super(modifiers);
370    }
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) {
450        VisualizationViewer vv = (VisualizationViewer)e.getSource();
460        boolean accepted = checkModifiers(e);
470        if(accepted) {
480            if(vv instanceof SatelliteVisualizationViewer) {
490                VisualizationViewer vvMaster =
50                     ((SatelliteVisualizationViewer)vv).getMaster();
51                 
520                MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();
530                vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
54                 try {
550                    Point2D q = vv.inverseTransform(down);
560                    Point2D p = vv.inverseTransform(e.getPoint());
570                    float dx = (float) (p.getX()-q.getX());
580                    float dy = (float) (p.getY()-q.getY());
59                     
600                    modelTransformerMaster.translate(-dx, -dy);
610                    down.x = e.getX();
620                    down.y = e.getY();
630                } catch(RuntimeException ex) {
640                    System.err.println("down = "+down+", e = "+e);
650                    throw ex;
660                }
67             }
680            e.consume();
69         }
700    }
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.