@Test(expected = IllegalArgumentException.class) public void testFindSimplePositionColIsTooBig() { grid.findPosition(5, 10000); }
public Point findPosition(final Point anchorPoint, final Direction direction) { int width = getWidth(); int height = getHeight(); int x = anchorPoint.getX(); int y = anchorPoint.getY(); switch (direction) { case NORTH: x -= width / 2; y -= height; break; case SOUTH: x -= width / 2; break; case EAST: y -= height / 2; break; case WEST: x -= width; y -= height / 2; break; case NONE: x -= width / 2; y -= height / 2; break; case NORTH_EAST: y -= height; break; case SOUTH_EAST: break; case SOUTH_WEST: x -= width; break; case NORTH_WEST: x -= width; y -= height; break; default: throw new UnsupportedOperationException(); } return new Point(x, y); }
Grid implements Iterable<Grid.Point> { public Point findPosition(final Point anchorPoint, final Direction direction) { int width = getWidth(); int height = getHeight(); int x = anchorPoint.getX(); int y = anchorPoint.getY(); switch (direction) { case NORTH: x -= width / 2; y -= height; break; case SOUTH: x -= width / 2; break; case EAST: y -= height / 2; break; case WEST: x -= width; y -= height / 2; break; case NONE: x -= width / 2; y -= height / 2; break; case NORTH_EAST: y -= height; break; case SOUTH_EAST: break; case SOUTH_WEST: x -= width; break; case NORTH_WEST: x -= width; y -= height; break; default: throw new UnsupportedOperationException(); } return new Point(x, y); } }
Grid implements Iterable<Grid.Point> { public Point findPosition(final Point anchorPoint, final Direction direction) { int width = getWidth(); int height = getHeight(); int x = anchorPoint.getX(); int y = anchorPoint.getY(); switch (direction) { case NORTH: x -= width / 2; y -= height; break; case SOUTH: x -= width / 2; break; case EAST: y -= height / 2; break; case WEST: x -= width; y -= height / 2; break; case NONE: x -= width / 2; y -= height / 2; break; case NORTH_EAST: y -= height; break; case SOUTH_EAST: break; case SOUTH_WEST: x -= width; break; case NORTH_WEST: x -= width; y -= height; break; default: throw new UnsupportedOperationException(); } return new Point(x, y); } Grid(final int padding,
                final int iconSize,
                final int rows,
                final int cols); }
Grid implements Iterable<Grid.Point> { public Point findPosition(final Point anchorPoint, final Direction direction) { int width = getWidth(); int height = getHeight(); int x = anchorPoint.getX(); int y = anchorPoint.getY(); switch (direction) { case NORTH: x -= width / 2; y -= height; break; case SOUTH: x -= width / 2; break; case EAST: y -= height / 2; break; case WEST: x -= width; y -= height / 2; break; case NONE: x -= width / 2; y -= height / 2; break; case NORTH_EAST: y -= height; break; case SOUTH_EAST: break; case SOUTH_WEST: x -= width; break; case NORTH_WEST: x -= width; y -= height; break; default: throw new UnsupportedOperationException(); } return new Point(x, y); } Grid(final int padding,
                final int iconSize,
                final int rows,
                final int cols); Point findPosition(final Point anchorPoint,
                              final Direction direction); Point findPosition(final int row,
                              final int col); @Override Iterator<Point> iterator(); int getRows(); int getCols(); int size(); int getWidth(); int getHeight(); }
Grid implements Iterable<Grid.Point> { public Point findPosition(final Point anchorPoint, final Direction direction) { int width = getWidth(); int height = getHeight(); int x = anchorPoint.getX(); int y = anchorPoint.getY(); switch (direction) { case NORTH: x -= width / 2; y -= height; break; case SOUTH: x -= width / 2; break; case EAST: y -= height / 2; break; case WEST: x -= width; y -= height / 2; break; case NONE: x -= width / 2; y -= height / 2; break; case NORTH_EAST: y -= height; break; case SOUTH_EAST: break; case SOUTH_WEST: x -= width; break; case NORTH_WEST: x -= width; y -= height; break; default: throw new UnsupportedOperationException(); } return new Point(x, y); } Grid(final int padding,
                final int iconSize,
                final int rows,
                final int cols); Point findPosition(final Point anchorPoint,
                              final Direction direction); Point findPosition(final int row,
                              final int col); @Override Iterator<Point> iterator(); int getRows(); int getCols(); int size(); int getWidth(); int getHeight();  }