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:
com.google.common.base.Function<V,java.awt.geom.Point2D>
,Layout<V,E>
,java.util.function.Function<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.- Author:
- Danyel Fisher, Scott White, Tom Nelson - converted to jung2
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLayout(Graph<V,E> graph)
Creates an instance forgraph
which does not initialize the vertex locations.protected
AbstractLayout(Graph<V,E> graph, com.google.common.base.Function<V,java.awt.geom.Point2D> initializer)
Creates an instance forgraph
which initializes the vertex locations usinginitializer
.protected
AbstractLayout(Graph<V,E> graph, com.google.common.base.Function<V,java.awt.geom.Point2D> initializer, java.awt.Dimension size)
Creates an instance forgraph
which initializes the vertex locations usinginitializer
and sets the size of the layout tosize
.protected
AbstractLayout(Graph<V,E> graph, java.awt.Dimension size)
Creates an instance forgraph
which sets the size of the layout tosize
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Point2D
apply(V v)
Graph<V,E>
getGraph()
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)
void
lock(boolean lock)
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(Graph<V,E> graph)
void
setInitializer(com.google.common.base.Function<V,java.awt.geom.Point2D> initializer)
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 specified location.void
setLocation(V picked, java.awt.geom.Point2D p)
Changes the layout coordinates ofv
tolocation
.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.-
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(Graph<V,E> graph)
Creates an instance forgraph
which does not initialize the vertex locations.- Parameters:
graph
- the graph on which the layout algorithm is to operate
-
AbstractLayout
protected AbstractLayout(Graph<V,E> graph, com.google.common.base.Function<V,java.awt.geom.Point2D> initializer)
Creates an instance forgraph
which initializes the vertex locations usinginitializer
.- Parameters:
graph
- the graph on which the layout algorithm is to operateinitializer
- specifies the starting positions of the vertices
-
AbstractLayout
protected AbstractLayout(Graph<V,E> graph, java.awt.Dimension size)
Creates an instance forgraph
which sets the size of the layout tosize
.- Parameters:
graph
- the graph on which the layout algorithm is to operatesize
- the dimensions of the region in which the layout algorithm will place vertices
-
AbstractLayout
protected AbstractLayout(Graph<V,E> graph, com.google.common.base.Function<V,java.awt.geom.Point2D> initializer, java.awt.Dimension size)
Creates an instance forgraph
which initializes the vertex locations usinginitializer
and sets the size of the layout tosize
.- Parameters:
graph
- the graph on which the layout algorithm is to operateinitializer
- specifies the starting positions of the verticessize
- the dimensions of the region in which the layout algorithm will place vertices
-
-
Method Detail
-
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)
-
setInitializer
public void setInitializer(com.google.common.base.Function<V,java.awt.geom.Point2D> initializer)
- Specified by:
setInitializer
in interfaceLayout<V,E>
- Parameters:
initializer
- a function that specifies initial locations for all vertices
-
getSize
public java.awt.Dimension getSize()
Returns the current size of the visualization space, accoring to the last call to resize().
-
apply
public java.awt.geom.Point2D apply(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).- Parameters:
v
- the vertex whose x coordinate is to be returned- Returns:
- the x coordinate of
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).- Parameters:
v
- the vertex whose y coordinate is to be returned- Returns:
- the y coordinate of
v
-
offsetVertex
protected void offsetVertex(V v, double xOffset, double yOffset)
- Parameters:
v
- the vertex whose coordinates are to be offsetxOffset
- the change to apply to this vertex's x coordinateyOffset
- the change to apply to this vertex's y coordinate
-
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 specified 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.- Parameters:
picked
- the vertex whose location is being setx
- the x coordinate of the location to sety
- the y coordinate of the location to set
-
setLocation
public void setLocation(V picked, java.awt.geom.Point2D p)
Description copied from interface:Layout
Changes the layout coordinates ofv
tolocation
.- Specified by:
setLocation
in interfaceLayout<V,E>
- Parameters:
picked
- the vertex whose location is to be specifiedp
- the coordinates of the specified location
-
lock
public void lock(V v, boolean state)
Locksv
in place ifstate
istrue
, otherwise unlocks it.
-
lock
public void lock(boolean lock)
- Parameters:
lock
-true
to lock all vertices in place,false
to unlock all vertices
-
-