Package ghidra.graph.viewer.layout
Class AbstractVisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- java.lang.Object
- 
- edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
- 
- ghidra.graph.viewer.layout.AbstractVisualGraphLayout<V,E>
 
 
- 
- Type Parameters:
- V- the vertex type
- E- the edge type
 - All Implemented Interfaces:
- com.google.common.base.Function<V,java.awt.geom.Point2D>,- edu.uci.ics.jung.algorithms.layout.Layout<V,E>,- VisualGraphLayout<V,E>
 
 public abstract class AbstractVisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>> extends edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E> implements VisualGraphLayout<V,E> A base layout that marries the Visual Graph and Jung layout interfaces. This class allows you to create new layouts while stubbing the Jung layout methods.This class essentially takes in client-produced grid row and column indices and produces layout locations for those values. This an implementation the Jung Layoutinterface that handles most of the layout implementation for you. Things to know:- You should call initialize() inside of your constructor
- You must implement performInitialGridLayout(VisualGraph)- this is where you align your vertices (and optionally edge articulations) on a grid. This grid will be translated into layout space points for you.
- If you wish to use articulation points in your edges, you must override
      usesEdgeArticulations()to return true.
 By default, this class will create x-position values that are aligned with the column's x-position. You can override getVertexLocation(VisualVertex, Column, Row, Rectangle)in order to center the vertex within its columngetCenteredVertexLocation(VisualVertex, Column, Row, Rectangle). Also note though that if your layout returns true forisCondensedLayout(), then the centering will be condensed and slightly off.- See Also:
- GridLocationMap,- LayoutPositions
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanlayoutInitializedprotected java.lang.StringlayoutNameprotected TaskMonitormonitor
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractVisualGraphLayout(edu.uci.ics.jung.graph.Graph<V,E> graph, java.lang.String layoutName)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddLayoutListener(LayoutListener<V,E> listener)Adds a layout listenerprotected voidapplyNewArticulations(java.util.Map<E,java.util.List<java.awt.geom.Point2D>> edgeArticulations)protected voidapplyNewLocations(java.util.Map<V,java.awt.geom.Point2D> newLocations)LayoutPositions<V,E>calculateLocations(VisualGraph<V,E> visualGraph, TaskMonitor taskMonitor)Signals to again layout the current graph.VisualGraphLayout<V,E>cloneLayout(VisualGraph<V,E> newGraph)Creates a new version of this layout using the given graph.protected voidcondenseEdges(java.util.List<Row<V>> rows, java.util.Map<E,java.util.List<java.awt.geom.Point2D>> newEdgeArticulations, double centerX, double centerY)protected voidcondenseVertices(java.util.List<Row<V>> rows, java.util.Map<V,java.awt.geom.Point2D> newLocations, VisualGraphVertexShapeTransformer<V> transformer, double centerX, double centerY)abstract AbstractVisualGraphLayout<V,E>createClonedLayout(VisualGraph<V,E> newGraph)This class has implementedcloneLayout(VisualGraph)in order to properly initialize location information in the layout so that subclasses do not have to.voiddispose()Cleanup any resource being managed by this layout.protected LayoutPositions<V,E>doCalculateLocations(VisualGraph<V,E> g, TaskMonitor taskMonitor)protected java.awt.geom.Point2DgetCenteredEdgeLocation(Column col, Row<V> row)protected java.awt.geom.Point2DgetCenteredVertexLocation(V v, Column col, Row<V> row, java.awt.Rectangle bounds)Returns a location for the given vertex that is centered within its cellprotected doublegetCondenseFactor()The amount (from 0 to 1.0) by which to condense the vertices of the graph when that feature is enabled.edu.uci.ics.jung.visualization.renderers.Renderer.EdgeLabel<V,E>getEdgeLabelRenderer()Returns an optional custom edge label renderer.protected java.awt.geom.Point2DgetEdgeLocation(Column col, Row<V> row)edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer<V,E>getEdgeRenderer()Returns an optional edge renderer.com.google.common.base.Function<E,java.awt.Shape>getEdgeShapeTransformer()Returns an optional edge shape transformer.java.lang.StringgetLayoutName()Returns the name of this layoutprotected java.awt.geom.Point2DgetVertexLocation(V v, Column col, Row<V> row, java.awt.Rectangle bounds)voidinitialize()protected voidinitializeClonedLayout(AbstractVisualGraphLayout<V,E> newLayout)Takes the given layout and copies the layout information this layout into that layoutprotected booleanisCondensedLayout()Returns true if this layout is in a condensed mode, which means to reduce space between vertices and edges.protected abstract GridLocationMap<V,E>performInitialGridLayout(VisualGraph<V,E> g)This is the method that is called to perform the actual layout.protected java.util.Map<E,java.util.List<java.awt.geom.Point2D>>positionEdgeArticulationsInLayoutSpace(VisualGraphVertexShapeTransformer<V> transformer, java.util.Map<V,java.awt.geom.Point2D> vertexLayoutLocations, java.util.Collection<E> edges, LayoutLocationMap<V,E> layoutLocations)protected LayoutPositions<V,E>positionInLayoutSpaceFromGrid(VisualGraph<V,E> visualGraph, GridLocationMap<V,E> gridLocations)voidremoveLayoutListener(LayoutListener<V,E> listener)Removes a layout listenervoidreset()voidsetLocation(V v, java.awt.geom.Point2D location)voidsetLocation(V v, java.awt.geom.Point2D location, LayoutListener.ChangeType changeType)Allows the client to change the location while specifying the type of changevoidsetTaskMonitor(TaskMonitor monitor)booleanusesEdgeArticulations()Returns true if this layout uses articulated edges.- 
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayoutapply, getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, setLocation, setSize
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface edu.uci.ics.jung.algorithms.layout.LayoutgetGraph, getSize, isLocked, lock, setGraph, setInitializer, setSize
 - 
