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

LineHitsSource
1 /*
2  * Copyright (c) 2005, the JUNG Project and the Regents of the University
3  * of California
4  * All rights reserved.
5  *
6  * This software is open-source under the BSD license; see either
7  * "license.txt" or
8  * http://jung.sourceforge.net/license.txt for a description.
9  * Created on Mar 8, 2005
10  *
11  */
12 package edu.uci.ics.jung.visualization.control;
13  
14 import java.awt.event.InputEvent;
15 import java.awt.event.MouseEvent;
16 import java.awt.event.MouseListener;
17 import java.awt.event.MouseMotionListener;
18 import java.awt.geom.Point2D;
19  
20 import edu.uci.ics.jung.visualization.Layout;
21 import edu.uci.ics.jung.visualization.VisualizationViewer;
22  
23 /**
24  * A version of the AnimatedPickingGraphMousePlugin that is for
25  * the SatelliteVisualizationViewer. The difference it that when
26  * you pick a Vertex in the Satellite View, the 'master view' is
27  * translated to move that Vertex to the center.
28  * @see AnimatedPickingGraphMousePlugin
29  * @author Tom Nelson
30  */
31 public class SatelliteAnimatedPickingGraphMousePlugin extends AnimatedPickingGraphMousePlugin
32     implements MouseListener, MouseMotionListener {
33  
34     /**
35      * create an instance
36      *
37      */
38     public SatelliteAnimatedPickingGraphMousePlugin() {
390        this(InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK);
400    }
41  
42     public SatelliteAnimatedPickingGraphMousePlugin(int selectionModifiers) {
430        super(selectionModifiers);
440    }
45  
46     /**
47      * override subclass method to translate the master view instead
48      * of this satellite view
49      *
50      */
51     public void mouseReleased(MouseEvent e) {
520            if (e.getModifiers() == modifiers) {
530            final VisualizationViewer vv = (VisualizationViewer) e.getSource();
540            if (vv instanceof SatelliteVisualizationViewer) {
550                final VisualizationViewer vvMaster =
56                     ((SatelliteVisualizationViewer) vv).getMaster();
57  
580                if (vertex != null) {
590                    Layout layout = vvMaster.getGraphLayout();
600                    Point2D q = layout.getLocation(vertex);
610                    Point2D lvc =
62                         vvMaster.inverseLayoutTransform(vvMaster.getCenter());
630                    final double dx = (lvc.getX() - q.getX()) / 10;
640                    final double dy = (lvc.getY() - q.getY()) / 10;
65  
660                    Runnable animator = new Runnable() {
67  
68                         public void run() {
69                             for (int i = 0; i < 10; i++) {
70                                 vvMaster.getLayoutTransformer().translate(dx,
71                                         dy);
72                                 try {
73                                     Thread.sleep(100);
74                                 } catch (InterruptedException ex) {
75                                 }
76                             }
77                         }
78                     };
790                    Thread thread = new Thread(animator);
800                    thread.start();
81                 }
82             }
83         }
840    }
85 }

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.