gov.nasa.gsfc.drl.rtstps.library.layout
Class WidthManager

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.library.layout.WidthManager

final class WidthManager
extends java.lang.Object

This is a utility class that layout managers use. Its job is to determine the start pixels and widths of a row of components. You may add glue or horizontal glue.


Nested Class Summary
(package private)  class WidthManager.Item
           
 
Field Summary
private  boolean _distributeFatToGaps
           
private  int _hgap
           
private  java.util.LinkedList<WidthManager.Item> _itemList
           
private  int _leftMargin
           
private  int _minimumHeight
          the min and preferred sizes minus the margins.
private  int _minimumWidth
           
private  int _preferredHeight
           
private  int _preferredWidth
           
private  int _rightMargin
           
private  float _totalWeight
           
private  boolean _valid
           
 
Constructor Summary
WidthManager(int gap)
          Construct a WidthManager object.
 
Method Summary
(package private)  void addComponent(java.awt.Component c, float weight)
          Add a component with a weight.
(package private)  void doLayout(java.awt.Container parent, int ystart, int yheight)
          Lay out the container.
(package private)  int getMinimumHeight()
          Get the minimum height for the row, which is the largest minimum height of all components in the row.
(package private)  int getMinimumWidth()
          Get the minimum width of the row.
(package private)  int getPreferredHeight()
          Get the preferred height for the row, which is the largest preferred height of all components in the row.
(package private)  int getPreferredWidth()
          Get the preferred width of the row.
private  int giveFatToComponents(int fat)
           
(package private)  void removeComponent(java.awt.Component c)
          Remove a component.
(package private)  void setDistributeSpaceToGaps(boolean c)
          Determines how to distribute extra space when all components have zero weight and there is no glue.
(package private)  void setGap(int gap)
          Set a horizontal gap.
(package private)  void setMargins(int leftMargin, int rightMargin)
          Set the left and right margins in pixels.
(package private)  void validate()
          Validate the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_itemList

private java.util.LinkedList<WidthManager.Item> _itemList

_valid

private boolean _valid

_hgap

private int _hgap

_leftMargin

private int _leftMargin

_rightMargin

private int _rightMargin

_totalWeight

private float _totalWeight

_distributeFatToGaps

private boolean _distributeFatToGaps

_minimumHeight

private int _minimumHeight
the min and preferred sizes minus the margins.


_preferredHeight

private int _preferredHeight

_minimumWidth

private int _minimumWidth

_preferredWidth

private int _preferredWidth
Constructor Detail

WidthManager

WidthManager(int gap)
Construct a WidthManager object.

Method Detail

addComponent

void addComponent(java.awt.Component c,
                  float weight)
Add a component with a weight. The component may be glue or horizontal glue, in which case the weight is unconditionally set to 1f, and the passed weight is ignored.


removeComponent

void removeComponent(java.awt.Component c)
Remove a component.


setDistributeSpaceToGaps

void setDistributeSpaceToGaps(boolean c)
Determines how to distribute extra space when all components have zero weight and there is no glue. If true, extra space is evenly distributed among the gaps and margins, which causes a center alignment. If false, extra space is put at the end of the row, which causes a left alignment. The default behavior is false, left alignment.


setMargins

void setMargins(int leftMargin,
                int rightMargin)
Set the left and right margins in pixels. The defaults are (0,0).


setGap

void setGap(int gap)
Set a horizontal gap. The default is zero pixels.


getPreferredHeight

int getPreferredHeight()
Get the preferred height for the row, which is the largest preferred height of all components in the row.


getMinimumHeight

int getMinimumHeight()
Get the minimum height for the row, which is the largest minimum height of all components in the row.


getPreferredWidth

int getPreferredWidth()
Get the preferred width of the row. This includes the gaps and the margins but does not include the container's insets.


getMinimumWidth

int getMinimumWidth()
Get the minimum width of the row. This includes the gaps and the margins but does not include the container's insets.


validate

void validate()
Validate the layout.


doLayout

void doLayout(java.awt.Container parent,
              int ystart,
              int yheight)
Lay out the container.

Parameters:
parent - The container.
ystart - The row's y pixel location.
yheight - The row's height.

giveFatToComponents

private int giveFatToComponents(int fat)