| 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.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() { | |
| 31 | 0 | super(); |
| 32 | 0 | } |
| 33 | ||
| 34 | public SatelliteShearingGraphMousePlugin(int modifiers) { | |
| 35 | 0 | super(modifiers); |
| 36 | 0 | } |
| 37 | ||
| 38 | /** | |
| 39 | * overridden to shear the main view | |
| 40 | */ | |
| 41 | public void mouseDragged(MouseEvent e) { | |
| 42 | 0 | if(down == null) return; |
| 43 | 0 | VisualizationViewer vv = (VisualizationViewer)e.getSource(); |
| 44 | 0 | boolean accepted = checkModifiers(e); |
| 45 | 0 | if(accepted) { |
| 46 | 0 | if(vv instanceof SatelliteVisualizationViewer) { |
| 47 | 0 | VisualizationViewer vvMaster = |
| 48 | ((SatelliteVisualizationViewer)vv).getMaster(); | |
| 49 | ||
| 50 | 0 | MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer(); |
| 51 | ||
| 52 | 0 | vv.setCursor(cursor); |
| 53 | 0 | Point2D q = down; |
| 54 | 0 | Point2D p = e.getPoint(); |
| 55 | 0 | float dx = (float) (p.getX()-q.getX()); |
| 56 | 0 | float dy = (float) (p.getY()-q.getY()); |
| 57 | ||
| 58 | 0 | Dimension d = vv.getSize(); |
| 59 | 0 | float shx = 2.f*dx/d.height; |
| 60 | 0 | 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.... | |
| 65 | 0 | Point2D center = vv.transform(vvMaster.inverseTransform(vvMaster.getCenter())); |
| 66 | 0 | if(p.getX() < center.getX()) { |
| 67 | 0 | shy = -shy; |
| 68 | } | |
| 69 | 0 | if(p.getY() < center.getY()) { |
| 70 | 0 | shx = -shx; |
| 71 | } | |
| 72 | 0 | modelTransformerMaster.shear(-shx, -shy, vvMaster.getCenter()); |
| 73 | ||
| 74 | 0 | down.x = e.getX(); |
| 75 | 0 | down.y = e.getY(); |
| 76 | } | |
| 77 | 0 | e.consume(); |
| 78 | } | |
| 79 | 0 | } |
| 80 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |