|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractComponentContainer
com.vaadin.ui.AbstractLayout
com.vaadin.ui.GridLayout
public class GridLayout
A container that consists of components with certain coordinates (cell position) 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
(column1,row1,column2,row2) 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
Gridlayout does not support laying components on top of each other. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout |
---|
Layout.AlignmentHandler, Layout.MarginHandler, Layout.MarginInfo, Layout.SpacingHandler |
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer |
---|
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener |
Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable |
---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Field Summary |
---|
Fields inherited from class com.vaadin.ui.AbstractLayout |
---|
margins |
Fields inherited from interface com.vaadin.ui.Layout.AlignmentHandler |
---|
ALIGNMENT_BOTTOM, ALIGNMENT_HORIZONTAL_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP, ALIGNMENT_VERTICAL_CENTER |
Fields inherited from interface com.vaadin.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
Constructor Summary | |
---|---|
GridLayout()
Constructs an empty grid layout that is extended as needed. |
|
GridLayout(int columns,
int rows)
Constructor for grid of given size (number of cells). |
Method Summary | |
---|---|
void |
addComponent(Component component)
Adds the component into this container to the cursor position. |
void |
addComponent(Component c,
int column,
int row)
Adds the component into this container to cells column1,row1 (NortWest corner of the area.) End coordinates (SouthEast corner of the area) are the same as column1,row1. |
void |
addComponent(Component component,
int column1,
int row1,
int column2,
int row2)
Adds a component with a specified area to the grid. |
void |
addListener(LayoutEvents.LayoutClickListener listener)
Add a click listener to the layout. |
void |
changeVariables(Object source,
Map variables)
Called when one or more variables handled by the implementing class are changed. |
float |
getColumnExpandRatio(int columnIndex)
Returns the expand ratio of given column |
int |
getColumns()
Get the number of columns in the grid. |
Component |
getComponent(int x,
int y)
Gets the Component at given index. |
Alignment |
getComponentAlignment(Component childComponent)
Returns the current Alignment of given component. |
GridLayout.Area |
getComponentArea(Component component)
Returns information about the area where given component is layed in the GridLayout. |
Iterator<Component> |
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. |
float |
getRowExpandRatio(int rowIndex)
Returns the expand ratio of given row. |
int |
getRows()
Get the number of rows in the grid. |
void |
insertRow(int row)
Inserts an empty row at the chosen position in the grid. |
boolean |
isSpacing()
|
boolean |
isSpacingEnabled()
Deprecated. |
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 column,
int row)
Removes the component specified with it's cell index. |
void |
removeListener(LayoutEvents.LayoutClickListener listener)
Remove a click listener from the layout. |
void |
removeRow(int row)
Removes row and all components in the row. |
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replaces the component in the container with another one without changing position. |
void |
setColumnExpandRatio(int columnIndex,
float ratio)
Sets the expand ratio of given column. |
void |
setColumns(int columns)
Sets the number of columns in the grid. |
void |
setComponentAlignment(Component childComponent,
Alignment alignment)
Set alignment for one contained component in this layout. |
void |
setComponentAlignment(Component childComponent,
int horizontalAlignment,
int verticalAlignment)
Set alignment for one contained component in this layout. |
void |
setComponentAlignment(Component component,
String alignment)
|
void |
setCursorX(int cursorX)
Sets the current cursor x-position. |
void |
setCursorY(int cursorY)
Sets the current cursor y-position. |
void |
setRowExpandRatio(int rowIndex,
float ratio)
Sets the expand ratio of given row. |
void |
setRows(int rows)
Sets the number of rows in the grid. |
void |
setSpacing(boolean enabled)
Enable spacing between child components within this layout. |
void |
space()
Moves the cursor forwards by one. |
Methods inherited from class com.vaadin.ui.AbstractLayout |
---|
getMargin, setMargin, setMargin, setMargin |
Methods inherited from class com.vaadin.ui.AbstractComponentContainer |
---|
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeListener, removeListener, requestRepaintAll, setEnabled, setHeight, setWidth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.ComponentContainer |
---|
addListener, addListener, moveComponentsFrom, removeListener, removeListener, requestRepaintAll |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, attach, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible |
Methods inherited from interface com.vaadin.terminal.Paintable |
---|
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId |
Methods inherited from interface com.vaadin.terminal.VariableOwner |
---|
isImmediate |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Constructor Detail |
---|
public GridLayout(int columns, int rows)
columns
- Number of columns in the grid.rows
- Number of rows in the grid.public GridLayout()
Method Detail |
---|
public void addComponent(Component component, int column1, int row1, int column2, int row2) 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 (column1, row1) and the lower right corner (column2, row2) 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.column1
- the column of the upper left corner of the area c
is supposed to occupy.row1
- the row of the upper left corner of the area c
is
supposed to occupy.column2
- the column of the lower right corner of the area
c
is supposed to occupy.row2
- the row 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 cells are outside the grid area.public void addComponent(Component c, int column, int row) throws GridLayout.OverlapsException, GridLayout.OutOfBoundsException
c
- the component to be added.column
- the column index.row
- the row index.
GridLayout.OverlapsException
- if the new component overlaps with any of the components
already in the grid.
GridLayout.OutOfBoundsException
- if the cell is outside the grid area.public void newLine()
space()
public void space()
newLine()
public void addComponent(Component component)
addComponent
in interface ComponentContainer
addComponent
in class AbstractComponentContainer
c
- the component to be added.ComponentContainer.addComponent(Component)
public void removeComponent(Component component)
removeComponent
in interface ComponentContainer
removeComponent
in class AbstractComponentContainer
c
- the component to be removed.ComponentContainer.removeComponent(Component)
public void removeComponent(int column, int row)
column
- the Component's column.row
- the Component's row.public Iterator<Component> getComponentIterator()
getComponentIterator
in interface ComponentContainer
public void paintContent(PaintTarget target) throws PaintException
paintContent
in class AbstractLayout
target
- the Paint Event.
PaintException
- if the paint operation failed.public Alignment getComponentAlignment(Component childComponent)
Layout.AlignmentHandler
getComponentAlignment
in interface Layout.AlignmentHandler
Alignment
public void setColumns(int columns)
columns
- the new number of columns in the grid.public final int getColumns()
public void setRows(int rows)
rows
- the new number of rows in the grid.public final int getRows()
public int getCursorX()
public void setCursorX(int cursorX)
cursorX
- public int getCursorY()
public void setCursorY(int cursorY)
cursorY
- 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.public void removeAllComponents()
AbstractComponentContainer
removeAllComponents
in interface ComponentContainer
removeAllComponents
in class AbstractComponentContainer
public void setComponentAlignment(Component childComponent, int horizontalAlignment, int verticalAlignment)
Layout.AlignmentHandler
setComponentAlignment
in interface Layout.AlignmentHandler
childComponent
- the component to align within it's layout cell.horizontalAlignment
- the horizontal alignment for the child component (left,
center, right). Use ALIGNMENT constants.verticalAlignment
- the vertical alignment for the child component (top,
center, bottom). Use ALIGNMENT constants.public void setComponentAlignment(Component childComponent, Alignment alignment)
Layout.AlignmentHandler
layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);
setComponentAlignment
in interface Layout.AlignmentHandler
childComponent
- the component to align within it's layout cell.alignment
- the Alignment value to be setpublic void setSpacing(boolean enabled)
Layout.SpacingHandler
NOTE: This will only affect the space between
components, not the space around all the components in the layout
(i.e. do not confuse this with the cellspacing attribute of a HTML
Table). Use Layout.setMargin(boolean)
to add space around the
layout.
See the reference manual for more information about CSS rules for defining the amount of spacing to use.
setSpacing
in interface Layout.SpacingHandler
enabled
- true if spacing should be turned on, false if it should be
turned off@Deprecated public boolean isSpacingEnabled()
isSpacingEnabled
in interface Layout.SpacingHandler
public boolean isSpacing()
isSpacing
in interface Layout.SpacingHandler
public void insertRow(int row)
row
- Number of the row the new row will be inserted beforepublic void removeRow(int row)
If the last row is removed then all remaining components will be removed and the grid will be reduced to one row. The cursor will be moved to the upper left cell of the grid.
row
- The row number to removepublic void setColumnExpandRatio(int columnIndex, float ratio)
By default excess space is distributed evenly.
Note, that width needs to be defined for this method to have any effect.
columnIndex
- ratio
- AbstractComponentContainer.setWidth(float, int)
public float getColumnExpandRatio(int columnIndex)
columnIndex
-
setColumnExpandRatio(int, float)
public void setRowExpandRatio(int rowIndex, float ratio)
By default excess space is distributed evenly.
Note, that height needs to be defined for this method to have any effect.
rowIndex
- ratio
- AbstractComponentContainer.setHeight(float, int)
public float getRowExpandRatio(int rowIndex)
rowIndex
-
setRowExpandRatio(int, float)
public Component getComponent(int x, int y)
x
- x-indexy
- y-index
public GridLayout.Area getComponentArea(Component component)
component
- the component whose area information is requested.
public void setComponentAlignment(Component component, String alignment)
public void changeVariables(Object source, Map variables)
VariableOwner
changeVariables
in interface VariableOwner
changeVariables
in class AbstractComponent
source
- the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.public void addListener(LayoutEvents.LayoutClickListener listener)
LayoutEvents.LayoutClickEvent
.
Use #removeListener(LayoutClickListener)
to remove the listener.
listener
- The listener to addpublic void removeListener(LayoutEvents.LayoutClickListener listener)
#addListener(LayoutClickListener)
.
listener
- The listener to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |