View Javadoc
1   /*
2   * Copyright (c) 2003, The JUNG Authors 
3   *
4   * All rights reserved.
5   *
6   * This software is open-source under the BSD license; see either
7   * "license.txt" or
8   * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
9   */
10  package edu.uci.ics.jung.algorithms.layout;
11  
12  import java.awt.Dimension;
13  import java.awt.geom.Point2D;
14  
15  import com.google.common.base.Function;
16  
17  import edu.uci.ics.jung.graph.Graph;
18  
19  /**
20   * A generalized interface is a mechanism for returning (x,y) coordinates 
21   * from vertices. In general, most of these methods are used to both control and
22   * get information from the layout algorithm.
23   * <p>
24   * @author danyelf
25   * @author tom nelson
26   */
27  public interface Layout<V, E> extends Function<V,Point2D> {
28      
29  	/**
30  	 * Initializes fields in the node that may not have
31  	 * been set during the constructor. Must be called before
32  	 * the iterations begin.
33  	 */
34  	void initialize();
35  	
36  	/**
37  	 * @param initializer a function that specifies initial locations for all vertices
38  	 */
39  	void setInitializer(Function<V,Point2D> initializer);
40      
41  	/**
42  	 * @param graph the graph that this algorithm is to operate on
43  	 */
44      void setGraph(Graph<V,E> graph);
45  
46  	/**
47  	 * @return the graph that this Layout refers to
48  	 */
49  	Graph<V,E> getGraph();
50  	
51  	void reset();
52  	
53  	/**
54  	 * @param d the space to use to lay out this graph
55  	 */
56  	void setSize(Dimension d);
57  	
58  	/**
59  	 * @return the current size of the visualization's space
60  	 */
61  	Dimension getSize();
62  
63  
64  	/**
65  	 * Locks or unlocks the specified vertex.  Locking the vertex fixes it at its current position,
66  	 * so that it will not be affected by the layout algorithm.  Unlocking it allows the layout
67  	 * algorithm to change the vertex's position.
68       * 
69  	 * @param v	the vertex to lock/unlock
70  	 * @param state {@code true} to lock the vertex, {@code false} to unlock it
71  	 */
72  	void lock(V v, boolean state);
73  
74      /**
75       * @param v the vertex whose locked state is being queried
76       * @return <code>true</code> if the position of vertex <code>v</code> is locked
77       */
78      boolean isLocked(V v);
79  
80      /**
81       * Changes the layout coordinates of {@code v} to {@code location}.
82       * @param v the vertex whose location is to be specified
83       * @param location the coordinates of the specified location
84       */
85  	void setLocation(V v, Point2D location);
86  	
87  }