windowCells.add(cellIter.next());
for (int cell=0; cell<windowCells.size(); cell++)
{
final ColMajorCell currentCell = (ColMajorCell)windowCells.get(cell);
if ( (currentCell.getCol() != minI()) && (currentCell.getRow() != maxJ()) )// move to upper left if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol()-radius;
final int targetRow = currentCell.getRow()+radius;
if ( (targetCol>=minI()) && (targetRow<=maxJ()))
markVisited(targetCol, targetRow);
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = Math.max(minI()-targetCol, targetRow-maxJ());
markVisited(targetCol+cellsPastEdge, targetRow-cellsPastEdge);
} // end if
} // end if
if (currentCell.getRow() != maxJ()) // move up if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol();
final int targetRow = currentCell.getRow()+radius;
if (targetRow <= maxJ())
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = targetRow-maxJ();
markVisited(targetCol, targetRow-cellsPastEdge);
} // end if
} // end if
if ((currentCell.getCol() != maxI()) && (currentCell.getRow() != maxJ())) // move to upper-right if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol()+radius;
final int targetRow = currentCell.getRow()+radius;
if ( (targetCol<=maxI()) && (targetRow<=maxJ()))
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = Math.max(targetCol-maxI(), targetRow-maxJ());
markVisited(targetCol-cellsPastEdge, targetRow-cellsPastEdge);
} // end if
} // end if
if (currentCell.getCol() != minI()) // move left if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol()-radius;
final int targetRow = currentCell.getRow();
if (targetCol >= minI())
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = minI()-targetCol;
markVisited(targetCol+cellsPastEdge, targetRow);
} // end if
} // end if
if (currentCell.getCol() != maxI()) // move right if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol()+radius;
final int targetRow = currentCell.getRow();
if (targetCol <= maxI())
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = targetCol-maxI();
markVisited(targetCol-cellsPastEdge, targetRow);
} // end if
} // end if
if ( (currentCell.getCol() != minI()) && (currentCell.getRow() != minJ()) ) // move to lower-left if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol()-radius;
final int targetRow = currentCell.getRow()-radius;
if ( (targetCol>=minI()) && (targetRow>=minJ()))
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = Math.max(minI()-targetCol, minJ()-targetRow);
markVisited(targetCol+cellsPastEdge, targetRow+cellsPastEdge);
} // end if
} // end if
if (currentCell.getRow() != minJ()) // move down if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol();
final int targetRow = currentCell.getRow()-radius;
if (targetRow >= minJ())
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{
// Expand the window only to the edge of the matrix.
final int cellsPastEdge = minJ()-targetRow;
markVisited(targetCol, targetRow+cellsPastEdge);
} // end if
} // end if
if ((currentCell.getCol() != maxI()) && (currentCell.getRow() != minJ())) // move to lower-right if possible
{
// Either extend full search radius or some fraction until edges of matrix are met.
final int targetCol = currentCell.getCol()+radius;
final int targetRow = currentCell.getRow()-radius;
if ( (targetCol<=maxI()) && (targetRow>=minJ()))
markVisited(targetCol, targetRow); // radius does not go past the edges of the matrix
else
{