Methods inherited from interface ghidra.graph.viewer.layout.VisualGraphLayoutgetVisualGraph
 
- 
 
- 
- 
- 
Field Detail- 
layoutNameprotected java.lang.String layoutName 
 - 
layoutInitializedprotected boolean layoutInitialized 
 - 
monitorprotected TaskMonitor monitor 
 
- 
 - 
Method Detail- 
getLayoutNamepublic java.lang.String getLayoutName() Returns the name of this layout- Returns:
- the name of this layout
 
 - 
performInitialGridLayoutprotected abstract GridLocationMap<V,E> performInitialGridLayout(VisualGraph<V,E> g) throws CancelledException This is the method that is called to perform the actual layout. While this method is running, themonitorvariable has been set so that you can callTaskMonitor.checkCanceled().- Parameters:
- g- the graph
- Returns:
- the new grid location
- Throws:
- CancelledException- if the operation was cancelled
 
 - 
setTaskMonitorpublic void setTaskMonitor(TaskMonitor monitor) 
 - 
getEdgeRendererpublic edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer<V,E> getEdgeRenderer() Description copied from interface:VisualGraphLayoutReturns an optional edge renderer. This is used to render each edge.- Specified by:
- getEdgeRendererin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Returns:
- an optional edge renderer
 
 - 
getEdgeShapeTransformerpublic com.google.common.base.Function<E,java.awt.Shape> getEdgeShapeTransformer() Description copied from interface:VisualGraphLayoutReturns an optional edge shape transformer. This is used to create shapes for each edge.- Specified by:
- getEdgeShapeTransformerin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Returns:
- an optional edge shape transformer
 
 - 
getEdgeLabelRendererpublic edu.uci.ics.jung.visualization.renderers.Renderer.EdgeLabel<V,E> getEdgeLabelRenderer() Description copied from interface:VisualGraphLayoutReturns an optional custom edge label renderer. This is used to add labels to the edges.- Specified by:
- getEdgeLabelRendererin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Returns:
- an optional renderer
 
 - 
usesEdgeArticulationspublic boolean usesEdgeArticulations() Description copied from interface:VisualGraphLayoutReturns true if this layout uses articulated edges. AllVisualEdges have the ability to articulate. This method servers as a shortcut for algorithms so that they need not loop over all edges to determine if they have articulations. (Looping over large graphs is time intensive.)- Specified by:
- usesEdgeArticulationsin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Returns:
- true if this layout uses articulated edges.
 
 - 
resetpublic void reset() - Specified by:
- resetin interface- edu.uci.ics.jung.algorithms.layout.Layout<V extends VisualVertex,E extends VisualEdge<V>>
 
 - 
disposepublic void dispose() Description copied from interface:VisualGraphLayoutCleanup any resource being managed by this layout.- Specified by:
- disposein interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
 
 - 
isCondensedLayoutprotected boolean isCondensedLayout() Returns true if this layout is in a condensed mode, which means to reduce space between vertices and edges. This is useful to save space. Subclasses may choose to have this setting controlled via an option that the user can toggle.- Returns:
- true for a condensed layout
 
 - 
initializepublic void initialize() - Specified by:
- initializein interface- edu.uci.ics.jung.algorithms.layout.Layout<V extends VisualVertex,E extends VisualEdge<V>>
 
 - 
calculateLocationspublic LayoutPositions<V,E> calculateLocations(VisualGraph<V,E> visualGraph, TaskMonitor taskMonitor) Description copied from interface:VisualGraphLayoutSignals to again layout the current graph. The locations generated by the layout will be returned, but not actually applied to the graph. This allows clients to generate new locations and then apply them in a delayed fashion, like for animation.- Specified by:
- calculateLocationsin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Parameters:
- visualGraph- the graph that contains the vertices to layout
- taskMonitor- the task monitor used to report progress or to cancel
 
 - 
doCalculateLocationsprotected LayoutPositions<V,E> doCalculateLocations(VisualGraph<V,E> g, TaskMonitor taskMonitor) 
 - 
