Package ghidra.graph.viewer.layout

# 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 Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Map<E,List<GridPoint>>`
  `edgePoints`
  `protected Map<V,GridPoint>`
  `vertexPoints`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GridLocationMap()`
  `GridLocationMap(V root, int row, int col)`
  Constructor that includes an initial "root" vertex.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `void`
  `centerRows()`
  Updates each row within the grid such that it's column values are set to center the row in the grid.
  `int`
  `col(V vertex)`
  `void`
  `col(V vertex, int col)`
  `Map<Integer,Column<V>>`
  `columnsMap()`
  Returns a mapping or column indexes to Column objects in this grid
  `boolean`
  `containsEdge(E e)`
  `boolean`
  `containsPoint(GridPoint p)`
  `boolean`
  `containsVertex(V v)`
  `void`
  `dispose()`
  `Set<E>`
  `edges()`
  `List<GridPoint>`
  `getArticulations(E edge)`
  `int`
  `getRootColumn()`
  Returns the column of the initial vertex in this grid.
  `int`
  `getRootRow()`
  Returns the row of the initial vertex in this grid.
  `GridRange[]`
  `getVertexColumnRanges()`
  Returns the minimum/max column for all rows in the grid.
  `Map<V,GridPoint>`
  `getVertexPoints()`
  `GridRange[]`
  `getVertexRowRanges()`
  Returns the minimum/max row for all columns in the grid.
  `GridPoint`
  `gridPoint(V vertex)`
  `int`
  `height()`
  Returns the number of rows in this grid map.
  `int`
  `row(V vertex)`
  `void`
  `row(V vertex, int row)`
  `List<Row<V>>`
  `rows()`
  Returns the rows in this grid, sorted by index (index can be negative)
  `Map<Integer,Row<V>>`
  `rowsMap()`
  Returns a mapping or row indexes to Row objects in this grid
  `void`
  `set(V v, int row, int col)`
  `void`
  `set(V v, GridPoint gridPoint)`
  `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.
  `String`
  `toString()`
  `String`
  `toStringGrid()`
  Creates a string representation of this grid
  `Set<V>`
  `vertices()`
  `int`
  `width()`
  Returns the number of columns in this grid map.
  `void`
  `zeroAlignGrid()`
  Shifts the grid so that its first row and column are at 0.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### vertexPoints

    protected Map<V,GridPoint> vertexPoints

  - ### edgePoints

    protected Map<E,List<GridPoint>> edgePoints

- ## 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

  - ### getRootRow

    public int getRootRow()
    Returns the row of the initial vertex in this grid.
    Returns:
      the row 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.

  - ### getVertexRowRanges

    public GridRange[] getVertexRowRanges()
    Returns the minimum/max row for all columns in the grid. This method is only defined for grids that have no negative columns. This is because the array returned will be 0 based, with the entry at index 0 containing the row bounds for column 0 and so on.
    Returns:
      the minimum/max row for all columns 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)