com.itmill.toolkit.ui
Class AbstractOrderedLayout

java.lang.Object
  extended by com.itmill.toolkit.ui.AbstractComponent
      extended by com.itmill.toolkit.ui.AbstractComponentContainer
          extended by com.itmill.toolkit.ui.AbstractLayout
              extended by com.itmill.toolkit.ui.AbstractOrderedLayout
All Implemented Interfaces:
MethodEventSource, Paintable, Sizeable, VariableOwner, Component, ComponentContainer, Layout, Layout.AlignmentHandler, Layout.MarginHandler, Layout.SpacingHandler, EventListener
Direct Known Subclasses:
HorizontalLayout, OrderedLayout, VerticalLayout

public abstract class AbstractOrderedLayout
extends AbstractLayout
implements Layout.AlignmentHandler, Layout.SpacingHandler


Nested Class Summary
 
Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Layout
Layout.AlignmentHandler, Layout.MarginHandler, Layout.MarginInfo, Layout.SpacingHandler
 
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
 
Field Summary
protected  LinkedList<Component> components
          Custom layout slots containing the components.
 
Fields inherited from class com.itmill.toolkit.ui.AbstractLayout
margins
 
Fields inherited from interface com.itmill.toolkit.ui.Layout.AlignmentHandler
ALIGNMENT_BOTTOM, ALIGNMENT_HORIZONTAL_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP, ALIGNMENT_VERTICAL_CENTER
 
Fields inherited from interface com.itmill.toolkit.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
AbstractOrderedLayout()
           
 
Method Summary
 void addComponent(Component c)
          Add a component into this container.
 void addComponent(Component c, int index)
          Adds a component into indexed position in this container.
 void addComponentAsFirst(Component c)
          Adds a component into this container.
 Alignment getComponentAlignment(Component childComponent)
          Returns the current Alignment of given component.
 Iterator getComponentIterator()
          Gets the component container iterator for going trough all the components in the container.
 float getExpandRatio(Component component)
          Returns the expand ratio of given component.
 String getTag()
          Gets the component UIDL tag.
 boolean isSpacingEnabled()
           
 void paintContent(PaintTarget target)
          Paints the content of this component.
 void removeComponent(Component c)
          Removes the component from this container.
 void replaceComponent(Component oldComponent, Component newComponent)
          Replaces the component in the container with another one without changing position.
 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 setExpandRatio(Component component, float ratio)
           This method is used to control how excess space in layout is distributed among components.
 void setSpacing(boolean enabled)
          Enable spacing between child components within this layout.
 
Methods inherited from class com.itmill.toolkit.ui.AbstractLayout
getMargin, setMargin, setMargin, setMargin
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponentContainer
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeAllComponents, removeListener, removeListener, requestRepaintAll, setEnabled, setHeight, setWidth
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, addStyleName, changeVariables, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setWidth, setWidth, setWidthUnits, setVisible
 
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, removeAllComponents, removeListener, removeListener, requestRepaintAll
 
Methods inherited from interface com.itmill.toolkit.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.itmill.toolkit.terminal.Paintable
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId
 
Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner
changeVariables, isImmediate
 
Methods inherited from interface com.itmill.toolkit.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits
 

Field Detail

components

protected LinkedList<Component> components
Custom layout slots containing the components.

Constructor Detail

AbstractOrderedLayout

public AbstractOrderedLayout()
Method Detail

getTag

public String getTag()
Gets the component UIDL tag.

Specified by:
getTag in class AbstractLayout
Returns:
the Component UIDL tag as string.

addComponent

public void addComponent(Component c)
Add a component into this container. The component is added to the right or under the previous component.

Specified by:
addComponent in interface ComponentContainer
Overrides:
addComponent in class AbstractComponentContainer
Parameters:
c - the component to be added.
See Also:
ComponentContainer.addComponent(Component)

addComponentAsFirst

public void addComponentAsFirst(Component c)
Adds a component into this container. The component is added to the left or on top of the other components.

