de.frag.umlplugin.classcloud
Class Grid

java.lang.Object
  extended by de.frag.umlplugin.classcloud.Grid

public class Grid
extends java.lang.Object

Regular grid that is used as intermediate storage for class cloud cells.


Constructor Summary
Grid(int width, int height)
          Creates a grid that can contain "width" times "height" cells.
 
Method Summary
 CellCoordinate chooseCoordinate(Cell cell)
          Chooses a cell coordinate that has the nearest distance to all available cell candidates.
 java.util.List<CellCoordinate> getCandidates()
          Current list of cell candidates.
 Cell getCell(int x, int y)
          Gets cell at given coordinates.
 int getHeight()
          Gets grid height.
 int getWidth()
          Gets grid width.
 void placeCell(Cell cell)
          Places a single cell by choosing a coordinate from the current list of candidates that is nearest to the preferred coordinate of the cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grid

public Grid(int width,
            int height)
Creates a grid that can contain "width" times "height" cells.

Parameters:
width - width of grid in cells
height - height of grid in cells
Method Detail

placeCell

public void placeCell(@NotNull
                      Cell cell)
Places a single cell by choosing a coordinate from the current list of candidates that is nearest to the preferred coordinate of the cell. The chosen coordinate is removed from the list of candidates.

Parameters:
cell - cell to be placed.

chooseCoordinate

@NotNull
public CellCoordinate chooseCoordinate(@NotNull
                                               Cell cell)
Chooses a cell coordinate that has the nearest distance to all available cell candidates.

Parameters:
cell - cell to choose coordinate for
Returns:
chosen coordinate

getCandidates

@NotNull
public java.util.List<CellCoordinate> getCandidates()
Current list of cell candidates.

Returns:
list of candidates

getWidth

public int getWidth()
Gets grid width.

Returns:
Gets grid width

getHeight

public int getHeight()
Gets grid height.

Returns:
Gets grid height

getCell

@Nullable
public Cell getCell(int x,
                             int y)
Gets cell at given coordinates.

Parameters:
x - x-coordinate
y - y-coordinate
Returns:
found cell or null, if no cell exists at given coordinate