org.argouml.swingext
Class LabelledLayout

java.lang.Object
  |
  +--org.argouml.swingext.LabelledLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.io.Serializable

public class LabelledLayout
extends java.lang.Object
implements java.awt.LayoutManager, java.io.Serializable

This layout manager lines up components in 2 columns. All JLabels are the first column and any component the JLabel is registered with is in a second column next to the label.

The height of each row is the largest minimum height of the 2 components.

The width of the first column is the largest preferred width of the 2 components.

The width of the 2nd column is any left over space or the maximum width of the component, whichever is the least.

LabelledLayout can show multiple panels of label/component pairs. The seperation of these panels is indicated by adding a Seperator component to the parent component. Labelled layout starts a new panel when detecting this Seperator.

See Also:
Serialized Form

Field Summary
private  int _hgap
          This is the horizontal gap (in pixels) which specifies the space between columns.
private  boolean _ignoreSplitters
           
private  int _labelWidth
          The required cell width of the labels column
private  int _largestHeight
          The height of the child component with the largest height
private  int _largestWidth
          The width of the child component with the largest width
private  int _vgap
          This is the vertical gap (in pixels) which specifies the space between rows.
 
Constructor Summary
LabelledLayout()
          Construct a new LabelledLayout.
LabelledLayout(boolean ignoreSplitters)
          Construct a new LabelledLayout.
LabelledLayout(int hgap, int vgap)
          Construct a new horizontal LabelledLayout with the specified cell spacing.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
private  int calculateHeight(int parentHeight, int totalHeight, int unknownHeightsLeft, java.awt.Component childComp)
           
 int getHgap()
           
private  int getSectionCount(java.awt.Container parent)
          Determine the number of sections.
private  int getSectionWidth(java.awt.Container parent, int sectionCount)
          Determine the width of each section from the section count.
static Seperator getSeperator()
           
private  int getUsableWidth(java.awt.Container parent)
          Determine the usable width of the parent.
 int getVgap()
           
 void layoutContainer(java.awt.Container parent)
           
private  void layoutSection(java.awt.Container parent, int sectionX, int sectionWidth, java.util.ArrayList components)
          Layout a single section
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
           
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Determines the preferred size of the container argument using this labelled layout.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component with the specified name from the layout.
 void setHgap(int hgap)
           
 void setVgap(int vgap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_hgap

private int _hgap
This is the horizontal gap (in pixels) which specifies the space between columns. They can be changed at any time. This should be a non negative integer.

See Also:
getHgap(), setHgap(int)

_vgap

private int _vgap
This is the vertical gap (in pixels) which specifies the space between rows. They can be changed at any time. This should be a non negative integer.

See Also:
getVgap(), setVgap(int)

_largestHeight

private int _largestHeight
The height of the child component with the largest height


_largestWidth

private int _largestWidth
The width of the child component with the largest width


_labelWidth

private int _labelWidth
The required cell width of the labels column


_ignoreSplitters

private boolean _ignoreSplitters
Constructor Detail

LabelledLayout

public LabelledLayout()
Construct a new LabelledLayout.


LabelledLayout

public LabelledLayout(boolean ignoreSplitters)
Construct a new LabelledLayout.


LabelledLayout

public LabelledLayout(int hgap,
                      int vgap)
Construct a new horizontal LabelledLayout with the specified cell spacing.

Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component with the specified name to the layout. This is included to satisfy the LayoutManager interface but is not actually used in this layout implementation.

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

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component with the specified name from the layout. This is included to satisfy the LayoutManager interface but is not actually used in this layout implementation.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the name of the component

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Determines the preferred size of the container argument using this labelled layout. The preferred size is that all child components are in one section at their own preferred size with gaps and border indents.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

layoutContainer

public void layoutContainer(java.awt.Container parent)
Specified by:
layoutContainer in interface java.awt.LayoutManager

getSectionCount

private int getSectionCount(java.awt.Container parent)
Determine the number of sections. There is only ever one section if oriented vertically. If oriented horizontally the number of sections is deduced from the number of Splitters in the parent container.


getSectionWidth

private int getSectionWidth(java.awt.Container parent,
                            int sectionCount)
Determine the width of each section from the section count. This is the working width minus the gaps between sections. This result is then divided equally by the section count.


getUsableWidth

private int getUsableWidth(java.awt.Container parent)
Determine the usable width of the parent. This is the full width minus any borders.


layoutSection

private void layoutSection(java.awt.Container parent,
                           int sectionX,
                           int sectionWidth,
                           java.util.ArrayList components)
Layout a single section


calculateHeight

private int calculateHeight(int parentHeight,
                            int totalHeight,
                            int unknownHeightsLeft,
                            java.awt.Component childComp)

getSeperator

public static Seperator getSeperator()

getHgap

public int getHgap()

setHgap

public void setHgap(int hgap)

getVgap

public int getVgap()

setVgap

public void setVgap(int vgap)


ArgoUML © 1996-2004 (20040306)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook