com.vaadin.terminal.gwt.client
Class LayoutManager

java.lang.Object
  extended by com.vaadin.terminal.gwt.client.LayoutManager
Direct Known Subclasses:
LayoutManagerIE8

public class LayoutManager
extends Object


Constructor Summary
LayoutManager()
           
 
Method Summary
 void addElementResizeListener(com.google.gwt.dom.client.Element element, ElementResizeListener listener)
          Adds a listener that will be notified whenever the size of a specific element changes.
protected  void cleanMeasuredSizes()
          Clean measured sizes which are no longer needed.
 void forceLayout()
           
static LayoutManager get(ApplicationConnection connection)
          Gets the layout manager associated with the given ApplicationConnection.
 int getBorderHeight(com.google.gwt.dom.client.Element element)
          Gets the border height (top border + bottom border) of the given element, provided that it has been measured.
 int getBorderWidth(com.google.gwt.dom.client.Element element)
          Gets the border width (left border + right border) of the given element, provided that it has been measured.
 int getInnerHeight(com.google.gwt.dom.client.Element element)
          Gets the inner height (excluding margins, paddings and borders) of the given element, provided that it has been measured.
 int getInnerWidth(com.google.gwt.dom.client.Element element)
          Gets the inner width (excluding margins, paddings and borders) of the given element, provided that it has been measured.
 int getMarginBottom(com.google.gwt.dom.client.Element element)
          Gets the bottom margin of the given element, provided that it has been measured.
 int getMarginLeft(com.google.gwt.dom.client.Element element)
          Gets the left margin of the given element, provided that it has been measured.
 int getMarginRight(com.google.gwt.dom.client.Element element)
          Gets the right margin of the given element, provided that it has been measured.
 int getMarginTop(com.google.gwt.dom.client.Element element)
          Gets the top margin of the given element, provided that it has been measured.
protected  MeasuredSize getMeasuredSize(com.google.gwt.dom.client.Element element, MeasuredSize defaultSize)
          Gets the measured size for an element.
 int getOuterHeight(com.google.gwt.dom.client.Element element)
          Gets the outer height (including margins, paddings and borders) of the given element, provided that it has been measured.
 int getOuterWidth(com.google.gwt.dom.client.Element element)
          Gets the outer width (including margins, paddings and borders) of the given element, provided that it has been measured.
 int getPaddingBottom(com.google.gwt.dom.client.Element element)
          Gets the bottom padding of the given element, provided that it has been measured.
 int getPaddingHeight(com.google.gwt.dom.client.Element element)
          Gets the padding height (top padding + bottom padding) of the given element, provided that it has been measured.
 int getPaddingLeft(com.google.gwt.dom.client.Element element)
          Gets the left padding of the given element, provided that it has been measured.
 int getPaddingRight(com.google.gwt.dom.client.Element element)
          Gets the right padding of the given element, provided that it has been measured.
 int getPaddingTop(com.google.gwt.dom.client.Element element)
          Gets the top padding of the given element, provided that it has been measured.
 int getPaddingWidth(com.google.gwt.dom.client.Element element)
          Gets the padding width (left padding + right padding) of the given element, provided that it has been measured.
 boolean isLayoutRunning()
           
 void layoutNow()
           
 void registerDependency(ManagedLayout owner, com.google.gwt.dom.client.Element element)
          Registers that a ManagedLayout is depending on the size of an Element.
 void removeElementResizeListener(com.google.gwt.dom.client.Element element, ElementResizeListener listener)
          Removes an element resize listener from the provided element.
 void reportHeightAssignedToRelative(ComponentConnector component, int assignedHeight)
          Registers the height reserved for a relatively sized component.
 void reportOuterHeight(ComponentConnector component, int outerHeight)
          Registers the outer height (including margins, borders and paddings) of a component.
 void reportOuterWidth(ComponentConnector component, int outerWidth)
          Registers the outer width (including margins, borders and paddings) of a component.
 void reportWidthAssignedToRelative(ComponentConnector component, int assignedWidth)
          Registers the width reserved for a relatively sized component.
 void setConnection(ApplicationConnection connection)
           
 void setEverythingNeedsMeasure()
           
protected  void setMeasuredSize(com.google.gwt.dom.client.Element element, MeasuredSize measuredSize)
          Assigns a measured size to an element.
 void setNeedsHorizontalLayout(ManagedLayout layout)
          Marks that a ManagedLayout should be layouted horizontally in the next layout phase even if none of the elements managed by the layout have been resized horizontally.
 void setNeedsLayout(ManagedLayout layout)
          Marks that a ManagedLayout should be layouted in the next layout phase even if none of the elements managed by the layout have been resized.
 void setNeedsMeasure(ComponentConnector component)
          Informs this LayoutManager that the size of a component might have changed.
 void setNeedsVerticalLayout(ManagedLayout layout)
          Marks that a ManagedLayout should be layouted vertically in the next layout phase even if none of the elements managed by the layout have been resized vertically.
 void unregisterDependency(ManagedLayout owner, com.google.gwt.dom.client.Element element)
          Registers that a ManagedLayout is no longer depending on the size of an Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayoutManager

public LayoutManager()
Method Detail

setConnection

public void setConnection(ApplicationConnection connection)

get

public static LayoutManager get(ApplicationConnection connection)
Gets the layout manager associated with the given ApplicationConnection.

Parameters:
connection - the application connection to get a layout manager for
Returns:
the layout manager associated with the provided application connection

registerDependency

public void registerDependency(ManagedLayout owner,
                               com.google.gwt.dom.client.Element element)
Registers that a ManagedLayout is depending on the size of an Element. This causes this layout manager to measure the element in the beginning of every layout phase and call the appropriate layout method of the managed layout if the size of the element has changed.

Parameters:
owner - the ManagedLayout that depends on an element
element - the Element that should be measured

setMeasuredSize

protected void setMeasuredSize(com.google.gwt.dom.client.Element element,
                               MeasuredSize measuredSize)
Assigns a measured size to an element. Method defined as protected to allow separate implementation for IE8.

Parameters:
element - the dom element to attach the measured size to
measuredSize - the measured size to attach to the element. If null, any previous measured size is removed.

getMeasuredSize

protected MeasuredSize getMeasuredSize(com.google.gwt.dom.client.Element element,
                                       MeasuredSize defaultSize)
Gets the measured size for an element. Method defined as protected to allow separate implementation for IE8.

Parameters:
element - The element to get measured size for
defaultSize - The size to return if no measured size could be found
Returns:
The measured size for the element or defaultSize

unregisterDependency

public void unregisterDependency(ManagedLayout owner,
                                 com.google.gwt.dom.client.Element element)
Registers that a ManagedLayout is no longer depending on the size of an Element.

Parameters:
owner - the ManagedLayout no longer depends on an element
element - the Element that that no longer needs to be measured
See Also:
registerDependency(ManagedLayout, Element)

isLayoutRunning

public boolean isLayoutRunning()

layoutNow

public void layoutNow()

forceLayout

public void forceLayout()

setNeedsLayout

public final void setNeedsLayout(ManagedLayout layout)
Marks that a ManagedLayout should be layouted in the next layout phase even if none of the elements managed by the layout have been resized.

Parameters:
layout - the managed layout that should be layouted

setNeedsHorizontalLayout

public final void setNeedsHorizontalLayout(ManagedLayout layout)
Marks that a ManagedLayout should be layouted horizontally in the next layout phase even if none of the elements managed by the layout have been resized horizontally. For SimpleManagedLayout which is always layouted in both directions, this has the same effect as setNeedsLayout(ManagedLayout).

Parameters:
layout - the managed layout that should be layouted

setNeedsVerticalLayout

public final void setNeedsVerticalLayout(ManagedLayout layout)
Marks that a ManagedLayout should be layouted vertically in the next layout phase even if none of the elements managed by the layout have been resized vertically. For SimpleManagedLayout which is always layouted in both directions, this has the same effect as setNeedsLayout(ManagedLayout).

Parameters:
layout - the managed layout that should be layouted

getOuterHeight

public final int getOuterHeight(com.google.gwt.dom.client.Element element)
Gets the outer height (including margins, paddings and borders) of the given element, provided that it has been measured. These elements are guaranteed to be measured: -1 is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured outer height (including margins, paddings and borders) of the element in pixels.

getOuterWidth

public final int getOuterWidth(com.google.gwt.dom.client.Element element)
Gets the outer width (including margins, paddings and borders) of the given element, provided that it has been measured. These elements are guaranteed to be measured: -1 is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured outer width (including margins, paddings and borders) of the element in pixels.

getInnerHeight

public final int getInnerHeight(com.google.gwt.dom.client.Element element)
Gets the inner height (excluding margins, paddings and borders) of the given element, provided that it has been measured. These elements are guaranteed to be measured: -1 is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured inner height (excluding margins, paddings and borders) of the element in pixels.

getInnerWidth

public final int getInnerWidth(com.google.gwt.dom.client.Element element)
Gets the inner width (excluding margins, paddings and borders) of the given element, provided that it has been measured. These elements are guaranteed to be measured: -1 is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured inner width (excluding margins, paddings and borders) of the element in pixels.

getBorderHeight

public final int getBorderHeight(com.google.gwt.dom.client.Element element)
Gets the border height (top border + bottom border) of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured border height (top border + bottom border) of the element in pixels.

getPaddingHeight

public int getPaddingHeight(com.google.gwt.dom.client.Element element)
Gets the padding height (top padding + bottom padding) of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured padding height (top padding + bottom padding) of the element in pixels.

getBorderWidth

public int getBorderWidth(com.google.gwt.dom.client.Element element)
Gets the border width (left border + right border) of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured border width (left border + right border) of the element in pixels.

