Coverage details for edu.uci.ics.jung.visualization.RadiusPickSupport

LineHitsSource
1 /*
2  * Copyright (c) 2003, 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  */
10 /*
11  * Created on Mar 19, 2005
12  *
13  */
14 package edu.uci.ics.jung.visualization;
15  
16 import edu.uci.ics.jung.graph.Edge;
17 import edu.uci.ics.jung.graph.Vertex;
18  
19  
20 /**
21  * Simple implementation of PickSupport that returns the vertex or edge
22  * that is closest to the specified location. This implementation
23  * provides the same picking options that were available in
24  * previous versions of AbstractLayout.
25  *
26  * @author Tom Nelson
27  * @author Joshua O'Madadhain
28  */
29 public class RadiusPickSupport extends RadiusGraphElementAccessor implements PickSupport {
30     
31     protected HasGraphLayout hasGraphLayout;
32     
33     public RadiusPickSupport(HasGraphLayout hasGraphLayout, double maxDistance) {
340        this(maxDistance);
350        this.hasGraphLayout = hasGraphLayout;
360    }
37     
38     public RadiusPickSupport() {
390        this(Math.sqrt(Double.MAX_VALUE - 1000));
400    }
41     
42     /**
43      * the layout will always be provided by the VisualizationViewer
44      * this is supporting picking for
45      * @param maxDistance
46      */
47     public RadiusPickSupport(double maxDistance) {
480        super(null, maxDistance);
490    }
50     
51     /**
52      * called by VisualizationViewer when this PickSupport impl is
53      * added to VisualizationViewer. This allows the PickSupport to
54      * always get the current Layout from the VisualizationViewer it
55      * supports picking on.
56      */
57     public void setHasGraphLayout(HasGraphLayout hasGraphLayout) {
580        this.hasGraphLayout = hasGraphLayout;
590    }
60     
61     /**
62      * Gets the vertex nearest to the location of the (x,y) location selected,
63      * within a distance of <tt>maxDistance</tt>. Iterates through all
64      * visible vertices and checks their distance from the click. Override this
65      * method to provde a more efficient implementation.
66      */
67     public Vertex getVertex(double x, double y) {
680        return getVertex(x, y, this.maxDistance);
69     }
70  
71     /**
72      * Gets the vertex nearest to the location of the (x,y) location selected,
73      * within a distance of <tt>maxDistance</tt>. Iterates through all
74      * visible vertices and checks their distance from the click. Override this
75      * method to provde a more efficient implementation.
76      * @param x
77      * @param y
78      * @param maxDistance temporarily overrides member maxDistance
79      */
80     public Vertex getVertex(double x, double y, double maxDistance) {
81         // if vv is set, use it to get the most current layout
820        if(hasGraphLayout != null) {
830            layout = hasGraphLayout.getGraphLayout();
84         }
850        return super.getVertex(x, y, maxDistance);
86     }
87     
88     /**
89      * Gets the edge nearest to the location of the (x,y) location selected.
90      * Calls the longer form of the call.
91      */
92     public Edge getEdge(double x, double y) {
930        return getEdge(x, y, this.maxDistance);
94     }
95  
96     /**
97      * Gets the edge nearest to the location of the (x,y) location selected,
98      * within a distance of <tt>maxDistance</tt>, Iterates through all
99      * visible edges and checks their distance from the click. Override this
100      * method to provide a more efficient implementation.
101      *
102      * @param x
103      * @param y
104      * @param maxDistance temporarily overrides member maxDistance
105      * @return Edge closest to the click.
106      */
107     public Edge getEdge(double x, double y, double maxDistance) {
108         // if vv is set, use it to get the most current layout
1090        if(hasGraphLayout != null) {
1100            layout = hasGraphLayout.getGraphLayout();
111         }
1120        return super.getEdge(x, y, maxDistance);
113     }
114 }

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.