com.togethersoft.openapi.util.ui
Class StackLayout


public class StackLayout
implements LayoutManager

**************************************************************************
StackLayout is a LayoutManager that arranges components in a vertical
(or horizontal) strip aligning them at right, left or centered, and/or
filling them to take up any extra vertical or horizontal space.
Arrangement tags are provided by using the add(tag,component) form to
add components to the container.

The tag consists of one or more of the following, with the two forms applying
to horizontal or vertical dimension.


Positioning:
"Center" : centered horizontally & vertically (the default)
"Left" or "Top" : pushed at the left|top edge.
"Right" or "Bottom" : pushed against the right|top edge
Sizing:
"Wide" or "Tall" : filled to use available space.
"Wide*#" or "Tall*#" : filled but weighted by the number #.
"Fill" (or "Fill*#") : filled in both directions.
"Width=#" or "Height=#" : given explicit width|height
Margins:
"Flush" : margins are not added around this component.
"FlushV" : margins are not added to top and bottom edges of this component.
"FlushH" : margins are not added to left and right edges of this component.
"FlushTop" : margins are not added to top edge of this component.
"FlushBottom" : margins are not added to bottom edge of this component.
"FlushLeft" : margins are not added to left edge of this component.
"FlushRight" : margins are not added to right edge of this component.

By default, a component is centered in both directions.
The available space along the orientation is divided between the filled
components. A common idiom is to build a complicated panel out of, say, a
vertical stack of horizontal stacks (both using StackLayout). In that
case, it would usually be good to add the horizontal panels using the
tag "Wide Flush", so that spacing comes out evenly.



Much of what can be done with GridBagLayout can be achieved by combining
a set of subpanels using StackLayout, but typically more concisely.
On the other hand, with StackLayout there is less compile time checking
of the layout.

Author:
Bruce R. Miller (bruce.miller@nist.gov), TogetherSoft

Field Summary
 (package private) final static intABS
           
 (package private) final static intBACK
           
 (package private) final static intCENTER
           
 (package private) HashtablecodeTable
           
 (package private) int[]defaultCode
           
 (package private) final static intFILL
           
 (package private) final static intFLUSH
           
 (package private) final static intFLUSHLEFT
           
 (package private) final static intFLUSHRIGHT
           
 (package private) final static intFRONT
           
 final static intHORIZONTAL
          The orientation constant for horizontal layouts.
 (package private) intmargin
           
 (package private) intorientation
           
 (package private) final static intPOSMASK
           
 (package private) final static intSIZEMASK
           
 final static intVERTICAL
          The orientation constant for vertical layouts.

Constructor Summary
StackLayout()
          Create a horizontal StackLayout.
StackLayout(int orientation)
          Create a StackLayout with the given orientation.
StackLayout(int orientation, int margin)
          Create a StackLayout with the given orientation and space
between components.

Method Summary
 voidaddLayoutComponent(String tag, Component comp)
          Add the specified component to the layout, parsing the layout tag.
 (package private) DimensioncomputeLayoutSize(Container parent, boolean preferred)
           
 (package private) intcountDigits(String tag, int i)
           
 (package private) int[]getCode(Component comp)
           
 voidlayoutContainer(Container parent)
          Lays out the specified container.
 DimensionminimumLayoutSize(Container parent)
          Calculate the minimum size dimensions for the specififed container.
 (package private) intparseArg(String tag, int i, int n)
           
 DimensionpreferredLayoutSize(Container parent)
          Calculate the preferred size dimensions for the specififed container.
 voidremoveLayoutComponent(Component comp)
          Remove the specified component from the layout.
 (package private) booleanstretches(Component comp)
           

Field Detail

ABS

final static int ABS

BACK

final static int BACK

CENTER

final static int CENTER

codeTable

Hashtable codeTable

defaultCode

int[] defaultCode

FILL

final static int FILL

FLUSH

final static int FLUSH

FLUSHLEFT

final static int FLUSHLEFT

FLUSHRIGHT

final static int FLUSHRIGHT

FRONT

final static int FRONT

HORIZONTAL

public final static int HORIZONTAL
The orientation constant for horizontal layouts.

margin

int margin

orientation

int orientation

POSMASK

final static int POSMASK

SIZEMASK

final static int SIZEMASK

VERTICAL

public final static int VERTICAL
The orientation constant for vertical layouts.
Constructor Detail

StackLayout

public StackLayout()
Create a horizontal StackLayout.

StackLayout

public StackLayout(int orientation)
Create a StackLayout with the given orientation.

StackLayout

public StackLayout(int orientation, int margin)
Create a StackLayout with the given orientation and space
between components.
Method Detail

addLayoutComponent

public void addLayoutComponent(String tag, Component comp)
Add the specified component to the layout, parsing the layout tag.

computeLayoutSize

Dimension computeLayoutSize(Container parent, boolean preferred)

countDigits

int countDigits(String tag, int i)

getCode

int[] getCode(Component comp)

layoutContainer

public void layoutContainer(Container parent)
Lays out the specified container.

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Calculate the minimum size dimensions for the specififed container.

parseArg

int parseArg(String tag, int i, int n)

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Calculate the preferred size dimensions for the specififed container.

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Remove the specified component from the layout.

stretches

boolean stretches(Component comp)

Association Links

to Class java.util.Hashtable