Class GridLayout

A container that consists of components with certain coordinates on a grid. It also maintains cursor for adding component in left to right, top to bottom order.

Each component in a GridLayout uses a certain area (x1,y1,x2,y2) from the grid. One should not add components that would overlap with the existing components because in such case an com.itmill.toolkit.ui.GridLayout.OverlapsException is thrown. Adding component with cursor automatically extends the grid by increasing the grid height.

GridLayout()

Constructs an empty grid layout that is extended as needed.

GridLayout(int, int)

Parameters

width

Width of the grid.

height

Height of the grid.

Constructor for grid of given size. Note that grid's final size depends on the items that are added into the grid. Grid grows if you add components outside the grid's area.

addComponent(Component)

Parameters

c

The component to be added.

Add a component into this container to the cursor position. If the cursor position is already occupied, the cursor is moved forwards to find free position. If the cursor goes out from the bottom of the grid, the grid is automaticly extended.

addComponent(Component, int, int)

Parameters

c

The component to be added.

x

X-coordinate

y

Y-coordinate

Add component into this container to coordinates x1,y1 (NortWest corner of the area.) End coordinates (SouthEast corner of the area) are the same as x1,y1. Component width and height is 1.

addComponent(Component, int, int, int, int)

Parameters

c

The component to be added.

x1

The X-coordinate of the upper left corner of the area c is supposed to occupy

y1

The Y-coordinate of the upper left corner of the area c is supposed to occupy

x2

The X-coordinate of the lower right corner of the area c is supposed to occupy

y2

The Y-coordinate of the lower right corner of the area c is supposed to occupy

Exceptions

OverlapsException

if the new component overlaps with any of the components already in the grid

OutOfBoundsException

if the coordinates are outside of the grid area.

Adds a component with a specified area to the grid. The area the new component should take is defined by specifying the upper left corner (x1, y1) and the lower right corner (x2, y2) of the area.

If the new component overlaps with any of the existing components already present in the grid the operation will fail and an com.itmill.toolkit.ui.GridLayout.OverlapsException is thrown.

getComponentIterator()

Parameters

return

Iterator of the components inside the container.

Gets an Iterator to the component container contents. Using the Iterator it's possible to step through the contents of the container.

getCursorX()

Parameters

return

Cursor x-coordinate.

Get the current cursor x-position. The cursor position points the position for the next component that is added without specifying its coordinates. When the cursor position is occupied, the next component will be added to first free position after the cursor.

getCursorY()

Parameters

return

Cursor y-coordinate.

Get the current cursor y-position. The cursor position points the position for the next component that is added without specifying its coordinates. When the cursor position is occupied, the next component will be added to first free position after the cursor.

getHeight()

Parameters

return

int - how many cells high the grid is

Get the height of the grid.

getTag()

Parameters

return

Component UIDL tag as string.

See Also
getTag()

Gets the components UIDL tag.

getWidth()

Parameters

return

The width of the grid

Get the width of the grids.

newLine()

See Also
space()

Force the next component to be added to the beginning of the next line. By calling this function user can ensure that no more components are added to the right of the previous component.

paintContent(PaintTarget)

Parameters

event

PaintEvent.

Exceptions

PaintException

The paint operation failed.

Paints the contents of this component.

removeComponent(Component)

Parameters

c

The component to be removed.

Removes the given component from this container.

removeComponent(int, int)

Parameters

x

Component's top-left corner's X-coordinate

y

Component's top-left corner's Y-coordinate

Removes a component specified with it's top-left corner coordinates from this grid.

setHeight(int)

Parameters

Height

of the grid

Set the height of the grid. The width can not be reduced if there are any areas that would be outside of the shrunk grid.

setWidth(int)

Parameters

width

New width of the grid.

Exceptions

OutOfBoundsException

if the one of the areas would exceed the bounds of the grid after the modification of the grid size.

Set the width of the grid. The width can not be reduced if there are any areas that would be outside of the shrunk grid.

space()

See Also
newLine()

Move cursor forwards by one. If the cursor goes out of the right grid border, move it to next line.