Class Row<V>

  • Type Parameters:
    V - the vertex type

    public class Row<V>
    extends java.lang.Object
    A row in a grid. This class stores its row index, its y offset and its height. The y value is the layout space y value of a Point2D object. That is, unlike the GridLocationMap, the y value of this object is in layout space and not indexes of a grid.

    This class maintains a collection of vertices on this row, organized by column index. You can get the column of a vertex from getColumn(V).

    • Field Summary

      Fields 
      Modifier and Type Field Description
      int height  
      int index
      The grid index of this row (0, 1...n) for the number of rows
      int y
      The layout y coordinate of the column
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getColumn​(V v)
      Returns the column index for the given vertex
      int getColumnCount()
      Represents the range of columns in this row.
      int getEndColumn()
      Returns the largest column index in this row
      int getPaddedHeight​(boolean isCondensed)  
      java.lang.Integer getStartColumn()
      Returns the smallest column index in this row
      V getVertex​(int column)
      Returns the vertex at the given column index or null if there is no vertex at that column
      java.util.List<V> getVertices()
      Returns all vertices in this row, sorted by column index (min to max).
      boolean isInitialized()  
      void setColumn​(V v, int col)
      Sets the column index in this row for the given vertex
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • y

        public int y
        The layout y coordinate of the column
      • height

        public int height
      • index

        public int index
        The grid index of this row (0, 1...n) for the number of rows
    • Method Detail

      • setColumn

        public void setColumn​(V v,
                              int col)
        Sets the column index in this row for the given vertex
        Parameters:
        v - the vertex
        col - the column index
      • getColumn

        public int getColumn​(V v)
        Returns the column index for the given vertex
        Parameters:
        v - the vertex
        Returns:
        the column index for the given vertex
      • getVertex

        public V getVertex​(int column)
        Returns the vertex at the given column index or null if there is no vertex at that column
        Parameters:
        column - the column index
        Returns:
        the vertex
      • getColumnCount

        public int getColumnCount()
        Represents the range of columns in this row. For this given row in a grid:
                0 1 2 3 4 5 6
                - - v - v - - 
         
        the column count is 3--where the column range is 2-4, inclusive.

        Note: this differs from then number of vertices in this row, as the column count includes columns that have no vertex.

        Returns:
        the number of columns in this row, including empty columns between start and end
      • getStartColumn

        public java.lang.Integer getStartColumn()
        Returns the smallest column index in this row
        Returns:
        the smallest column index in this row
      • getEndColumn

        public int getEndColumn()
        Returns the largest column index in this row
        Returns:
        the largest column index in this row
      • getVertices

        public java.util.List<V> getVertices()
        Returns all vertices in this row, sorted by column index (min to max).

        Note: the index of a vertex in the list does not match the column index. To get the column index for a vertex, call getColumn(V).

        Returns:
        all vertices in this row
      • getPaddedHeight

        public int getPaddedHeight​(boolean isCondensed)
      • isInitialized

        public boolean isInitialized()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object