org.merlotxml.awt
Class PercentLayout

java.lang.Object
  extended byorg.merlotxml.awt.PercentLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2

public class PercentLayout
extends java.lang.Object
implements java.awt.LayoutManager2

A LayoutManager that allows you to set the component's sizes as a percentage of the total layout size. Based somewhat on StrutLayout by Matthew Phillips

Author:
Kelly A. Campbell

Nested Class Summary
 class PercentLayout.ComponentInfo
           
static class PercentLayout.Constraints
           
 
Field Summary
protected  java.util.ArrayList _components
           
protected  int _defaultSpace
           
protected  boolean _invalid
           
protected  int _orient
           
protected  java.awt.Dimension _preferredSize
           
static int BOTH
           
 boolean DEBUG
           
static int HORIZONTAL
           
static int NONE
           
static int VERTICAL
           
 
Constructor Summary
PercentLayout()
           
PercentLayout(int orientation)
           
PercentLayout(int orientation, int space)
           
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
protected  void assignPreferredSizes(java.awt.Container c)
           
 float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the y axis.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container parent)
          Lays out the container in the specified panel.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum size of this component.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
protected  void recalculateLayout(java.awt.Container container)
           
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setDefaultSpacing(int space)
           
 void setOrientation(int orient)
           
protected  void translateComponents(int xdelta, int ydelta)
          Translate all component locations by xdelta, ydelta.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
See Also:
Constant Field Values

BOTH

public static final int BOTH
See Also:
Constant Field Values

DEBUG

public boolean DEBUG

_components

protected java.util.ArrayList _components

_orient

protected int _orient

_defaultSpace

protected int _defaultSpace

_invalid

protected boolean _invalid

_preferredSize

protected java.awt.Dimension _preferredSize
Constructor Detail

PercentLayout

public PercentLayout()

PercentLayout

public PercentLayout(int orientation)

PercentLayout

public PercentLayout(int orientation,
                     int space)
Method Detail

setDefaultSpacing

public void setDefaultSpacing(int space)

setOrientation

public void setOrientation(int orient)

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component with the specified name to the layout.

This form adds the component with default constraints which just uses the components preferred size.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container in the specified panel.

Specified by:
layoutContainer in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2

recalculateLayout

protected void recalculateLayout(java.awt.Container container)

assignPreferredSizes

protected void assignPreferredSizes(java.awt.Container c)

translateComponents

protected void translateComponents(int xdelta,
                                   int ydelta)
Translate all component locations by xdelta, ydelta.