|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.ui.AbstractComponent | +--org.millstone.base.ui.AbstractComponentContainer | +--org.millstone.base.ui.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 inherited from class org.millstone.base.ui.ComponentContainer |
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener |
Nested classes inherited from class org.millstone.base.ui.Component |
Component.Event, Component.Listener |
Nested classes inherited from class org.millstone.base.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)
Add a component into this container to the cursor position. |
void |
addComponent(Component c,
int x,
int y)
Add 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. |
java.util.Iterator |
getComponentIterator()
Gets an Iterator to the component container contents. |
int |
getCursorX()
Get the current cursor x-position. |
int |
getCursorY()
Get the current cursor y-position. |
int |
getHeight()
Get the height of the grid. |
java.lang.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 |
removeComponent(Component component)
Removes the given component from this container. |
void |
removeComponent(int x,
int y)
Removes a component specified with it's top-left corner coordinates from this grid. |
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replace a component in the container with another one without changing position. |
void |
setHeight(int height)
Set the height of the grid. |
void |
setWidth(int width)
Set the width of the grid. |
void |
space()
Move cursor forwards by one. |
Methods inherited from class org.millstone.base.ui.AbstractComponentContainer |
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeAllComponents, removeListener, removeListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.millstone.base.ui.ComponentContainer |
addListener, addListener, moveComponentsFrom, removeAllComponents, removeListener, removeListener |
Methods inherited from interface org.millstone.base.ui.Component |
addListener, attach, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, setEnabled, setParent, setReadOnly, setStyle, setVisible |
Methods inherited from interface org.millstone.base.terminal.Paintable |
addListener, paint, removeListener, requestRepaint, requestRepaintRequests |
Methods inherited from interface org.millstone.base.terminal.VariableOwner |
changeVariables, dependsOn, getDirectDependencies, removeDirectDependency |
Constructor Detail |
public GridLayout(int width, int height)
width
- Width of the grid.height
- 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.
x1
- The X-coordinate of the upper left corner of the area
c
is supposed to occupyy1
- The Y-coordinate of the upper left corner of the area
c
is supposed to occupyx2
- The X-coordinate of the lower right corner of the area
c
is supposed to occupyy2
- 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
- X-coordinatey
- Y-coordinatepublic void newLine()
space()
public void space()
newLine()
public void addComponent(Component component)
addComponent
in interface ComponentContainer
addComponent
in class AbstractComponentContainer
component
- the component to be addedpublic void removeComponent(Component component)
removeComponent
in interface ComponentContainer
removeComponent
in class AbstractComponentContainer
component
- the component to be addedpublic void removeComponent(int x, int y)
x
- Component's top-left corner's X-coordinatey
- Component's top-left corner's Y-coordinatepublic java.util.Iterator getComponentIterator()
getComponentIterator
in interface ComponentContainer
public void paintContent(PaintTarget target) throws PaintException
paintContent
in class AbstractComponent
target
- target UIDL stream where the component should paint
itself to
PaintException
- The paint operation failed.public java.lang.String getTag()
getTag
in class AbstractComponent
AbstractComponent.getTag()
public void setWidth(int width)
width
- New width of the grid.
GridLayout.OutOfBoundsException
- if the one of the areas would exceed the
bounds of the grid after the modification of the grid size.public final int getWidth()
public void setHeight(int height)
public final int getHeight()
public int getCursorX()
public int getCursorY()
public void replaceComponent(Component oldComponent, Component newComponent)
ComponentContainer
This 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 ComponentContainer
oldComponent
- The old component that will be replaced.newComponent
- The new component to be replaced
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |