com.vaadin.client
Class LayoutManager
java.lang.Object
com.vaadin.client.LayoutManager
- Direct Known Subclasses:
- LayoutManagerIE8
public class LayoutManager
- extends java.lang.Object
|
Method Summary |
void |
addElementResizeListener(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 |
getBorderBottom(Element element)
Gets the bottom border of the given element, provided that it has been
measured. |
int |
getBorderHeight(Element element)
Gets the border height (top border + bottom border) of the given element,
provided that it has been measured. |
int |
getBorderLeft(Element element)
Gets the left border of the given element, provided that it has been
measured. |
int |
getBorderRight(Element element)
Gets the right border of the given element, provided that it has been
measured. |
int |
getBorderTop(Element element)
Gets the top border of the given element, provided that it has been
measured. |
int |
getBorderWidth(Element element)
Gets the border width (left border + right border) of the given element,
provided that it has been measured. |
protected ApplicationConnection |
getConnection()
Returns the application connection for this layout manager. |
int |
getInnerHeight(Element element)
Gets the inner height (excluding margins, paddings and borders) of the
given element, provided that it has been measured. |
int |
getInnerWidth(Element element)
Gets the inner width (excluding margins, paddings and borders) of the
given element, provided that it has been measured. |
int |
getMarginBottom(Element element)
Gets the bottom margin of the given element, provided that it has been
measured. |
int |
getMarginHeight(Element element)
Gets the combined top & bottom margin of the given element, provided that
they have been measured. |
int |
getMarginLeft(Element element)
Gets the left margin of the given element, provided that it has been
measured. |
int |
getMarginRight(Element element)
Gets the right margin of the given element, provided that it has been
measured. |
int |
getMarginTop(Element element)
Gets the top margin of the given element, provided that it has been
measured. |
int |
getMarginWidth(Element element)
Gets the combined left & right margin of the given element, provided that
they have been measured. |
protected MeasuredSize |
getMeasuredSize(Element element,
MeasuredSize defaultSize)
Gets the measured size for an element. |
int |
getOuterHeight(Element element)
Gets the outer height (including margins, paddings and borders) of the
given element, provided that it has been measured. |
int |
getOuterWidth(Element element)
Gets the outer width (including margins, paddings and borders) of the
given element, provided that it has been measured. |
int |
getPaddingBottom(Element element)
Gets the bottom padding of the given element, provided that it has been
measured. |
int |
getPaddingHeight(Element element)
Gets the padding height (top padding + bottom padding) of the given
element, provided that it has been measured. |
int |
getPaddingLeft(Element element)
Gets the left padding of the given element, provided that it has been
measured. |
int |
getPaddingRight(Element element)
Gets the right padding of the given element, provided that it has been
measured. |
int |
getPaddingTop(Element element)
Gets the top padding of the given element, provided that it has been
measured. |
int |
getPaddingWidth(Element element)
Gets the padding width (left padding + right padding) of the given
element, provided that it has been measured. |
boolean |
isLayoutRunning()
|
void |
layoutLater()
|
void |
layoutNow()
|
protected void |
performBrowserLayoutHacks()
Called once per iteration in the layout loop before size calculations so
different browsers quirks can be handled. |
void |
registerDependency(ManagedLayout owner,
Element element)
Registers that a ManagedLayout is depending on the size of an Element. |
void |
removeElementResizeListener(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(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 |
setNeedsMeasureRecursively(ComponentConnector component)
Informs this LayoutManager that some sizes in a component hierarchy 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,
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 |
LayoutManager
public LayoutManager()
setConnection
public void setConnection(ApplicationConnection connection)
getConnection
protected ApplicationConnection getConnection()
- Returns the application connection for this layout manager.
- Returns:
- 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,
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 elementelement - the Element that should be measured
setMeasuredSize
protected void setMeasuredSize(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 tomeasuredSize - the measured size to attach to the element. If
null, any previous measured size is removed.
getMeasuredSize
protected MeasuredSize getMeasuredSize(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 fordefaultSize - 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,
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 elementelement - the Element that that no longer needs to be measured- See Also:
registerDependency(ManagedLayout, Element)
isLayoutRunning
public boolean isLayoutRunning()
layoutLater
public void layoutLater()
layoutNow
public void layoutNow()
performBrowserLayoutHacks
protected void performBrowserLayoutHacks()
- Called once per iteration in the layout loop before size calculations so
different browsers quirks can be handled. Mainly this is currently for
the IE8 permutation.
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.
This method should not be invoked during a layout phase since it only
controls what will happen in the beginning of the next phase. If you want
to explicitly cause some layout to be considered in an ongoing layout
phase, you should use setNeedsMeasure(ComponentConnector)
instead.
- 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).
This method should not be invoked during a layout phase since it only
controls what will happen in the beginning of the next phase. If you want
to explicitly cause some layout to be considered in an ongoing layout
phase, you should use setNeedsMeasure(ComponentConnector)
instead.
- 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).
This method should not be invoked during a layout phase since it only
controls what will happen in the beginning of the next phase. If you want
to explicitly cause some layout to be considered in an ongoing layout
phase, you should use setNeedsMeasure(ComponentConnector)
instead.
- Parameters:
layout - the managed layout that should be layouted
getOuterHeight
public final int getOuterHeight(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
-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(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
-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(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
-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(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
-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(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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.
getBorderTop
public int getBorderTop(Element element)
- Gets the top border of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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 border of the element in pixels.
getBorderLeft
public int getBorderLeft(Element element)
- Gets the left border of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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 border of the element in pixels.
getBorderBottom
public int getBorderBottom(Element element)
- Gets the bottom border of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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 border of the element in pixels.
getBorderRight
public int getBorderRight(Element element)
- Gets the right border of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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 border of the element in pixels.
getPaddingWidth
public int getPaddingWidth(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:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the top padding of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the left padding of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the bottom padding of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the right padding of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the top margin of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the right margin of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the bottom margin of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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(Element element)
- Gets the left margin of the given element, provided that it has been
measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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.
getMarginHeight
public int getMarginHeight(Element element)
- Gets the combined top & bottom margin of the given element, provided that
they have been measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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 margin for
- Returns:
- the measured top+bottom margin of the element in pixels.
getMarginWidth
public int getMarginWidth(Element element)
- Gets the combined left & right margin of the given element, provided that
they have been measured. These elements are guaranteed to be measured:
- ManagedLayotus and their child Connectors
- Elements for which there is at least one ElementResizeListener
- Elements for which at least one ManagedLayout has registered a
dependency
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 margin for
- Returns:
- the measured left+right 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 reportedouterHeight - 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 reportedassignedHeight - 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 reportedassignedWidth - 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 reportedouterWidth - the new outer width (including margins, borders and paddings)
of the component in pixels
addElementResizeListener
public void addElementResizeListener(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 changeslistener - an ElementResizeListener that will be informed whenever the
size of the target element has changed
removeElementResizeListener
public void removeElementResizeListener(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 addedlistener - 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. This method should be used whenever the size of an individual
component 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.
To set an entire component hierarchy to be measured, use
setNeedsMeasureRecursively(ComponentConnector) instead.
If there is no upcoming layout phase, a new layout phase is scheduled.
- Parameters:
component - the component whose size might have changed.
setNeedsMeasureRecursively
public void setNeedsMeasureRecursively(ComponentConnector component)
- Informs this LayoutManager that some sizes in a component hierarchy might
have changed. This method should be used whenever the size of any child
component might have changed from outside of Vaadin's normal update
phase, e.g. when a CSS class name related to sizing has been changed.
To set a single component to be measured, use
setNeedsMeasure(ComponentConnector) instead.
If there is no upcoming layout phase, a new layout phase is scheduled.
- Parameters:
component - the component at the root of the component hierarchy to
measure- Since:
- 7.2
setEverythingNeedsMeasure
public void setEverythingNeedsMeasure()
cleanMeasuredSizes
protected void cleanMeasuredSizes()
- Clean measured sizes which are no longer needed. Only for IE8.
Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.