gate.swing
Class MenuLayout

java.lang.Object
  extended by gate.swing.MenuLayout
All Implemented Interfaces:
LayoutManager

public class MenuLayout
extends Object
implements LayoutManager

A layout designed to allow Java menus to make better use of the screen real-estate. It will lay out the menu components in columns going from top to bottom and from left to right.


Constructor Summary
MenuLayout()
           
 
Method Summary
 void addLayoutComponent(String name, Component comp)
          Adds the specified component to the layout.
protected  GraphicsConfiguration findGraphicsConfiguration(Component target)
          Find the graphics configuration for the target popup (useful in case of multiple screens).
 int getColumnForComponentIndex(int index)
           
protected  Dimension getCompositeSize(Container target, Dimension[] componentSizes)
          Calculates the size of the target container given the sizes of the components.
 int getPreferredWidthForColumn(int index)
           
 void layoutContainer(Container target)
           
 Dimension minimumLayoutSize(Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
 Dimension preferredLayoutSize(Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuLayout

public MenuLayout()
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Adds the specified component to the layout. Not used by this class.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the name of the component
comp - the the component to be added

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the specified component from the layout. Not used by this class.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - the component to remove

preferredLayoutSize

public Dimension preferredLayoutSize(Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
target - the component which needs to be laid out
See Also:
Container, minimumLayoutSize(java.awt.Container)

getCompositeSize

protected Dimension getCompositeSize(Container target,
                                     Dimension[] componentSizes)
Calculates the size of the target container given the sizes of the components. If the doLayout is true it will also lay out the container. Used by minimumLayoutSize(java.awt.Container) and preferredLayoutSize(java.awt.Container).

Parameters:
target - the component which needs to be laid out
componentSizes - array of dimensions for each menu component
Returns:
a Dimension value.

findGraphicsConfiguration

protected GraphicsConfiguration findGraphicsConfiguration(Component target)
Find the graphics configuration for the target popup (useful in case of multiple screens).

Parameters:
target - the component for which the configuration needs to be found.
Returns:
a GraphicsConfiguration value.

minimumLayoutSize

public Dimension minimumLayoutSize(Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
target - the component which needs to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(Container target)
Specified by:
layoutContainer in interface LayoutManager

getColumnForComponentIndex

public int getColumnForComponentIndex(int index)

getPreferredWidthForColumn

public int getPreferredWidthForColumn(int index)