Parameters:
c - the component to be added.

addComponent

public void addComponent(Component c,
                         int index)
Adds a component into indexed position in this container.

Parameters:
c - the component to be added.
index - the Index of the component position. The components currently in and after the position are shifted forwards.

removeComponent

public void removeComponent(Component c)
Removes the component from this container.

Specified by:
removeComponent in interface ComponentContainer
Overrides:
removeComponent in class AbstractComponentContainer
Parameters:
c - the component to be removed.
See Also:
ComponentContainer.removeComponent(Component)

getComponentIterator

public Iterator getComponentIterator()
Gets the component container iterator for going trough all the components in the container.

Specified by:
getComponentIterator in interface ComponentContainer
Returns:
the Iterator of the components inside the container.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

Overrides:
paintContent in class AbstractLayout
Parameters:
target - the Paint Event.
Throws:
PaintException - if the paint operation failed.

replaceComponent

public void replaceComponent(Component oldComponent,
                             Component newComponent)
Description copied from interface: ComponentContainer
Replaces the component in the container with another one without changing position.

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.

Specified by:
replaceComponent in interface ComponentContainer
Parameters:
oldComponent - the old component that will be replaced.
newComponent - the new component to be replaced.

setComponentAlignment

public void setComponentAlignment(Component childComponent,
                                  int horizontalAlignment,
                                  int verticalAlignment)
Description copied from interface: Layout.AlignmentHandler
Set alignment for one contained component in this layout. Alignment is calculated as a bit mask of the two passed values.

Specified by:
setComponentAlignment in interface Layout.AlignmentHandler
Parameters:
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.

setComponentAlignment

public void setComponentAlignment(Component childComponent,
                                  Alignment alignment)
Description copied from interface: Layout.AlignmentHandler
Set alignment for one contained component in this layout. Use predefined alignments from Alignment class. Example: layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);

Specified by:
setComponentAlignment in interface Layout.AlignmentHandler
Parameters:
childComponent - the component to align within it's layout cell.
alignment - the Alignment value to be set

getComponentAlignment

public Alignment getComponentAlignment(Component childComponent)
Description copied from interface: Layout.AlignmentHandler
Returns the current Alignment of given component.

Specified by:
getComponentAlignment in interface Layout.AlignmentHandler
Returns:
the Alignment

setSpacing

public void setSpacing(boolean enabled)
Description copied from interface: Layout.SpacingHandler
Enable spacing between child components within this layout.

NOTE: This will only affect spaces between components, not also all around spacing of the layout (i.e. do not mix this with HTML Table elements cellspacing-attribute). Use Layout.setMargin(boolean) to add extra space around the layout.

Specified by:
setSpacing in interface Layout.SpacingHandler

isSpacingEnabled

public boolean isSpacingEnabled()
Specified by:
isSpacingEnabled in interface Layout.SpacingHandler
Returns:
true if spacing, layout leaves space between components

setExpandRatio

public void setExpandRatio(Component component,
                           float ratio)

This method is used to control how excess space in layout is distributed among components. Excess space may exist if layout is sized and contained non relatively sized components don't consume all available space.

Example how to distribute 1:3 (33%) for component1 and 2:3 (67%) for component2 : layout.setExpandRatio(component1, 1);
layout.setExpandRatio(component2, 2);

If no ratios have been set, the excess space is distributed evenly among all components.

Note, that width or height (depending on orientation) needs to be defined for this method to have any effect.

Parameters:
component - the component in this layout which expand ratio is to be set
ratio -
See Also:
Sizeable

getExpandRatio

public float getExpandRatio(Component component)
Returns the expand ratio of given component.

Parameters:
component - which expand ratios is requested
Returns:
expand ratio of given component, 0.0f by default

setComponentAlignment

public void setComponentAlignment(Component component,
                                  String alignment)


Copyright © 2000-2009 IT Mill Ltd. All Rights Reserved.