java.lang.Object
eu.hansolo.toolbox.observables.ObservableMatrix<T>
-
Constructor Summary
ConstructorsConstructorDescriptionObservableMatrix(ObservableMatrix<T> copyFromMatrix) ObservableMatrix(Class<T> type, int cols, int rows) ObservableMatrix(Class<T> type, int cols, int rows, boolean resizeMatrixWhenInnerRowOrColIsRemoved) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a column at the given position in the matrix and fills it with the items from the itemSuppliervoidvoidvoidvoidaddMatrixChangeObserver(EvtType type, EvtObserver<MatrixChangeEvt<T>> observer) voidaddMatrixItemChangeObserver(EvtType type, EvtObserver<MatrixItemChangeEvt<T>> observer) voidaddNullCol(int at) voidaddNullCol(int at, boolean notify) voidaddNullRow(int at) voidaddNullRow(int at, boolean notify) voidAdds a row at the given position in the matrix and fills it with the items from the itemSuppliervoidvoidvoidbooleanReturns true if the given item will be found in the matrixvoidvoidReturns all items in matrix that are non null as listgetCol(int col) Get all items in column specified by index as listbooleanint[]getIndicesOf(T item) Returns the indices of the given item as an array of int[], where [0] contains the column and [1] contains the row of the item In case the item was not found the method will return [-1, -1]getItemAt(int x, int y) Returns the given item in the matrix at the given position defined by x and yAtomicReference<T>[][]Returns the 2-dimensional array of typeintReturns the number of columns in the matrixintReturns the number of rows in the matrixbooleangetRow(int row) Get all items in row specified by index as listbooleangetType()Returns the type of the matrix elementsbooleanisColEmpty(int col) Returns true if all items in given column index equals nullbooleanisEmpty()booleanisRowEmpty(int row) Returns true if all items in given row index equals nullvoidvoidmirrorColumns(boolean notify) voidvoidmirrorRows(boolean notify) voidvoidvoidremoveCol(int at) Removes col at given indexvoidremoveCol(int at, boolean notify) voidremoveItem(T item) If item is found in matrix it's position in the matrix will be set to nullvoidremoveItem(T item, boolean notify) voidremoveItemAt(int x, int y) Removes item at position defined by x and y Item will be set to nullvoidremoveItemAt(int x, int y, boolean notify) voidremoveMatrixChangeObserver(EvtType type, EvtObserver<MatrixChangeEvt<T>> observer) voidremoveMatrixItemChangeObserver(EvtType type, EvtObserver<MatrixItemChangeEvt<T>> observer) voidremoveRow(int at) Removes row at given indexvoidremoveRow(int at, boolean notify) voidreset()voidsetCols(int cols) Sets the number of columsn in the matrix.voidsetCols(int cols, boolean notify) voidSets the given item in the matrix at the given position defined by x and yvoidvoidsetResizeMatrixWhenInnerRowOrColIsRemoved(boolean resize) voidsetRows(int rows) Sets the number of rows in the matrix.voidsetRows(int rows, boolean notify) stream()Returns all items in matrix as streamtoString()
-
Constructor Details
-
ObservableMatrix
-
ObservableMatrix
-
ObservableMatrix
-
-
Method Details
-
getType
Returns the type of the matrix elements- Returns:
- the type of the matrix elements
-
getItemAt
Returns the given item in the matrix at the given position defined by x and y- Parameters:
x- Column used to return itemy- Row used to return item- Returns:
- the given item in the matrix at the given position defined by x and y
-
setItemAt
Sets the given item in the matrix at the given position defined by x and y- Parameters:
x- Column where the given item will be insertedy- Row where the given item will be inserteditem-
-
setItemAt
-
removeItemAt
public void removeItemAt(int x, int y) Removes item at position defined by x and y Item will be set to null- Parameters:
x- Column where the item will be set to nully- Column where the item will be set to null
-
removeItemAt
public void removeItemAt(int x, int y, boolean notify) -
removeItem
If item is found in matrix it's position in the matrix will be set to null- Parameters:
item- Item to remove from matrix
-
removeItem
-
contains
Returns true if the given item will be found in the matrix- Parameters:
item-- Returns:
- true if the given item will be found in the matrix
-
getIndicesOf
Returns the indices of the given item as an array of int[], where [0] contains the column and [1] contains the row of the item In case the item was not found the method will return [-1, -1]- Parameters:
item-- Returns:
- the indices of the given item as an array of in[]
-
getMatrix
Returns the 2-dimensional array of type- Returns:
- the 2-dimensional array of type
-
getAllItems
Returns all items in matrix that are non null as list- Returns:
- all items in matrix that are non null as list
-
stream
Returns all items in matrix as stream- Returns:
- all items in matrix as stream
-
reset
public void reset() -
getCol
Get all items in column specified by index as list- Parameters:
col- index of column to return as list- Returns:
- all items in column specified by index as list
-
getRow
Get all items in row specified by index as list- Parameters:
row- index of row to return as list- Returns:
- all items in row specified by index as list
-
isColEmpty
public boolean isColEmpty(int col) Returns true if all items in given column index equals null- Parameters:
col-- Returns:
- true if all items in given column index equals null
-
isRowEmpty
public boolean isRowEmpty(int row) Returns true if all items in given row index equals null- Parameters:
row-- Returns:
- true if all items in given row index equals null
-
getNoOfCols
public int getNoOfCols()Returns the number of columns in the matrix- Returns:
- the number of columsn of the matrix
-
setCols
public void setCols(int cols) Sets the number of columsn in the matrix. Existing entries will be copied to the new matrix. If the number of columns is smaller than the old one, all items in columns outside of the new matrix will be lost.- Parameters:
cols-
-
setCols
public void setCols(int cols, boolean notify) -
addCol
Adds a column at the given position in the matrix and fills it with the items from the itemSupplier- Parameters:
at- position of where to add the new columnitemSupplier- supplier of items
-
addCol
-
addCol
-
addCol
-
addNullCol
public void addNullCol(int at) -
addNullCol
public void addNullCol(int at, boolean notify) -
removeCol
public void removeCol(int at) Removes col at given index- Parameters:
at- index of col that should be removed
-
removeCol
public void removeCol(int at, boolean notify) -
addRow
Adds a row at the given position in the matrix and fills it with the items from the itemSupplier- Parameters:
at- position of where to add the new rowitemSupplier- supplier of items
-
addRow
-
addRow
-
addRow
-
addNullRow
public void addNullRow(int at) -
addNullRow
public void addNullRow(int at, boolean notify) -
removeRow
public void removeRow(int at) Removes row at given index- Parameters:
at- index of row that should be removed
-
removeRow
public void removeRow(int at, boolean notify) -
getNoOfRows
public int getNoOfRows()Returns the number of rows in the matrix- Returns:
- the number of rows in the matrix
-
setRows
public void setRows(int rows) Sets the number of rows in the matrix. Existing entries will be copied to the new matrix. If the new number of rows is smaller than the old one, all items in rows outside the new matrix will be lost.- Parameters:
rows-
-
setRows
public void setRows(int rows, boolean notify) -
getAllColumns
-
getAllEmptyColumns
-
getAllRows
-
getAllEmptyRows
-
mirrorColumns
public void mirrorColumns() -
mirrorColumns
public void mirrorColumns(boolean notify) -
mirrorRows
public void mirrorRows() -
mirrorRows
public void mirrorRows(boolean notify) -
getColsMirrored
public boolean getColsMirrored() -
getRowsMirrored
public boolean getRowsMirrored() -
getResizeMatrixWhenInnerRowOrColIsRemoved
public boolean getResizeMatrixWhenInnerRowOrColIsRemoved() -
setResizeMatrixWhenInnerRowOrColIsRemoved
public void setResizeMatrixWhenInnerRowOrColIsRemoved(boolean resize) -
isEmpty
public boolean isEmpty() -
addMatrixChangeObserver
-
removeMatrixChangeObserver
-
removeAllMatrixChangeObservers
public void removeAllMatrixChangeObservers() -
fireMatrixChangeEvt
-
addMatrixItemChangeObserver
-
removeMatrixItemChangeObserver
public void removeMatrixItemChangeObserver(EvtType type, EvtObserver<MatrixItemChangeEvt<T>> observer) -
removeAllMatrixItemChangeObservers
public void removeAllMatrixItemChangeObservers() -
fireMatrixItemChangeEvt
-
toString
-