Coverage details for edu.uci.ics.jung.visualization.transform.LayoutLensSupport

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 Jul 21, 2005
9  */
10  
11 package edu.uci.ics.jung.visualization.transform;
12  
13 import java.awt.Dimension;
14  
15 import edu.uci.ics.jung.visualization.VisualizationViewer;
16 import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
17 import edu.uci.ics.jung.visualization.control.ModalLensGraphMouse;
18 /**
19  * A class to make it easy to add an
20  * examining lens to a jung graph application. See HyperbolicTransformerDemo
21  * for an example of how to use it.
22  *
23  * @author Tom Nelson - RABA Technologies
24  *
25  *
26  */
27 public class LayoutLensSupport extends AbstractLensSupport
28     implements LensSupport {
29  
30     public LayoutLensSupport(VisualizationViewer vv) {
310        this(vv, new HyperbolicTransformer(vv, vv.getLayoutTransformer()),
32                 new ModalLensGraphMouse());
330    }
34     /**
35      * create the base class, setting common members and creating
36      * a custom GraphMouse
37      * @param vv the VisualizationViewer to work on
38      */
39     public LayoutLensSupport(VisualizationViewer vv, LensTransformer lensTransformer,
40             ModalGraphMouse lensGraphMouse) {
410        super(vv, lensGraphMouse);
420        this.lensTransformer = lensTransformer;
43  
440        Dimension d = vv.getSize();
450        if(d.width <= 0 || d.height <= 0) {
460            d = vv.getPreferredSize();
47         }
480        lensTransformer.setViewRadius(d.width/5);
490   }
50     
51     public void activate() {
520        if(lens == null) {
530            lens = new Lens(lensTransformer);
54         }
550        if(lensControls == null) {
560            lensControls = new LensControls(lensTransformer);
57         }
580        vv.setLayoutTransformer(lensTransformer);
590        vv.setViewTransformer(new MutableAffineTransformer());
600        vv.addPreRenderPaintable(lens);
610        vv.addPostRenderPaintable(lensControls);
620        vv.setGraphMouse(lensGraphMouse);
630        vv.setToolTipText(instructions);
640        vv.repaint();
650    }
66     
67     public void deactivate() {
680        if(savedViewTransformer != null) {
690            vv.setViewTransformer(savedViewTransformer);
70         }
710        if(lensTransformer != null) {
720            vv.removePreRenderPaintable(lens);
730            vv.removePostRenderPaintable(lensControls);
740            vv.setLayoutTransformer(lensTransformer.getDelegate());
75         }
760        vv.setToolTipText(defaultToolTipText);
770        vv.setGraphMouse(graphMouse);
780        vv.repaint();
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.