Class GridLocationMap<V,E>

java.lang.Object
ghidra.graph.viewer.layout.GridLocationMap<V,E>
Type Parameters:
V - the vertex type
E - the edge type

public class GridLocationMap<V,E> extends Object
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 Details

  • Constructor Details

    • GridLocationMap

      public GridLocationMap()
    • GridLocationMap

      public GridLocationMap(V root, int row, int col)
      Constructor that includes an initial "root" vertex.
      Parameters:
      root - the initial vertex
      row - the row for the initial vertex
      col - 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

      public Set<V> vertices()
    • edges

      public Set<E> edges()
    • getVertexPoints

      public Map<V,GridPoint> getVertexPoints()
    • setArticulations

      public void setArticulations(E edge, List<GridPoint> articulations)
    • getArticulations

      public List<GridPoint> getArticulations(E edge)
    • row

      public void row(V vertex, int row)
    • col

      public void col(V vertex, int col)
    • set

      public void set(V v, int row, int col)
    • set

      public void set(V v, GridPoint gridPoint)
    • row

      public int row(V vertex)
    • col

      public int col(V vertex)
    • gridPoint

      public GridPoint gridPoint(V vertex)
    • rows

      public List<Row<V>> rows()
      Returns the rows in this grid, sorted by index (index can be negative)
      Returns:
      the rows in this grid
    • rowsMap

      public Map<Integer,Row<V>> rowsMap()
      Returns a mapping or row indexes to Row objects in this grid
      Returns:
      the rows in this grid
    • columnsMap

      public Map<Integer,Column<V>> 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 point
      colShift - 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

      public GridRange[] 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

      public boolean containsVertex(V v)
    • containsEdge

      public boolean containsEdge(E e)
    • add

      public void 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.
      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 grid
      colShift - the amount to shift the columns in the grid points from the other grid before adding them to this grid
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringGrid

      public String toStringGrid()
      Creates a string representation of this grid
      Returns:
      a string representation of this grid
    • containsPoint

      public boolean containsPoint(GridPoint p)