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

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.Dimension;
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 ShearingGraphMousePlugin so that mouse events in the
22  * satellite view cause shearing of the main view
23  *
24  * @see ShearingGraphMousePlugin
25  * @author Tom Nelson - RABA Technologies
26  *
27  */
28 public class SatelliteShearingGraphMousePlugin extends ShearingGraphMousePlugin {
29  
30     public SatelliteShearingGraphMousePlugin() {
310        super();
320    }
33  
34     public SatelliteShearingGraphMousePlugin(int modifiers) {
350        super(modifiers);
360    }
37     
38     /**
39      * overridden to shear the main view
40      */
41     public void mouseDragged(MouseEvent e) {
420        if(down == null) return;
430        VisualizationViewer vv = (VisualizationViewer)e.getSource();
440        boolean accepted = checkModifiers(e);
450        if(accepted) {
460            if(vv instanceof SatelliteVisualizationViewer) {
470                VisualizationViewer vvMaster =
48                     ((SatelliteVisualizationViewer)vv).getMaster();
49                 
500                MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();
51  
520                vv.setCursor(cursor);
530                Point2D q = down;
540                Point2D p = e.getPoint();
550                float dx = (float) (p.getX()-q.getX());
560                float dy = (float) (p.getY()-q.getY());
57  
580                Dimension d = vv.getSize();
590                float shx = 2.f*dx/d.height;
600                float shy = 2.f*dy/d.width;
61                 // I want to compute shear based on the view coordinates of the
62                 // lens center in the satellite view.
63                 // translate the master view center to layout coords, then translate
64                 // that point to the satellite view's view coordinate system....
650                Point2D center = vv.transform(vvMaster.inverseTransform(vvMaster.getCenter()));
660                if(p.getX() < center.getX()) {
670                    shy = -shy;
68                 }
690                if(p.getY() < center.getY()) {
700                    shx = -shx;
71                 }
720                modelTransformerMaster.shear(-shx, -shy, vvMaster.getCenter());
73  
740                down.x = e.getX();
750                down.y = e.getY();
76             }
770            e.consume();
78         }
790    }
80 }

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.