1 /*
2 * Copyright (c) 2005, The JUNG Authors
3 * All rights reserved.
4 *
5 * This software is open-source under the BSD license; see either "license.txt"
6 * or https://github.com/jrtom/jung/blob/master/LICENSE for a description.
7 *
8 *
9 * Created on Apr 12, 2005
10 */
11 package edu.uci.ics.jung.algorithms.layout;
12
13 import java.awt.Shape;
14 import java.util.Collection;
15
16 /**
17 * Interface for coordinate-based selection of graph components.
18 * @author Tom Nelson
19 * @author Joshua O'Madadhain
20 */
21 public interface GraphElementAccessor<V, E>
22 {
23 /**
24 * Returns the vertex, if any, associated with (x, y).
25 *
26 * @param layout the layout instance that records the positions for all vertices
27 * @param x the x coordinate of the pick point
28 * @param y the y coordinate of the pick point
29 * @return the vertex associated with (x, y)
30 */
31 V getVertex(Layout<V,E> layout, double x, double y);
32
33 /**
34 * @param layout the layout instance that records the positions for all vertices
35 * @param rectangle the region in which the returned vertices are located
36 * @return the vertices whose locations given by {@code layout}
37 * are contained within {@code rectangle}
38 */
39 Collection<V> getVertices(Layout<V,E> layout, Shape rectangle);
40
41 /**
42 * @param layout the context in which the location is defined
43 * @param x the x coordinate of the location
44 * @param y the y coordinate of the location
45 * @return an edge which is associated with the location {@code (x,y)}
46 * as given by {@code layout}, generally by reference to the edge's endpoints
47 */
48 E getEdge(Layout<V,E> layout, double x, double y);
49 }