Class AbstractLayout<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
-
- Type Parameters:
V
- the vertex typeE
- the edge type
- All Implemented Interfaces:
Layout<V,E>
,org.apache.commons.collections4.Transformer<V,java.awt.geom.Point2D>
- Direct Known Subclasses:
CircleLayout
,FRLayout
,FRLayout2
,ISOMLayout
,KKLayout
,SpringLayout
,StaticLayout
public abstract class AbstractLayout<V,E> extends java.lang.Object implements Layout<V,E>
Abstract class for implementations ofLayout
. It handles some of the basic functions: storing coordinates, maintaining the dimensions, initializing the locations, maintaining locked vertices.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph)
Creates an instance which does not initialize the vertex locations.protected
AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph, java.awt.Dimension size)
protected
AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph, org.apache.commons.collections4.Transformer initializer)
protected
AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph, org.apache.commons.collections4.Transformer initializer, java.awt.Dimension size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description edu.uci.ics.jung.graph.Graph<V,E>
getGraph()
Accessor for the graph that represets all vertices.java.awt.Dimension
getSize()
Returns the current size of the visualization space, accoring to the last call to resize().double
getX(V v)
Returns the x coordinate of the vertex from the Coordinates object.double
getY(V v)
Returns the y coordinate of the vertex from the Coordinates object.boolean
isLocked(V v)
Returnstrue
if the position of vertexv
is locked.void
lock(boolean lock)
Locks all vertices in place iflock
istrue
, otherwise unlocks all vertices.void
lock(V v, boolean state)
Locksv
in place ifstate
istrue
, otherwise unlocks it.protected void
offsetVertex(V v, double xOffset, double yOffset)
void
setGraph(edu.uci.ics.jung.graph.Graph<V,E> graph)
setter for graphvoid
setInitializer(org.apache.commons.collections4.Transformer initializer)
provides initial locations for all vertices.void
setLocation(V picked, double x, double y)
Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location.void
setLocation(V picked, java.awt.geom.Point2D p)
set the location of a vertexvoid
setSize(java.awt.Dimension size)
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.java.awt.geom.Point2D
transform(V v)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.uci.ics.jung.algorithms.layout.Layout
initialize, reset
-
-
-
-
Constructor Detail
-
AbstractLayout
protected AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph)
Creates an instance which does not initialize the vertex locations.- Parameters:
graph
- the graph for which the layout algorithm is to be created.
-
AbstractLayout
protected AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph, org.apache.commons.collections4.Transformer initializer)
-
AbstractLayout
protected AbstractLayout(edu.uci.ics.jung.graph.Graph<V,E> graph, java.awt.Dimension size)
-
-
Method Detail
-
setGraph
public void setGraph(edu.uci.ics.jung.graph.Graph<V,E> graph)
Description copied from interface:Layout
setter for graph
-
setSize
public void setSize(java.awt.Dimension size)
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local.
-
isLocked
public boolean isLocked(V v)
Description copied from interface:Layout
Returnstrue
if the position of vertexv
is locked.
-
setInitializer
public void setInitializer(org.apache.commons.collections4.Transformer initializer)
Description copied from interface:Layout
provides initial locations for all vertices.- Specified by:
setInitializer
in interfaceLayout<V,E>
-
getSize
public java.awt.Dimension getSize()
Returns the current size of the visualization space, accoring to the last call to resize().
-
transform
public java.awt.geom.Point2D transform(V v)
-
getX
public double getX(V v)
Returns the x coordinate of the vertex from the Coordinates object. in most cases you will be better off calling transform(v).
-
getY
public double getY(V v)
Returns the y coordinate of the vertex from the Coordinates object. In most cases you will be better off calling transform(v).
-
offsetVertex
protected void offsetVertex(V v, double xOffset, double yOffset)
- Parameters:
v
-xOffset
-yOffset
-
-
getGraph
public edu.uci.ics.jung.graph.Graph<V,E> getGraph()
Accessor for the graph that represets all vertices.
-
setLocation
public void setLocation(V picked, double x, double y)
Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location. Does not add the vertex to the "dontmove" list, and (in the default implementation) does not make any adjustments to the rest of the graph.
-
setLocation
public void setLocation(V picked, java.awt.geom.Point2D p)
Description copied from interface:Layout
set the location of a vertex- Specified by:
setLocation
in interfaceLayout<V,E>
-
lock
public void lock(V v, boolean state)
Locksv
in place ifstate
istrue
, otherwise unlocks it.
-
lock
public void lock(boolean lock)
Locks all vertices in place iflock
istrue
, otherwise unlocks all vertices.
-
-