Class SwingPercentLayoutAdapter
- java.lang.Object
-
- net.sf.jguiraffe.gui.platform.swing.layout.SwingPercentLayoutAdapter
-
- All Implemented Interfaces:
LayoutManager,LayoutManager2,Serializable,net.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter
public class SwingPercentLayoutAdapter extends Object implements LayoutManager2, net.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter, Serializable
Implementation of a Swing-specific adapter class for the percent layout manager.
This class implements the percent layout manager for swing. It implements the
LayoutManager2interface and can be used as a standard Swing layout.- Version:
- $Id: SwingPercentLayoutAdapter.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SwingPercentLayoutAdapter(net.sf.jguiraffe.gui.layout.PercentLayoutBase percentLayout)Creates a new instance ofSwingPercentLayouAdaptertand sets the associated percent layout.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutComponent(Component comp, Object constraints)Adds a component to this layout.voidaddLayoutComponent(String name, Component comp)Adds a component to this layout manager using the given name as constraints object.ObjectgetComponent(int index)Returns the component with the given index.intgetComponentCount()Returns the number of components in this layout.ObjectgetConstraints(int index)Returns the constraints for the component with the given index.floatgetLayoutAlignmentX(Container container)Returns the layout alignment in X direction.floatgetLayoutAlignmentY(Container container)Returns the layout alignment in Y direction.intgetMinimumComponentSize(Object component, boolean vert)Returns the minimum size of the specified component in the given axis.net.sf.jguiraffe.gui.layout.PercentLayoutBasegetPercentLayout()Returns a reference to the associated percent layout object.intgetPreferredComponentSize(Object component, boolean vert)Returns the preferred size of the specified component in the given axis.net.sf.jguiraffe.gui.layout.UnitSizeHandlergetSizeHandler()Returns the size handler used by this layout.voidinvalidateLayout(Container container)Invalidates this layout.voidlayoutContainer(Container container)Determines the coordinates and sizes of all components that belong to this layout.DimensionmaximumLayoutSize(Container container)Returns the maximum layout size.DimensionminimumLayoutSize(Container container)Returns the minimum size of this layout.DimensionpreferredLayoutSize(Container container)Returns the preferred size of this layout.voidremoveLayoutComponent(Component c)Removes the specified component from the layout manager.voidsetComponentBounds(Object component, Rectangle bounds)Initializes the bounds for the specified component.
-
-
-
Constructor Detail
-
SwingPercentLayoutAdapter
public SwingPercentLayoutAdapter(net.sf.jguiraffe.gui.layout.PercentLayoutBase percentLayout)
Creates a new instance ofSwingPercentLayouAdaptertand sets the associated percent layout.- Parameters:
percentLayout- the percent layout object (must not be null)- Throws:
IllegalArgumentException- if thePercentLayoutBaseobject is null
-
-
Method Detail
-
getPercentLayout
public net.sf.jguiraffe.gui.layout.PercentLayoutBase getPercentLayout()
Returns a reference to the associated percent layout object.- Returns:
- the percent layout object
-
getLayoutAlignmentX
public float getLayoutAlignmentX(Container container)
Returns the layout alignment in X direction.- Specified by:
getLayoutAlignmentXin interfaceLayoutManager2- Parameters:
container- the associated container- Returns:
- the layout alignment in X direction
-
getLayoutAlignmentY
public float getLayoutAlignmentY(Container container)
Returns the layout alignment in Y direction.- Specified by:
getLayoutAlignmentYin interfaceLayoutManager2- Parameters:
container- the associated container- Returns:
- the layout alignment in Y direction
-
invalidateLayout
public void invalidateLayout(Container container)
Invalidates this layout. Clears all cached values.- Specified by:
invalidateLayoutin interfaceLayoutManager2- Parameters:
container- the associated container
-
maximumLayoutSize
public Dimension maximumLayoutSize(Container container)
Returns the maximum layout size. For this layout type there is no upper limit.- Specified by:
maximumLayoutSizein interfaceLayoutManager2- Parameters:
container- the container- Returns:
- the maximum layout size
-
addLayoutComponent
public void addLayoutComponent(Component comp, Object constraints)
Adds a component to this layout.- Specified by:
addLayoutComponentin interfaceLayoutManager2- Parameters:
comp- the component to addconstraints- the constraints
-
addLayoutComponent
public void addLayoutComponent(String name, Component comp)
Adds a component to this layout manager using the given name as constraints object.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
name- the namecomp- the component
-
removeLayoutComponent
public void removeLayoutComponent(Component c)
Removes the specified component from the layout manager.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
c- the component to remove
-
layoutContainer
public void layoutContainer(Container container)
Determines the coordinates and sizes of all components that belong to this layout.- Specified by:
layoutContainerin interfaceLayoutManager- Parameters:
container- the associated container
-
minimumLayoutSize
public Dimension minimumLayoutSize(Container container)
Returns the minimum size of this layout. For this layout type this equals the preferred layout size.- Specified by:
minimumLayoutSizein interfaceLayoutManager- Parameters:
container- the associated container- Returns:
- the minimum layout size
-
preferredLayoutSize
public Dimension preferredLayoutSize(Container container)
Returns the preferred size of this layout.- Specified by:
preferredLayoutSizein interfaceLayoutManager- Parameters:
container- the associated container- Returns:
- the preferred layout size
-
getSizeHandler
public net.sf.jguiraffe.gui.layout.UnitSizeHandler getSizeHandler()
Returns the size handler used by this layout. This happens to be a swing size handler.- Specified by:
getSizeHandlerin interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Returns:
- the size handler
-
getComponentCount
public int getComponentCount()
Returns the number of components in this layout.- Specified by:
getComponentCountin interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Returns:
- the number of components
-
getComponent
public Object getComponent(int index)
Returns the component with the given index.- Specified by:
getComponentin interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Parameters:
index- the index- Returns:
- the component with this index
-
getConstraints
public Object getConstraints(int index)
Returns the constraints for the component with the given index.- Specified by:
getConstraintsin interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Parameters:
index- the index- Returns:
- the constraints for the specified component
-
getMinimumComponentSize
public int getMinimumComponentSize(Object component, boolean vert)
Returns the minimum size of the specified component in the given axis.- Specified by:
getMinimumComponentSizein interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Parameters:
component- the componentvert- the flag for the axis- Returns:
- the minimum component size
-
getPreferredComponentSize
public int getPreferredComponentSize(Object component, boolean vert)
Returns the preferred size of the specified component in the given axis.- Specified by:
getPreferredComponentSizein interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Parameters:
component- the componentvert- the flag for the axis- Returns:
- the preferred component size
-
setComponentBounds
public void setComponentBounds(Object component, Rectangle bounds)
Initializes the bounds for the specified component.- Specified by:
setComponentBoundsin interfacenet.sf.jguiraffe.gui.layout.PercentLayoutPlatformAdapter- Parameters:
component- the componentbounds- the new bounds
-
-