|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.terminal.Identifiable
com.itmill.toolkit.ui.AbstractComponent
com.itmill.toolkit.ui.AbstractComponentContainer
com.itmill.toolkit.ui.GridLayout
public 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 GridLayout.OverlapsException is thrown. Adding component with cursor
automatically extends the grid by increasing the grid height.
| Nested Class Summary | |
|---|---|
class |
GridLayout.Area
This class defines an area on a grid. |
class |
GridLayout.OutOfBoundsException
An Exception object which is thrown when an area exceeds
the bounds of the grid. |
class |
GridLayout.OverlapsException
An Exception object which is thrown when two Items occupy
the same space on a grid. |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.ComponentContainer |
|---|
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component |
|---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
| Constructor Summary | |
|---|---|
GridLayout()
Constructs an empty grid layout that is extended as needed. |
|
GridLayout(int width,
int height)
Constructor for grid of given size. |
|
| Method Summary | |
|---|---|
void |
addComponent(Component component)
Adds the component into this container to the cursor position. |
void |
addComponent(Component c,
int x,
int y)
Adds the component into this container to coordinates x1,y1 (NortWest corner of the area.) |
void |
addComponent(Component component,
int x1,
int y1,
int x2,
int y2)
Adds a component with a specified area to the grid. |
Iterator |
getComponentIterator()
Gets an Iterator to the component container contents. |
int |
getCursorX()
Gets the current cursor x-position. |
int |
getCursorY()
Gets the current cursor y-position. |
int |
getHeight()
Gets the height of the grid. |
String |
getTag()
Gets the components UIDL tag. |
int |
getWidth()
Get the width of the grids. |
void |
newLine()
Force the next component to be added to the beginning of the next line. |
void |
paintContent(PaintTarget target)
Paints the contents of this component. |
void |
removeAllComponents()
Removes all components from the container. |
void |
removeComponent(Component component)
Removes the given component from this container. |
void |
removeComponent(int x,
int y)
Removes the component specified with it's top-left corner coordinates from this grid. |
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replaces the component in the container with another one without changing position. |
void |
setHeight(int height)
Sets the height of the grid. |
void |
setWidth(int width)
Sets the width of the grid. |
void |
space()
Moves the cursor forwards by one. |
| Methods inherited from class com.itmill.toolkit.ui.AbstractComponentContainer |
|---|
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeListener, removeListener |
| Methods inherited from class com.itmill.toolkit.terminal.Identifiable |
|---|
getDebugId, getUIID, setDebugId, setUIID |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.itmill.toolkit.ui.ComponentContainer |
|---|
addListener, addListener, moveComponentsFrom, removeListener, removeListener |
| Methods inherited from interface com.itmill.toolkit.ui.Component |
|---|
addListener, attach, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isReadOnly, isVisible, removeListener, setEnabled, setParent, setReadOnly, setStyle, setVisible |
| Methods inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
addListener, paint, removeListener, requestRepaint, requestRepaintRequests |
| Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner |
|---|
changeVariables, dependsOn, getDirectDependencies, isImmediate, removeDirectDependency |
| Constructor Detail |
|---|
public GridLayout(int width,
int height)
width - the Width of the grid.height - the Height of the grid.public GridLayout()
| Method Detail |
|---|
public void addComponent(Component component,
int x1,
int y1,
int x2,
int y2)
throws GridLayout.OverlapsException,
GridLayout.OutOfBoundsException
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
GridLayout.OverlapsException is thrown.
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.
GridLayout.OverlapsException - if the new component overlaps with any of the components
already in the grid.
GridLayout.OutOfBoundsException - if the coordinates are outside of the grid area.
public void addComponent(Component c,
int x,
int y)
c - the component to be added.x - the X-coordinate.y - the Y-coordinate.public void newLine()
space()public void space()
newLine()public void addComponent(Component component)
addComponent in interface ComponentContaineraddComponent in class AbstractComponentContainerc - the component to be added.ComponentContainer.addComponent(Component)public void removeComponent(Component component)
removeComponent in interface ComponentContainerremoveComponent in class AbstractComponentContainerc - the component to be removed.ComponentContainer.removeComponent(Component)
public void removeComponent(int x,
int y)
x - the Component's top-left corner's X-coordinate.y - the Component's top-left corner's Y-coordinate.public Iterator getComponentIterator()
getComponentIterator in interface ComponentContainer
public void paintContent(PaintTarget target)
throws PaintException
paintContent in class AbstractComponenttarget - the Paint Event.
PaintException - if the paint operation failed.public String getTag()
getTag in class AbstractComponentAbstractComponent.getTag()public void setWidth(int width)
width - the New width of the grid.public final int getWidth()
public void setHeight(int height)
height - the height of the grid.public final int getHeight()
public int getCursorX()
public int getCursorY()
public void replaceComponent(Component oldComponent,
Component newComponent)
ComponentContainerThis method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.
replaceComponent in interface ComponentContaineroldComponent - the old component that will be replaced.newComponent - the new component to be replaced.public void removeAllComponents()
AbstractComponentContainer
removeAllComponents in interface ComponentContainerremoveAllComponents in class AbstractComponentContainer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||