Package ghidra.graph.viewer.layout
Class GridLocationMap<V,E>
java.lang.Object
ghidra.graph.viewer.layout.GridLocationMap<V,E>
- Type Parameters:
V
- the vertex typeE
- the edge type
An object that maps vertices and edge articulation points to rows and columns in a grid. This
class is essentially a container that allows layout algorithms to store results as it lays
out vertices and edges in a virtual grid. Later, this information can be used in conjunction
with vertex size information and padding information to transform these grid coordinates to
layout space coordinates.
This object also has methods for manipulating the grid such as shifting it up, down, left, right, and merging in other GridLocationMaps
After building the grid using this class, clients can call rows()
, rowsMap()
,
or columnsMap()
to get high-order objects that represent rows or columns.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
ConstructorsConstructorDescriptionGridLocationMap
(V root, int row, int col) Constructor that includes an initial "root" vertex. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(GridLocationMap<V, E> other, int rowShift, int colShift) Adds in the vertices and edges from another GridLocationMap with each point in the other grid map shifted by the given row and column amounts.void
Updates each row within the grid such that it's column values are set to center the row in the grid.int
void
Returns a mapping or column indexes to Column objects in this gridboolean
containsEdge
(E e) boolean
boolean
containsVertex
(V v) void
dispose()
edges()
getArticulations
(E edge) int
Returns the column of the initial vertex in this grid.Returns the minimum/max column for all rows in the grid.int
height()
Returns the number of rows in this grid map.int
void
rows()
Returns the rows in this grid, sorted by index (index can be negative)rowsMap()
Returns a mapping or row indexes to Row objects in this gridvoid
void
void
setArticulations
(E edge, List<GridPoint> articulations) void
shift
(int rowShift, int colShift) Shifts the rows and columns for all points in this map by the given amount.toString()
Creates a string representation of this gridvertices()
int
width()
Returns the number of columns in this grid map.void
Shifts the grid so that its first row and column are at 0.
-
Field Details
-
vertexPoints
-
edgePoints
-
-
Constructor Details
-
GridLocationMap
public GridLocationMap() -
GridLocationMap
Constructor that includes an initial "root" vertex.- Parameters:
root
- the initial vertexrow
- the row for the initial vertexcol
- the column for the initial vertex.
-
-
Method Details
-
getRootColumn
public int getRootColumn()Returns the column of the initial vertex in this grid.- Returns:
- the column of the initial vertex in this grid
-
vertices
-
edges
-
getVertexPoints
-
setArticulations
-
getArticulations
-
row
-
col
-
set
-
set
-
row
-
col
-
gridPoint
-
rows
Returns the rows in this grid, sorted by index (index can be negative)- Returns:
- the rows in this grid
-
rowsMap
Returns a mapping or row indexes to Row objects in this grid- Returns:
- the rows in this grid
-
columnsMap
Returns a mapping or column indexes to Column objects in this grid- Returns:
- the columns in this grid
-
centerRows
public void centerRows()Updates each row within the grid such that it's column values are set to center the row in the grid. Each row will be updated so that all its columns start at zero. After that, each column will be centered in the grid. -
zeroAlignGrid
public void zeroAlignGrid()Shifts the grid so that its first row and column are at 0. -
dispose
public void dispose() -
shift
public void shift(int rowShift, int colShift) Shifts the rows and columns for all points in this map by the given amount.- Parameters:
rowShift
- the amount to shift the rows of each pointcolShift
- the amount to shift the columns of each point
-
height
public int height()Returns the number of rows in this grid map. Note that this includes empty rows starting at the 0 row.- Returns:
- the number of rows in this grid map
-
width
public int width()Returns the number of columns in this grid map. Note that this includes empty columns starting at the 0 column.- Returns:
- the number of columns in this grid map
-
getVertexColumnRanges
Returns the minimum/max column for all rows in the grid. This method is only defined for grids that have no negative rows. This is because the array returned will be 0 based, with the entry at index 0 containing the column bounds for row 0 and so on.- Returns:
- the minimum/max column for all rows in the grid
- Throws:
IllegalStateException
- if this method is called on a grid with negative rows.
-
containsVertex
-
containsEdge
-
add
Adds in the vertices and edges from another GridLocationMap with each point in the other grid map shifted by the given row and column amounts.- Parameters:
other
- the other GridLocationMap to add to this one.rowShift
- the amount to shift the rows in the grid points from the other grid before adding them to this gridcolShift
- the amount to shift the columns in the grid points from the other grid before adding them to this grid
-
toString
-
toStringGrid
Creates a string representation of this grid- Returns:
- a string representation of this grid
-
containsPoint
-