com.magelang.splitter
Class SplitterLayout

java.lang.Object
  |
  +--com.magelang.splitter.SplitterLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class SplitterLayout
extends java.lang.Object
implements java.awt.LayoutManager2, java.io.Serializable

SplitterLayout is a layout manager that will layout a container holding other components and SplitterBars.

Each component added to a container to be laid out using SplitterLayout must provide a String containing a "weight" for the component. This weight will be used to determine the initial spacing of all components being laid out. The weight numbers are arbitrary integers. The amount of space initially allocated for a component is

(wc/wt) * (size-insets-splitterSize)

where

wc
the weight number for the component
wt
the total weight of all visible components in the container
size
the space free to display the components
insets
space used by insets in the container
splitterSize
amount of space needed to display SplitterBars

If the container being laid out holds no SplitterBars, SplitterLayout acts like a relational-weight layout manager. All components are always laid out based on their proportionate weights.

If the container being laid out holds some SplitterBars, SplitterLayout will initially size all non SplitterBar components based on their weights. Any succesive layouts are computed strictly on the locations of the SplitterBars.

SplitterLayout can be oriented Horizontally or Vertically. Any SpliterBars placed in the container will automatically be oriented.

If a SplitterBar has been modified (adding components to it) you will need to add SplitterSpace components to it. See SplitterBar for more details.

Known Problems:

Use this code at your own risk! MageLang Institute is not responsible for any damage caused directly or indirctly through use of this code.

SOFTWARE RIGHTS

MageLang support classes, version 1.0, MageLang Institute

We reserve no legal rights to this code--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with it, including including the incorporation of it into commerical software.

However, this code cannot be sold as a standalone product.

We encourage users to develop software with this code. However, we do ask that credit is given to us for developing it By "credit", we mean that if you use these components or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like these components and have developed a nice tool with the output, please mention that you developed it using these components. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.

The MageLang Support Classes Gang:

See Also:
SplitterBar, SplitterSpace, Serialized Form

Field Summary
static SplitterBar dragee
           
static int HORIZONTAL
          Aligns components horizontally -- SplitterBars will move left-right
static int VERTICAL
          Aligns components vertically -- SplitterBars will move up/down
 
Constructor Summary
SplitterLayout()
          Create a new SplitterLayout -- default orientation is VERTICAL
SplitterLayout(int orientation)
          Create a new SplitterLayout
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds a component w/ constraints to the layout.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds a component w/ a String constraint to the layout.
 java.awt.Dimension checkLayoutSize(java.awt.Container target, boolean getPrefSize)
           
 float getLayoutAlignmentX(java.awt.Container parent)
          Tells the caller that we prefer to be centered
 float getLayoutAlignmentY(java.awt.Container parent)
          Tells the caller that we prefer to be centered
 int getOrientation()
          Gets the orientation property (int) value.
 void invalidateLayout(java.awt.Container target)
          Does not have any effect (overridden to null the effect)
 void layoutContainer(java.awt.Container target)
          Lays out the components in the specified container by telling then what their size will be
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Determines the maximum amount of space that could be used when laying out the components in the specified container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Determines the minimum amount of room requested for the layout of components contained in the specified container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Determines the preferred amount of room requested for the layout of components contained in the specified container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes a component from the layout.
 void setOrientation(int orientation)
          Sets the orientation property (int) value.
 void swapOrientation(java.awt.Container container)
           
 java.lang.String toString()
          Returns a String representation of the Layout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERTICAL

public static final int VERTICAL
Aligns components vertically -- SplitterBars will move up/down

HORIZONTAL

public static final int HORIZONTAL
Aligns components horizontally -- SplitterBars will move left-right

dragee

public static SplitterBar dragee
Constructor Detail

SplitterLayout

public SplitterLayout()
Create a new SplitterLayout -- default orientation is VERTICAL

SplitterLayout

public SplitterLayout(int orientation)
Create a new SplitterLayout
Parameters:
orientation - -- VERTICAL or HORIZONTAL
Method Detail

addLayoutComponent

public final void addLayoutComponent(java.awt.Component comp,
                                     java.lang.Object constraints)
Adds a component w/ constraints to the layout. This should only be called by java.awt.Container's add method.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager2

addLayoutComponent

public final void addLayoutComponent(java.lang.String name,
                                     java.awt.Component comp)
Adds a component w/ a String constraint to the layout. This should only be called by java.awt.Container's add method.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager

checkLayoutSize

public final java.awt.Dimension checkLayoutSize(java.awt.Container target,
                                                boolean getPrefSize)

getLayoutAlignmentX

public final float getLayoutAlignmentX(java.awt.Container parent)
Tells the caller that we prefer to be centered
Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public final float getLayoutAlignmentY(java.awt.Container parent)
Tells the caller that we prefer to be centered
Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

getOrientation

public int getOrientation()
Gets the orientation property (int) value.
Returns:
The orientation property value.
See Also:
setOrientation(int)

invalidateLayout

public final void invalidateLayout(java.awt.Container target)
Does not have any effect (overridden to null the effect)
Specified by:
invalidateLayout in interface java.awt.LayoutManager2

layoutContainer

public final void layoutContainer(java.awt.Container target)
Lays out the components in the specified container by telling then what their size will be
Specified by:
layoutContainer in interface java.awt.LayoutManager

maximumLayoutSize

public final java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Determines the maximum amount of space that could be used when laying out the components in the specified container.
Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
Parameters:
-- - the container being laid out

minimumLayoutSize

public final java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Determines the minimum amount of room requested for the layout of components contained in the specified container.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
target - -- the Container being laid out

preferredLayoutSize

public final java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Determines the preferred amount of room requested for the layout of components contained in the specified container.
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
target - -- the Container being laid out

removeLayoutComponent

public final void removeLayoutComponent(java.awt.Component comp)
Removes a component from the layout. This should only be called by java.awt.Container's remove method.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

setOrientation

public void setOrientation(int orientation)
Sets the orientation property (int) value.
Parameters:
orientation - The new value for the property.
See Also:
getOrientation()

swapOrientation

public void swapOrientation(java.awt.Container container)

toString

public final java.lang.String toString()
Returns a String representation of the Layout
Overrides:
toString in class java.lang.Object