kirk.gui
Class LineLayout

java.lang.Object
  |
  +--kirk.gui.LineLayout
All Implemented Interfaces:
java.awt.LayoutManager

public class LineLayout
extends java.lang.Object
implements java.awt.LayoutManager

A custom LayoutManager that lays out components like a vertical FlowLayout that does not do multiple columns. Each Component is as high as it's preferred size, and as width as the container minus insets minus gaps, or as width as it prefers to be if it's maximum value is smaller.

Version:
1
Author:
Berend "Kirk" Wouda

Field Summary
protected  int horizontalgap
          The horizontal gap.
protected  int verticalgap
          The vertical gap.
 
Constructor Summary
LineLayout()
          Constructs a new LineLayout.
LineLayout(int verticalgap)
          Constructs a new LineLayout with the given value for the vertical gap, and the default value for the horizontal gap.
LineLayout(int horizontalgap, int verticalgap)
          Constructs a new LineLayout with the given values for the gaps.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Called by a Container that has this LayoutManager as LayoutManager.
 int getHorizontalGap()
          Returns the horizontal gap.
 int getVerticalGap()
          Returns the vertical gap.
 void layoutContainer(java.awt.Container parent)
          Lays out the given container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Returns the minimum size of the container if it get's layed out by this LayoutManager.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Returns the preferred size of the container if it get's layed out by this LayoutManager.
 void removeLayoutComponent(java.awt.Component comp)
          Called by a Container that has this LayoutManager as LayoutManager.
 void setHorizontalGap(int horizontalgap)
          Sets the horizontal gap.
 void setVerticalGap(int verticalgap)
          Sets the vertical gap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

horizontalgap

protected int horizontalgap
The horizontal gap.


verticalgap

protected int verticalgap
The vertical gap.

Constructor Detail

LineLayout

public LineLayout(int horizontalgap,
                  int verticalgap)
Constructs a new LineLayout with the given values for the gaps.


LineLayout

public LineLayout(int verticalgap)
Constructs a new LineLayout with the given value for the vertical gap, and the default value for the horizontal gap.


LineLayout

public LineLayout()
Constructs a new LineLayout. Use the default values for the gaps.

Method Detail

getHorizontalGap

public int getHorizontalGap()
Returns the horizontal gap.

Returns:
The size of the horizontal gap.

setHorizontalGap

public void setHorizontalGap(int horizontalgap)
Sets the horizontal gap.


getVerticalGap

public int getVerticalGap()
Returns the vertical gap.

Returns:
The size of the vertical gap.

setVerticalGap

public void setVerticalGap(int verticalgap)
Sets the vertical gap.


addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Called by a Container that has this LayoutManager as LayoutManager. It should add the given component to this LayoutManager, however that is not neccesary. We use the same approach as FlowLayout.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
See Also:
LayoutManager.addLayoutComponent(java.lang.String, java.awt.Component), FlowLayout

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Called by a Container that has this LayoutManager as LayoutManager. It should remove the given component from this LayoutManager, however that is not neccesary. We use the same approach as FlowLayout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
See Also:
LayoutManager.removeLayoutComponent(java.awt.Component), FlowLayout

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Returns the preferred size of the container if it get's layed out by this LayoutManager.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - The Container that the preferred size is wanted of.
See Also:
LayoutManager.preferredLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Returns the minimum size of the container if it get's layed out by this LayoutManager.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - The Container that the minimum size is wanted of.
See Also:
LayoutManager.minimumLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the given container.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - The Container to be layed out.
See Also:
LayoutManager.layoutContainer(java.awt.Container)