Class JungNetworkLayout<T>
- java.lang.Object
-
- repast.simphony.visualization.AbstractNetworkLayout<T>
-
- repast.simphony.visualization.visualization3D.layout.JungNetworkLayout<T>
-
- All Implemented Interfaces:
edu.uci.ics.jung.visualization.util.ChangeEventSupport
,Layout<T,Network<T>>
- Direct Known Subclasses:
FR3DLayout
public abstract class JungNetworkLayout<T> extends AbstractNetworkLayout<T> implements edu.uci.ics.jung.visualization.util.ChangeEventSupport
Abstract class to construct various types of JUNG graph layouts- Author:
- M. Altaweel
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ChangeListener>
changeListeners
protected edu.uci.ics.jung.visualization.util.ChangeEventSupport
changeSupport
protected Set
dontmove
a set of vertices that should not move in relation to the other verticesprotected Map<Object,Object>
objectData
protected JungVertexLocationFunction
vertex_locations
protected Set<Object>
visibleEdges
protected Network
visibleGraph
protected Set<Object>
visibleVertices
protected int
xSize
protected int
ySize
-
Fields inherited from class repast.simphony.visualization.AbstractNetworkLayout
baseGraph, layoutName, locationData
-
-
Constructor Summary
Constructors Constructor Description JungNetworkLayout()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addChangeListener(ChangeListener arg0)
Adds a change listener to listen for change events produced by network layout.protected Set<Object>
addEdgesOrVertices(Iterable it)
This gets the edges or vertices from the networkabstract void
advancePositions()
Implementors must override this method in order to create a Layout.void
applyFilter(Network n)
Applies the filter to the current network and network g.boolean
dontMove(Object o)
The set of nodes that have been locked.void
fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type.void
forceMove(Object 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
forceMove(Object picked, double x, double y, double z)
protected Object
getAVertex(RepastEdge e)
Utility method, gets a single vertex from this edgeObject
getBaseKey()
Returns a visualization-specific key, not currently usedChangeListener[]
getChangeListeners()
Returns an array of change listener objectsdouble[]
getCoordinates(Object o)
Returns the coordinates (float[2]) that stores the vertex' x and y location.Dimension
getCurrentSize()
Returns the current size of the visualization space, same as JUNG AbstractLayout.getCurrentSize()RepastEdge
getEdge(double x, double y)
Deprecated.RepastEdge
getEdge(double x, double y, double maxDistance)
Deprecated.Network
getGraph()
Accessor for the graph that represets all vertices.float[]
getLocation(Object obj)
Finds the location of the objectfloat[]
getLocation(Object obj, boolean threeD)
String
getName()
Gets the name of the layoutString
getStatus()
By default, an AbstractLayout returns null for its status.Object
getVertex(double x, double y)
Deprecated.Object
getVertex(double x, double y, double maxDistance)
Deprecated.Set
getVisibleEdges()
Gets edges that are equivalent to the ones passed in from the argument to applyFilter().protected Network
getVisibleGraph()
Accessor for the graph that represets all visible verticesSet
getVisibleVertices()
Gets vertices that are equivalent to the ones passed in from the argument to applyFilter().double
getX(Object o)
Returns the x coordinate of the vertex from the Coordinates object.int
getXSize()
double
getY(Object o)
Returns the y coordinate of the vertex from the Coordinates object.int
getYSize()
void
initialize(Dimension size)
void
initialize(Dimension size, JungVertexLocationFunction v_locations)
protected void
initialize_local()
Initializes all local information, and is called immediately within the initialize() process.protected abstract void
initialize_local_vertex(Object o)
Initializes the local information on a single vertex.protected void
initializeLocation(Object o, double[] coord, Dimension d)
Sets random locations for a vertex within the dimensions of the space.protected void
initializeLocations()
void
lockVertex(Object o)
Adds the vertex to the DontMove listprotected void
offsetVertex(Object o, double xOffset, double yOffset)
Offset the object based on the inputsprotected void
postInitialize()
may be overridden to do something after initializeLocations callvoid
removeChangeListener(ChangeListener arg0)
Removes a change listenervoid
resetVisibleEdgesAndVertices()
void
resize(Dimension size)
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.void
restart()
Set
returnEqualSet(Set<Object> thisVertices, Set<Object> thatVertices)
two vertices or edges to compare to see if they are equaldouble[]
returnMatchingCoordinate(Object o)
Returns a visualization-specific key that can be used to access UserData related to the AbstractLayout.void
setProjection(Network projection)
Sets the projection associated with this Layout.void
setXSize(int size)
void
setYSize(int size)
void
unlockVertex(Object o)
Removes the vertex from the DontMove listvoid
update()
set update by default to advance positions-
Methods inherited from class repast.simphony.visualization.AbstractNetworkLayout
getLayoutProperties, getLocationData, setLayoutProperties
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface repast.simphony.visualization.Layout
getBoundingBox
-
-
-
-
Field Detail
-
changeListeners
protected List<ChangeListener> changeListeners
-
changeSupport
protected edu.uci.ics.jung.visualization.util.ChangeEventSupport changeSupport
-
dontmove
protected Set dontmove
a set of vertices that should not move in relation to the other vertices
-
visibleGraph
protected Network visibleGraph
-
vertex_locations
protected JungVertexLocationFunction vertex_locations
-
xSize
protected int xSize
-
ySize
protected int ySize
-
-
Method Detail
-
dontMove
public boolean dontMove(Object o)
The set of nodes that have been locked. When running layout, it is important to checkif (dontmove( n )) { ... }
- Returns:
- whether this node may be legally moved or not
-
initialize
public void initialize(Dimension size)
-
initialize
public void initialize(Dimension size, JungVertexLocationFunction v_locations)
- Parameters:
size
- is a given dimensionv_locations
- is the calculated location for the node
-
initialize_local
protected void initialize_local()
Initializes all local information, and is called immediately within the initialize() process. The user is responsible for overriding this method to do any construction that may be necessary: for example, to initialize local per-edge or graph-wide data.
-
postInitialize
protected void postInitialize()
may be overridden to do something after initializeLocations call
-
initialize_local_vertex
protected abstract void initialize_local_vertex(Object o)
Initializes the local information on a single vertex. The user is responsible for overriding this method to do any vertex-level construction that may be necessary: for example, to attach vertex-level information to each vertex.
-
getBaseKey
public Object getBaseKey()
Returns a visualization-specific key, not currently used
-
initializeLocations
protected void initializeLocations()
-
returnMatchingCoordinate
public double[] returnMatchingCoordinate(Object o)
Returns a visualization-specific key that can be used to access UserData related to the AbstractLayout. Same as JUNG AbstractLayout.getBaseKey()
-
initializeLocation
protected void initializeLocation(Object o, double[] coord, Dimension d)
Sets random locations for a vertex within the dimensions of the space. If you want to initialize in some different way, override this method.- Parameters:
coord
-o
-d
-
-
getStatus
public String getStatus()
By default, an AbstractLayout returns null for its status.
-
update
public void update()
set update by default to advance positions
-
advancePositions
public abstract void advancePositions()
Implementors must override this method in order to create a Layout.
-
getVisibleGraph
protected Network getVisibleGraph()
Accessor for the graph that represets all visible vertices- Returns:
- the current visible graph (i.e. network).
- See Also:
getVisibleEdges()
,getVisibleVertices()
-
getCurrentSize
public Dimension getCurrentSize()
Returns the current size of the visualization space, same as JUNG AbstractLayout.getCurrentSize()- Returns:
- the current size of the screen
-
getAVertex
protected Object getAVertex(RepastEdge e)
Utility method, gets a single vertex from this edge- Parameters:
an
- edge object that you want a vertex from- Returns:
- a vertex object or null
-
getCoordinates
public double[] getCoordinates(Object o)
Returns the coordinates (float[2]) that stores the vertex' x and y location.- Parameters:
o
- = the object to get coordinates from- Returns:
- a coordinate float with x and y locations.
-
getX
public double getX(Object o)
Returns the x coordinate of the vertex from the Coordinates object.
-
getY
public double getY(Object o)
Returns the y coordinate of the vertex from the Coordinates object.
-
getLocation
public float[] getLocation(Object obj)
Finds the location of the object- Specified by:
getLocation
in interfaceLayout<T,Network<T>>
- Parameters:
obj
- you want to find location of- Returns:
- the float[] containing the location
-
getLocation
public float[] getLocation(Object obj, boolean threeD)
-
resize
public void resize(Dimension size)
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.- Parameters:
size
- represents the dimension that will set the current size
-
offsetVertex
protected void offsetVertex(Object o, double xOffset, double yOffset)
Offset the object based on the inputs- Parameters:
o
- object to offsetxOffset
-yOffset
-
-
restart
public void restart()
- See Also:
in JUNG
-
getVertex
public Object getVertex(double x, double y)
Deprecated.Calls get vertex to get object of nearest location to x and y- Parameters:
x
- and y represent location you want object to be near
-
getVertex
public Object getVertex(double x, double y, double maxDistance)
Deprecated.Gets the vertex nearest to the location of the (x,y) location selected, within a distance of maxDistance. Iterates through all visible vertices and checks their distance from the click. Override this method to provde a more efficient implementation.
-
getEdge
public RepastEdge getEdge(double x, double y)
Deprecated.Gets the edge nearest to the location of the (x,y) location selected. Calls the longer form of the call.
-
getEdge
public RepastEdge getEdge(double x, double y, double maxDistance)
Deprecated.Gets the edge nearest to the location of the (x,y) location selected, within a distance of maxDistance, Iterates through all visible edges and checks their distance from the click. Override this method to provide a more efficient implementation.- Parameters:
x
-y
-maxDistance
-- Returns:
- Edge closest to the click.
-
getGraph
public Network getGraph()
Accessor for the graph that represets all vertices. must match the nodes in the graph with the vertices created- Overrides:
getGraph
in classAbstractNetworkLayout<T>
- Returns:
- the graph that contains all vertices.
-
getVisibleEdges
public Set getVisibleEdges()
Gets edges that are equivalent to the ones passed in from the argument to applyFilter().- Returns:
- set of edges from the original
-
getVisibleVertices
public Set getVisibleVertices()
Gets vertices that are equivalent to the ones passed in from the argument to applyFilter().- Returns:
- set of vertices from the original
-
forceMove
public void forceMove(Object 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.
-
forceMove
public void forceMove(Object picked, double x, double y, double z)
-
lockVertex
public void lockVertex(Object o)
Adds the vertex to the DontMove list
-
unlockVertex
public void unlockVertex(Object o)
Removes the vertex from the DontMove list
-
applyFilter
public void applyFilter(Network n)
Applies the filter to the current network and network g. Shared vertices and edges are set to the visible edges and vertices
-
addChangeListener
public void addChangeListener(ChangeListener arg0)
Adds a change listener to listen for change events produced by network layout.- Specified by:
addChangeListener
in interfaceedu.uci.ics.jung.visualization.util.ChangeEventSupport
- Parameters:
arg0
- the listener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener arg0)
Removes a change listener- Specified by:
removeChangeListener
in interfaceedu.uci.ics.jung.visualization.util.ChangeEventSupport
- Parameters:
arg0
- the listener to remove
-
getChangeListeners
public ChangeListener[] getChangeListeners()
Returns an array of change listener objects- Specified by:
getChangeListeners
in interfaceedu.uci.ics.jung.visualization.util.ChangeEventSupport
-
fireStateChanged
public void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The primary listeners will be views that need to be repainted because of changes in this model instance- Specified by:
fireStateChanged
in interfaceedu.uci.ics.jung.visualization.util.ChangeEventSupport
- See Also:
listener list
-
returnEqualSet
public Set returnEqualSet(Set<Object> thisVertices, Set<Object> thatVertices)
two vertices or edges to compare to see if they are equal- Parameters:
thisEdges
-thatEdges
-- Returns:
- the equal vertices between the two compared
-
addEdgesOrVertices
protected Set<Object> addEdgesOrVertices(Iterable it)
This gets the edges or vertices from the network- Parameters:
it
- represents the iterable object- Returns:
- the return set of the object used for edges or vertices
-
setProjection
public void setProjection(Network projection)
Description copied from interface:Layout
Sets the projection associated with this Layout.- Specified by:
setProjection
in interfaceLayout<T,Network<T>>
- Overrides:
setProjection
in classAbstractNetworkLayout<T>
- Parameters:
projection
- the associated projection.
-
resetVisibleEdgesAndVertices
public void resetVisibleEdgesAndVertices()
-
getXSize
public int getXSize()
-
setXSize
public void setXSize(int size)
-
getYSize
public int getYSize()
-
setYSize
public void setYSize(int size)
-
-