Package org.jitsi.util.swing
Class FitLayout
- java.lang.Object
-
- org.jitsi.util.swing.FitLayout
-
- All Implemented Interfaces:
LayoutManager
- Direct Known Subclasses:
VideoLayout
public class FitLayout extends Object implements LayoutManager
Represents a LayoutManager which centers the first Component within its Container and, if the preferred size of the Component is larger than the size of the Container, scales the former within the bounds of the latter while preserving the aspect ratio. FitLayout is appropriate for Containers which display a single image or video Component in its entirety for which preserving the aspect ratio is important.- Author:
- Lyubomir Marinov
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_HEIGHT_OR_WIDTHThe default height and width to be used by FitLayout and its extenders in order to avoid falling back to zero height and/or width.
-
Constructor Summary
Constructors Constructor Description FitLayout()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutComponent(String name, Component comp)Does nothing because this LayoutManager lays out only the first Component of the parent Container and thus doesn't need any String associations.protected ComponentgetComponent(Container parent)Gets the first Component of a specific Container if there is such a Component.protected voidlayoutComponent(Component component, Rectangle bounds, float alignmentX, float alignmentY)voidlayoutContainer(Container parent)protected voidlayoutContainer(Container parent, float componentAlignmentX)DimensionminimumLayoutSize(Container parent)DimensionpreferredLayoutSize(Container parent)Since this LayoutManager lays out only the first Component of the specified parent Container, the preferred size of the Container is the preferred size of the mentioned Component.voidremoveLayoutComponent(Component comp)Does nothing because this LayoutManager lays out only the first Component of the parent Container and thus doesn't need any String associations.
-
-
-
Field Detail
-
DEFAULT_HEIGHT_OR_WIDTH
protected static final int DEFAULT_HEIGHT_OR_WIDTH
The default height and width to be used by FitLayout and its extenders in order to avoid falling back to zero height and/or width. Introduced to mitigate issues arising from the fact that a Component zero height and/or width.- See Also:
- Constant Field Values
-
-
Method Detail
-
addLayoutComponent
public void addLayoutComponent(String name, Component comp)
Does nothing because this LayoutManager lays out only the first Component of the parent Container and thus doesn't need any String associations.- Specified by:
addLayoutComponentin interfaceLayoutManager
-
getComponent
protected Component getComponent(Container parent)
Gets the first Component of a specific Container if there is such a Component.- Parameters:
parent- the Container to retrieve the first Component of- Returns:
- the first Component of a specific Container if there is such a Component; otherwise, null
-
layoutComponent
protected void layoutComponent(Component component, Rectangle bounds, float alignmentX, float alignmentY)
-
layoutContainer
public void layoutContainer(Container parent)
- Specified by:
layoutContainerin interfaceLayoutManager
-
layoutContainer
protected void layoutContainer(Container parent, float componentAlignmentX)
-
minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)
- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
preferredLayoutSize
public Dimension preferredLayoutSize(Container parent)
Since this LayoutManager lays out only the first Component of the specified parent Container, the preferred size of the Container is the preferred size of the mentioned Component.- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(Component comp)
Does nothing because this LayoutManager lays out only the first Component of the parent Container and thus doesn't need any String associations.- Specified by:
removeLayoutComponentin interfaceLayoutManager
-
-