/** * Remove all edges connecting dead cells with others Call this after loading this entity from db * OR after config is changed. (i.e., after ratio or actualW or actualH is changed) */ public void updateGraph() { cellContainer = new Cell[rowCount][colCount]; initGraph(); int row, col; for (DeadPoint dp : deadPoints) { col = getCorrespondingCol(dp.getX()); row = getCorrespondingRow(dp.getY()); if (valid(row, col)) g.removeVertex(cellContainer[row][col]); } }
/** @return an unmodifiable list of cells containing dead points (aka dead cells) */ public List<Cell> getDeadCells() { ArrayList<Cell> deadCells = new ArrayList<Cell>(); int row, col; for (DeadPoint dp : deadPoints) { row = getCorrespondingRow(dp.getY()); col = getCorrespondingCol(dp.getX()); if (valid(row, col)) deadCells.add(cellContainer[row][col]); } return Collections.unmodifiableList(deadCells); }
/** * @param row * @param col * @param dp * @return true if the given dead point is in the cell at specified location */ private boolean isInCell(int row, int col, DeadPoint dp) { return row == getCorrespondingRow(dp.getY()) && col == getCorrespondingCol(dp.getX()); }
public int getCorrespondingRow(DeadPoint dp) { return dp.getY() / unitH; }