V
- the vertex typeE
- the edge typepublic abstract class AbstractLayout<V,E> extends Object implements Layout<V,E>
Layout
. It handles some of the
basic functions: storing coordinates, maintaining the dimensions, initializing
the locations, maintaining locked vertices.Modifier and Type | Field and Description |
---|---|
protected Graph<V,E> |
graph |
protected boolean |
initialized |
protected com.google.common.cache.LoadingCache<V,Point2D> |
locations |
protected Dimension |
size |
Modifier | Constructor and Description |
---|---|
protected |
AbstractLayout(Graph<V,E> graph)
Creates an instance for
graph which does not initialize the vertex locations. |
protected |
AbstractLayout(Graph<V,E> graph,
Dimension size)
Creates an instance for
graph which sets the size of the layout to size . |
protected |
AbstractLayout(Graph<V,E> graph,
com.google.common.base.Function<V,Point2D> initializer)
Creates an instance for
graph which initializes the vertex locations
using initializer . |
protected |
AbstractLayout(Graph<V,E> graph,
com.google.common.base.Function<V,Point2D> initializer,
Dimension size)
Creates an instance for
graph which initializes the vertex locations
using initializer and sets the size of the layout to size . |
Modifier and Type | Method and Description |
---|---|
Point2D |
apply(V v) |
Graph<V,E> |
getGraph() |
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)
Locks
v in place if state is true , 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,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,
Point2D p)
Changes the layout coordinates of
v to location . |
void |
setSize(Dimension size)
When a visualization is resized, it presumably wants to fix the
locations of the vertices and possibly to reinitialize its data.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initialize, reset
protected Dimension size
protected boolean initialized
protected AbstractLayout(Graph<V,E> graph)
graph
which does not initialize the vertex locations.graph
- the graph on which the layout algorithm is to operateprotected AbstractLayout(Graph<V,E> graph, com.google.common.base.Function<V,Point2D> initializer)
graph
which initializes the vertex locations
using initializer
.graph
- the graph on which the layout algorithm is to operateinitializer
- specifies the starting positions of the verticesprotected AbstractLayout(Graph<V,E> graph, Dimension size)
graph
which sets the size of the layout to size
.graph
- the graph on which the layout algorithm is to operatesize
- the dimensions of the region in which the layout algorithm will place verticesprotected AbstractLayout(Graph<V,E> graph, com.google.common.base.Function<V,Point2D> initializer, Dimension size)
graph
which initializes the vertex locations
using initializer
and sets the size of the layout to size
.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 verticespublic void setSize(Dimension size)
public boolean isLocked(V v)
public void setInitializer(com.google.common.base.Function<V,Point2D> initializer)
setInitializer
in interface Layout<V,E>
initializer
- a function that specifies initial locations for all verticespublic Dimension getSize()
public double getX(V v)
v
- the vertex whose x coordinate is to be returnedv
public double getY(V v)
v
- the vertex whose y coordinate is to be returnedv
protected void offsetVertex(V v, double xOffset, double yOffset)
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 coordinatepublic void setLocation(V picked, double x, double y)
picked
- the vertex whose location is being setx
- the x coordinate of the location to sety
- the y coordinate of the location to setpublic void setLocation(V picked, Point2D p)
Layout
v
to location
.setLocation
in interface Layout<V,E>
picked
- the vertex whose location is to be specifiedp
- the coordinates of the specified locationpublic void lock(V v, boolean state)
v
in place if state
is true
, otherwise unlocks it.public void lock(boolean lock)
lock
- true
to lock all vertices in place, false
to unlock all verticesCopyright © 2015. All rights reserved.