getPaddingWidth

public int getPaddingWidth(com.google.gwt.dom.client.Element element)
Gets the padding width (left padding + right padding) of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured padding width (left padding + right padding) of the element in pixels.

getPaddingTop

public int getPaddingTop(com.google.gwt.dom.client.Element element)
Gets the top padding of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured top padding of the element in pixels.

getPaddingLeft

public int getPaddingLeft(com.google.gwt.dom.client.Element element)
Gets the left padding of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured left padding of the element in pixels.

getPaddingBottom

public int getPaddingBottom(com.google.gwt.dom.client.Element element)
Gets the bottom padding of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured bottom padding of the element in pixels.

getPaddingRight

public int getPaddingRight(com.google.gwt.dom.client.Element element)
Gets the right padding of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured right padding of the element in pixels.

getMarginTop

public int getMarginTop(com.google.gwt.dom.client.Element element)
Gets the top margin of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured top margin of the element in pixels.

getMarginRight

public int getMarginRight(com.google.gwt.dom.client.Element element)
Gets the right margin of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured right margin of the element in pixels.

getMarginBottom

public int getMarginBottom(com.google.gwt.dom.client.Element element)
Gets the bottom margin of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured bottom margin of the element in pixels.

getMarginLeft

public int getMarginLeft(com.google.gwt.dom.client.Element element)
Gets the left margin of the given element, provided that it has been measured. These elements are guaranteed to be measured: A negative number is returned if the element has not been measured. If 0 is returned, it might indicate that the element is not attached to the DOM.

Parameters:
element - the element to get the measured size for
Returns:
the measured left margin of the element in pixels.

reportOuterHeight

public void reportOuterHeight(ComponentConnector component,
                              int outerHeight)
Registers the outer height (including margins, borders and paddings) of a component. This can be used as an optimization by ManagedLayouts; by informing the LayoutManager about what size a component will have, the layout propagation can continue directly without first measuring the potentially resized elements.

Parameters:
component - the component for which the size is reported
outerHeight - the new outer height (including margins, borders and paddings) of the component in pixels

reportHeightAssignedToRelative

public void reportHeightAssignedToRelative(ComponentConnector component,
                                           int assignedHeight)
Registers the height reserved for a relatively sized component. This can be used as an optimization by ManagedLayouts; by informing the LayoutManager about what size a component will have, the layout propagation can continue directly without first measuring the potentially resized elements.

Parameters:
component - the relatively sized component for which the size is reported
assignedHeight - the inner height of the relatively sized component's parent element in pixels

reportWidthAssignedToRelative

public void reportWidthAssignedToRelative(ComponentConnector component,
                                          int assignedWidth)
Registers the width reserved for a relatively sized component. This can be used as an optimization by ManagedLayouts; by informing the LayoutManager about what size a component will have, the layout propagation can continue directly without first measuring the potentially resized elements.

Parameters:
component - the relatively sized component for which the size is reported
assignedWidth - the inner width of the relatively sized component's parent element in pixels

reportOuterWidth

public void reportOuterWidth(ComponentConnector component,
                             int outerWidth)
Registers the outer width (including margins, borders and paddings) of a component. This can be used as an optimization by ManagedLayouts; by informing the LayoutManager about what size a component will have, the layout propagation can continue directly without first measuring the potentially resized elements.

Parameters:
component - the component for which the size is reported
outerWidth - the new outer width (including margins, borders and paddings) of the component in pixels

addElementResizeListener

public void addElementResizeListener(com.google.gwt.dom.client.Element element,
                                     ElementResizeListener listener)
Adds a listener that will be notified whenever the size of a specific element changes. Adding a listener to an element also ensures that all sizes for that element will be available starting from the next layout phase.

Parameters:
element - the element that should be checked for size changes
listener - an ElementResizeListener that will be informed whenever the size of the target element has changed

removeElementResizeListener

public void removeElementResizeListener(com.google.gwt.dom.client.Element element,
                                        ElementResizeListener listener)
Removes an element resize listener from the provided element. This might cause this LayoutManager to stop tracking the size of the element if no other sources are interested in the size.

Parameters:
element - the element to which the element resize listener was previously added
listener - the ElementResizeListener that should no longer get informed about size changes to the target element.

setNeedsMeasure

public void setNeedsMeasure(ComponentConnector component)
Informs this LayoutManager that the size of a component might have changed. If there is no upcoming layout phase, a new layout phase is scheduled. This method should be used whenever a size might have changed from outside of Vaadin's normal update phase, e.g. when an icon has been loaded or when the user resizes some part of the UI using the mouse.

Parameters:
component - the component whose size might have changed.

setEverythingNeedsMeasure

public void setEverythingNeedsMeasure()

cleanMeasuredSizes

protected void cleanMeasuredSizes()
Clean measured sizes which are no longer needed. Only for IE8.



Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.