Class DynamicMatrix

java.lang.Object
overit.geocall.util.DynamicMatrix
All Implemented Interfaces:
Matrix

public class DynamicMatrix extends Object implements Matrix
Auxiliary class that implements the interface Matrix and must be used to create and manage a dynamic matrix. To set the width and height of the matrix must be set the element in a cell; so the matrix will be enlarged if the necessary. It is possible set a single element or more elements passing a Matrix or a SimpleMatrix. It is also possible to obtain a SimpleMatrix using the method toSimpleMatrix() .
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected HashMap
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Empty constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int x, int y)
    Gets the element presents in the matrix in row 'x' and in column 'y'.
    int
    Gets the height of the matrix.
    int
    Gets the width of the matrix.
    void
    set(int x, int y, Object o)
    Sets the element in the matrix to row 'x' and in column 'y'.
    void
    set(int x, int y, Matrix dm)
    Sets the elements in the matrix starting from the element to row 'x' and column 'y'.
    void
    set(int x, int y, SimpleMatrix dm)
    Sets the elements in the matrix starting from the element to row 'x' and column 'y'.
    Creates a SimpleMatrix of equal height and width of the DynamicMatrix and fill it with the element present in this matrix.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _hm

      protected HashMap _hm
    • _w

      protected int _w
    • _h

      protected int _h
  • Constructor Details

    • DynamicMatrix

      public DynamicMatrix()
      Empty constructor
  • Method Details

    • set

      public void set(int x, int y, Object o)
      Sets the element in the matrix to row 'x' and in column 'y'. If the indeces are better of the width and/or height, the matrix is enlarged to admit these indices.
      Specified by:
      set in interface Matrix
      Parameters:
      x - The horizontal position of the cell
      y - The vertical position of the cell
      o - The object to set
    • set

      public void set(int x, int y, Matrix dm)
      Sets the elements in the matrix starting from the element to row 'x' and column 'y'. Each element in the input Matrix is copied to the DynamicMatrix by re-mapping it: it is translated by 'x' rows and 'y' columns.
      Parameters:
      x - The row
      y - The column
      dm - The Matrix to copy
    • set

      public void set(int x, int y, SimpleMatrix dm)
      Sets the elements in the matrix starting from the element to row 'x' and column 'y'. Each element in the input SimpleMatrix is copied to the DynamicMatrix by re-mapping it: it is translated by 'x' rows and 'y' columns.
      Parameters:
      x - The row
      y - The column
      dm - The SimpleMatrix to copy
    • get

      public Object get(int x, int y)
      Gets the element presents in the matrix in row 'x' and in column 'y'. The indeces start from '0'
      Specified by:
      get in interface Matrix
      Parameters:
      x - The horizontal position of the cell from which extract the object
      y - The vertical position of the cell from which extract the object
      Returns:
      The element present in the corresponding cell.
    • getWidth

      public int getWidth()
      Gets the width of the matrix.
      Specified by:
      getWidth in interface Matrix
      Returns:
      The number of columns of the matrix.
    • getHeight

      public int getHeight()
      Gets the height of the matrix.
      Specified by:
      getHeight in interface Matrix
      Returns:
      The number of rows of the matrix.
    • toSimpleMatrix

      public SimpleMatrix toSimpleMatrix()
      Creates a SimpleMatrix of equal height and width of the DynamicMatrix and fill it with the element present in this matrix.
      Returns:
      The SimpleMatrix generated and filled.