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

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.Color;
14 import java.awt.Graphics;
15 import java.awt.Graphics2D;
16 import java.awt.geom.Ellipse2D;
17  
18 import edu.uci.ics.jung.visualization.VisualizationViewer;
19 import edu.uci.ics.jung.visualization.VisualizationViewer.Paintable;
20 import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
21 /**
22  * A class to make it easy to add an
23  * examining lens to a jung graph application. See HyperbolicTransformerDemo,
24  * ViewLensSupport and LayoutLensSupport
25  * for examples of how to use it.
26  *
27  * @author Tom Nelson - RABA Technologies
28  *
29  *
30  */
31 public abstract class AbstractLensSupport implements LensSupport {
32  
33     protected VisualizationViewer vv;
34     protected VisualizationViewer.GraphMouse graphMouse;
35     protected MutableTransformer savedViewTransformer;
36     protected LensTransformer lensTransformer;
37     protected ModalGraphMouse lensGraphMouse;
38     protected Lens lens;
39     protected LensControls lensControls;
40     protected String defaultToolTipText;
41  
42     protected static final String instructions =
43         "<html><center>Mouse-Drag the Lens center to move it<p>"+
44         "Mouse-Drag the Lens edge to resize it<p>"+
45         "Ctrl+MouseWheel to change magnification</center></html>";
46     
47     /**
48      * create the base class, setting common members and creating
49      * a custom GraphMouse
50      * @param vv the VisualizationViewer to work on
51      */
520    public AbstractLensSupport(VisualizationViewer vv, ModalGraphMouse lensGraphMouse) {
530        this.vv = vv;
540        this.savedViewTransformer = vv.getViewTransformer();
550        this.graphMouse = vv.getGraphMouse();
560        this.defaultToolTipText = vv.getToolTipText();
57  
580        this.lensGraphMouse = lensGraphMouse;//new ModalLensGraphMouse();
590    }
60  
61     public void activate(boolean state) {
620        if(state) activate();
630        else deactivate();
640    }
65     
66     public LensTransformer getLensTransformer() {
670        return lensTransformer;
68     }
69  
70     /**
71      * @return Returns the hyperbolicGraphMouse.
72      */
73     public ModalGraphMouse getGraphMouse() {
740        return lensGraphMouse;
75     }
76  
77     /**
78      * the background for the hyperbolic projection
79      * @author Tom Nelson - RABA Technologies
80      *
81      *
82      */
83     public static class Lens implements Paintable {
84         LensTransformer lensTransformer;
85         Ellipse2D ellipse;
86         
87         public Lens(LensTransformer lensTransformer) {
88             this.lensTransformer = lensTransformer;
89             this.ellipse = lensTransformer.getEllipse();
90         }
91         
92         /**
93          * @return Returns the hyperbolicTransformer.
94          */
95  
96         public void paint(Graphics g) {
97             
98             Graphics2D g2d = (Graphics2D)g;
99             g.setColor(Color.decode("0xdddddd"));
100             g2d.fill(ellipse);
101         }
102  
103         public boolean useTransform() {
104             return false;
105         }
106     }
107     
108     /**
109      * the background for the hyperbolic projection
110      * @author Tom Nelson - RABA Technologies
111      *
112      *
113      */
114     public static class LensControls implements Paintable {
115         LensTransformer lensTransformer;
116         Ellipse2D ellipse;
117         
118         public LensControls(LensTransformer lensTransformer) {
119             this.lensTransformer = lensTransformer;
120             this.ellipse = lensTransformer.getEllipse();
121         }
122         
123         /**
124          * @return Returns the hyperbolicTransformer.
125          */
126  
127         public void paint(Graphics g) {
128             
129             Graphics2D g2d = (Graphics2D)g;
130             g.setColor(Color.gray);
131             g2d.draw(ellipse);
132             int centerX = (int)Math.round(ellipse.getCenterX());
133             int centerY = (int)Math.round(ellipse.getCenterY());
134             g.drawOval(centerX-10, centerY-10, 20, 20);
135         }
136  
137         public boolean useTransform() {
138             return false;
139         }
140     }
141  
142 }

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.