createClonedLayoutpublic abstract AbstractVisualGraphLayout<V,E> createClonedLayout(VisualGraph<V,E> newGraph) This class has implementedcloneLayout(VisualGraph)in order to properly initialize location information in the layout so that subclasses do not have to. Each subclass still needs to create the new instance of the layout that is being cloned, as this class does not know how to do so.- Parameters:
- newGraph- the new graph for the new layout
- Returns:
- the new layout
 
 - 
cloneLayoutpublic VisualGraphLayout<V,E> cloneLayout(VisualGraph<V,E> newGraph) Description copied from interface:VisualGraphLayoutCreates a new version of this layout using the given graph. Also, the new layout will have the same state as this layout (i.e., vertex positions (and edge articulations, if applicable)).- Specified by:
- cloneLayoutin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Parameters:
- newGraph- the new graph for the new layout
- Returns:
- the new layout
 
 - 
initializeClonedLayoutprotected void initializeClonedLayout(AbstractVisualGraphLayout<V,E> newLayout) Takes the given layout and copies the layout information this layout into that layout- Parameters:
- newLayout- the new layout to update
 
 - 
applyNewLocationsprotected void applyNewLocations(java.util.Map<V,java.awt.geom.Point2D> newLocations) 
 - 
applyNewArticulationsprotected void applyNewArticulations(java.util.Map<E,java.util.List<java.awt.geom.Point2D>> edgeArticulations) 
 - 
positionInLayoutSpaceFromGridprotected LayoutPositions<V,E> positionInLayoutSpaceFromGrid(VisualGraph<V,E> visualGraph, GridLocationMap<V,E> gridLocations) throws CancelledException - Throws:
- CancelledException
 
 - 
getVertexLocationprotected java.awt.geom.Point2D getVertexLocation(V v, Column col, Row<V> row, java.awt.Rectangle bounds) 
 - 
getCenteredVertexLocationprotected java.awt.geom.Point2D getCenteredVertexLocation(V v, Column col, Row<V> row, java.awt.Rectangle bounds) Returns a location for the given vertex that is centered within its cell- Parameters:
- v- the vertex
- col- the vertex's column in the grid
- row- the vertex's row in the grid
- bounds- the bounds of the vertex in the layout space
- Returns:
- the centered location
 
 - 
positionEdgeArticulationsInLayoutSpaceprotected java.util.Map<E,java.util.List<java.awt.geom.Point2D>> positionEdgeArticulationsInLayoutSpace(VisualGraphVertexShapeTransformer<V> transformer, java.util.Map<V,java.awt.geom.Point2D> vertexLayoutLocations, java.util.Collection<E> edges, LayoutLocationMap<V,E> layoutLocations) throws CancelledException - Throws:
- CancelledException
 
 - 
getCenteredEdgeLocationprotected java.awt.geom.Point2D getCenteredEdgeLocation(Column col, Row<V> row) 
 - 
condenseVerticesprotected void condenseVertices(java.util.List<Row<V>> rows, java.util.Map<V,java.awt.geom.Point2D> newLocations, VisualGraphVertexShapeTransformer<V> transformer, double centerX, double centerY) 
 - 
condenseEdgesprotected void condenseEdges(java.util.List<Row<V>> rows, java.util.Map<E,java.util.List<java.awt.geom.Point2D>> newEdgeArticulations, double centerX, double centerY) 
 - 
getCondenseFactorprotected double getCondenseFactor() The amount (from 0 to 1.0) by which to condense the vertices of the graph when that feature is enabled. The default is .5 (50%). A value of 1.0 would be fully-condensed such that all vertices are aligned on the x-axis on the center of the graph.- Returns:
- the condense factor
 
 - 
addLayoutListenerpublic void addLayoutListener(LayoutListener<V,E> listener) Description copied from interface:VisualGraphLayoutAdds a layout listener- Specified by:
- addLayoutListenerin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Parameters:
- listener- the listener
 
 - 
removeLayoutListenerpublic void removeLayoutListener(LayoutListener<V,E> listener) Description copied from interface:VisualGraphLayoutRemoves a layout listener- Specified by:
- removeLayoutListenerin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Parameters:
- listener- the listener
 
 - 
setLocationpublic void setLocation(V v, java.awt.geom.Point2D location) - Specified by:
- setLocationin interface- edu.uci.ics.jung.algorithms.layout.Layout<V extends VisualVertex,E extends VisualEdge<V>>
- Overrides:
- setLocationin class- edu.uci.ics.jung.algorithms.layout.AbstractLayout<V extends VisualVertex,E extends VisualEdge<V>>
 
 - 
setLocationpublic void setLocation(V v, java.awt.geom.Point2D location, LayoutListener.ChangeType changeType) Description copied from interface:VisualGraphLayoutAllows the client to change the location while specifying the type of change- Specified by:
- setLocationin interface- VisualGraphLayout<V extends VisualVertex,E extends VisualEdge<V>>
- Parameters:
- v- the vertex
- location- the new location
- changeType- the type of change
 
 
- 
 
-