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

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

final class HeightManager
extends java.lang.Object

This is a utility class that layout managers use. Its job is to determine the start pixel and height of each row in a list of rows. It does not need components. You tell it the minimum and preferred sizes of each row as well as a row weighting factor. You may also give it top and bottom margins and a row gap.

HeightManager usually sets each row to its preferred size. If no row has a non-zero weight, then it distributes extra space to the gaps and margins. If one or more rows has non-zero weight, it gives those rows all extra space proportional to the weight.

If the container is smaller than HeightManager's preferred size, then it sets each row to its minimum size. It then distributes extra space as it did above depending on whether or not any row has non-zero weight.


Nested Class Summary
(package private)  class HeightManager.Row
           
 
Field Summary
private  int _bottomMargin
           
private  int _minimumHeight
           
private  int _preferredHeight
           
private  HeightManager.Row[] _row
           
private  int _topMargin
           
private  float _totalWeight
           
private  boolean _valid
           
private  int _vgap
           
 
Constructor Summary
HeightManager(int rows, int vgap)
          Construct a HeightManager object.
 
Method Summary
(package private)  void doLayout(java.awt.Container parent)
          Lay out the rows.
(package private)  int getMinimumHeight()
          Get the total minimum height of all rows.
(package private)  int getPreferredHeight()
          Get the total preferred height of all rows.
(package private)  int getRowHeight(int rowIndex)
          Get a row's pixel height.
(package private)  int getRowStart(int rowIndex)
          Get a row's start pixel.
private  int giveFatToComponents(int fat)
           
(package private)  void print()
           
(package private)  void setGap(int g)
          Set a pixel gap between rows.
(package private)  void setMargins(int top, int bottom)
          Set the top and bottom margins.
(package private)  void setMinimumRowHeight(int rowIndex, int h)
          Set a minimum pixel height for an indicated row.
(package private)  void setPreferredRowHeight(int rowIndex, int h)
          Set a preferred pixel height for an indicated row.
(package private)  void setRowWeight(float w)
          Set a weight for all rows.
(package private)  void setRowWeight(int rowIndex, float w)
          Set a weight for an indicated row.
(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

_valid

private boolean _valid

_row

private HeightManager.Row[] _row

_vgap

private int _vgap

_topMargin

private int _topMargin

_bottomMargin

private int _bottomMargin

_minimumHeight

private int _minimumHeight

_preferredHeight

private int _preferredHeight

_totalWeight

private float _totalWeight
Constructor Detail

HeightManager

HeightManager(int rows,
              int vgap)
Construct a HeightManager object.

Method Detail

setRowWeight

void setRowWeight(float w)
Set a weight for all rows. The default is 0.0f.


setRowWeight

void setRowWeight(int rowIndex,
                  float w)
Set a weight for an indicated row. The default is 0.0f.


setMinimumRowHeight

void setMinimumRowHeight(int rowIndex,
                         int h)
Set a minimum pixel height for an indicated row.


setPreferredRowHeight

void setPreferredRowHeight(int rowIndex,
                           int h)
Set a preferred pixel height for an indicated row.


setGap

void setGap(int g)
Set a pixel gap between rows. It does not affect the margin.


setMargins

void setMargins(int top,
                int bottom)
Set the top and bottom margins.


getPreferredHeight

int getPreferredHeight()
Get the total preferred height of all rows. This includes gaps and margins but excludes container insets.


getMinimumHeight

int getMinimumHeight()
Get the total minimum height of all rows. This includes gaps and margins but excludes container insets.


validate

void validate()
Validate the layout.


doLayout

void doLayout(java.awt.Container parent)
Lay out the rows.


giveFatToComponents

private int giveFatToComponents(int fat)

getRowStart

final int getRowStart(int rowIndex)
Get a row's start pixel. This is meaningful only after doLayout().


getRowHeight

final int getRowHeight(int rowIndex)
Get a row's pixel height. This is meaningful only after doLayout().


print

void print()