Interface PointGrid

    • Method Detail

      • width

        @Extension
        int width()
        Returns the width of this grid. All point array in this grid must have this length.
        Returns:
        The grid width.
        See Also:
        PointArray#length
      • height

        @Extension
        int height()
        Returns the length of this array. This is equivalent to rows().length().
        Returns:
        The grid height.
      • get

        @Extension
        DirectPosition get​(int row,
                           int column)
                    throws IndexOutOfBoundsException
        Returns the point at the given row and column index. This is equivalent to getRow(row).get(column).
        Parameters:
        row - The row index from 0 inclusive to height() exclusive.
        column - The column index from 0 inclusive to width() exclusive.
        Returns:
        The point at the given index.
        Throws:
        IndexOutOfBoundsException - if an index is out of bounds.
      • get

        @Extension
        DirectPosition get​(int row,
                           int column,
                           DirectPosition dest)
                    throws IndexOutOfBoundsException
        Gets a copy of the DirectPosition at the particular location in this PointGrid. If the dest argument is non-null, that object will be populated with the value from the array. In all cases, the position in insulated from changes in the PointArray, and vice-versa. Consequently, the same DirectPosition object can be reused for fetching many points from this grid. Example:
          DirectPosition position = null;
          for (int j=0; j<grid.height(); j++) {
              for (int i=0; i<grid.width(); i++) {
                  position = array.get(j, i, position);
                  // Do some processing...
              }
          }
         
        Parameters:
        row - The row index from 0 inclusive to height() exclusive.
        column - The column index from 0 inclusive to width() exclusive.
        dest - An optionnaly pre-allocated direct position.
        Returns:
        The dest argument, or a new object if dest was null.
        Throws:
        IndexOutOfBoundsException - if an index is out of bounds.
      • set

        @Extension
        void set​(int row,
                 int column,
                 DirectPosition position)
          throws IndexOutOfBoundsException,
                 UnsupportedOperationException
        Set the point at the given index. The point coordinates will be copied, i.e. changes to the given position after this method call will not be reflected into this point array. Consequently, the same DirectPosition object can be reused for setting many points in this array.
        Parameters:
        row - The row index from 0 inclusive to height() exclusive.
        column - The column index from 0 inclusive to width() exclusive.
        position - The point to set at the given location in this array.
        Throws:
        IndexOutOfBoundsException - if an index is out of bounds.
        UnsupportedOperationException - if this grid is immutable.
      • getRow

        @Extension
        PointArray getRow​(int row)
                   throws IndexOutOfBoundsException
        Returns the row at the given index. The row is backed by this PointGrid, so changes to the row are reflected in the grid, and vice-versa.
        Parameters:
        row - The index from 0 inclusive to height() exclusive.
        Returns:
        The row at the given index.
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds.