pagelayout
Class CellContainer

java.lang.Object
  extended by pagelayout.Cell
      extended by pagelayout.CellContainer
Direct Known Subclasses:
Column, Row

public abstract class CellContainer
extends Cell

The class CellContainer is the (abstract) superclass of the classes Column and Row in which the elements are arranged sequentially in the vertical or horizontal direction. Components, gaps, or Cell objects can be added to a row or column by using the add methods of this class.

See Also:
Cell, Column, Row

Nested Class Summary
 
Nested classes/interfaces inherited from class pagelayout.Cell
Cell.Constraint
 
Field Summary
protected  CellVector cells
          The collection of cells in a Vector of Cell objects.
protected  int halignment
          The horizontal alignment parameter.
protected  java.util.Vector<java.lang.Integer> parallelAlignment
           
protected  int valignment
          The vertical alignment parameter.
 
Fields inherited from class pagelayout.Cell
BASELINE, BOTTOM, boundSpring, CENTER, constraint, filledSizeX, filledSizeY, fixMaxSize, FOUND_NOTREPLACED, FOUND_REPLACED, halign, JUSTIFIED, LEFT, links, MAX, NEWROW, NO_ALIGNMENT, NOT_FOUND, RIGHT, SKIP, TOP, valign
 
Constructor Summary
CellContainer(int halignment, int valignment, boolean isRow)
          Creates a CellContainer with the given alignment specifications and orientation.
 
Method Summary
 CellContainer add(Cell... cellarray)
          Adds cells to the cell-container.
 CellContainer add(java.awt.Component... components)
          Adds a components to this cell-container.
 CellContainer add(java.awt.Component component, int horizontalGap, int verticalGap)
          Adds a component to this cell-container with specified gaps around the component.
 CellContainer add(int gap)
          Adds a fixed gap to the cell-container.
 CellContainer add(int align, Cell... cellarray)
          Adds cells to the cell-container with specified alignment that may be different from the alignment for the container.
 CellContainer add(int align, java.awt.Component... components)
          Adds components to the cell-container with specified alignment that may be different from the alignment for the container.
 CellContainer add(int minGap, int preferredGap, int maxGap)
          Adds a flexible gap to the cell-container.
 void addComponentsToContainer(java.awt.Container container)
          Recursively calls the addComponentsToContainer method of each cell within this row or column to add the components of the cells to the container of the type java.awt.Container .
 void changeAlignment(int halign, int valign)
           
 void clear()
           
abstract  BoundSpring computeBoundSpring()
          The abstract method for computing the BoundSpring of the cell-container.
 int getAlignment(int coord, int defaultValue)
          Used by Row and Column during layout of the elements to determine if the alignment of this cell overrides the default alignment for the container.
 Cell getChildAt(int index)
          Return the cell associated with the given index within this cell-container , with the first cell corresponding the the zero'th index.
protected  int getParallelAlignment(int i)
           
protected abstract  boolean isHorizontal()
          Returns true if this container is a row.
protected  void layout(int x, int y, int width, int height)
          This method of the top level cell is called by the layout manager whenever the container calls the manager to layout the components within it.
static int limitAlignment(int x, boolean isRow)
           
 int numberOfChildren()
          Returns the number of elements contained in this row or column.
 boolean replaceChild(int index, Cell newCell, java.awt.Container parent)
          Replace the cell at the specified index with a new cell.
 java.lang.String toString()
          Returns a string representation of this object.
 void xmlserialize(XMLPrintStream out, ComponentXMLSerializer c)
           
 
Methods inherited from class pagelayout.Cell
addArgs, alignBaseline, alignBaseline, checkArgs, createLayout, dupConstraint, duplicate, getBaseline, getBoundSpring, getCellByName, getComponent, getComponentCell, getComponentCell, getConstraint, getContainer, getDim, getFilledSizeX, getFilledSizeY, getName, getParent, getRootCell, getSize, invalidate, isCell, isCellOrComponent, isComponentCell, isFixedHeight, isFixedSize, isFixedWidth, linkHeight, linkHeight, linkHeight, linkToContainerHeight, linkToContainerWidth, linkWidth, linkWidth, linkWidth, removeAllComponents, removeComponent, replaceCell, setAlignment, setBounds, setBounds, setComponentGaps, setDim, setFixedHeight, setFixedHeight, setFixedHeight, setFixedHeight, setFixedHeight, setFixedSize, setFixedSize, setFixedSize, setFixedWidth, setFixedWidth, setFixedWidth, setFixedWidth, setFixedWidth, setName, setParent, setSize, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

valignment

protected int valignment
The vertical alignment parameter.


halignment

protected int halignment
The horizontal alignment parameter.


cells

protected CellVector cells
The collection of cells in a Vector of Cell objects.


parallelAlignment

protected java.util.Vector<java.lang.Integer> parallelAlignment
Constructor Detail

CellContainer

public CellContainer(int halignment,
                     int valignment,
                     boolean isRow)
Creates a CellContainer with the given alignment specifications and orientation.

Parameters:
halignment - the horizontal alignment parameter.
valignment - the vertical alignment parameter.
isRow - true if this cell-container is a row, false if column.
Method Detail

isHorizontal

protected abstract boolean isHorizontal()
Returns true if this container is a row.

Returns:
true for a row, and false for a column.

computeBoundSpring

public abstract BoundSpring computeBoundSpring()
The abstract method for computing the BoundSpring of the cell-container.

Specified by:
computeBoundSpring in class Cell
Returns:
The two-dimensional spring of associated with the row or column.

add

public CellContainer add(java.awt.Component... components)
Adds a components to this cell-container.

Parameters:
components - the components to be added.
Returns:
This object, so that multiple calls to add may be made in a single statement.

add

public CellContainer add(int align,
                         java.awt.Component... components)
Adds components to the cell-container with specified alignment that may be different from the alignment for the container.

Parameters:
align - the alignment of the components to be added. This overrides the default alignment of the row or column. For a row, it is the vertical alignment and for a column it is the horizontal alignment.
components - the components to be added.
Returns:
This object, so that multiple calls to add may be made in a single statement.

getParallelAlignment

protected int getParallelAlignment(int i)

add

public CellContainer add(java.awt.Component component,
                         int horizontalGap,
                         int verticalGap)
Adds a component to this cell-container with specified gaps around the component.

Parameters:
component - the component to be added.
horizontalGap - the width of empty strip to add around the vertical edges of the component.
verticalGap - the height of empty strip to add around the horizontal edges of the component.
Returns:
This object, so that multiple calls to add may be made in a single statement.

add

public CellContainer add(int gap)
Adds a fixed gap to the cell-container. The orientation of the gap is vertical for a column, and horizontal for a row.

Parameters:
gap - the length of the gap to be added.
Returns:
This object, so that multiple calls to add may be made in a single statement.

add

public CellContainer add(int minGap,
                         int preferredGap,
                         int maxGap)
Adds a flexible gap to the cell-container. The orientation of the gap is vertical for a column, and horizontal for a row.

Parameters:
minGap - the minimum length of the gap to be added.
preferredGap - the preferred length of the gap to be added.
maxGap - the maximum length of the gap to be added.
Returns:
This object, so that multiple calls to add may be made in a single statement.

add

public CellContainer add(Cell... cellarray)
Adds cells to the cell-container.

Parameters:
cellarray - the Cell objects to be added.
Returns:
This object, so that multiple calls to add may be made in a single statement.

add

public CellContainer add(int align,
                         Cell... cellarray)
Adds cells to the cell-container with specified alignment that may be different from the alignment for the container.

Parameters:
align - the alignment of the cells to be added. This overrides the default alignment for the column or row. For a row, it is the vertical alignment and for a column it is the horizontal alignment.
cellarray - the Cell objects to be added.
Returns:
This object, so that multiple calls to add may be made in a single statement.

limitAlignment

public static int limitAlignment(int x,
                                 boolean isRow)

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the object.

addComponentsToContainer

public void addComponentsToContainer(java.awt.Container container)
Recursively calls the addComponentsToContainer method of each cell within this row or column to add the components of the cells to the container of the type java.awt.Container .

Overrides:
addComponentsToContainer in class Cell
Parameters:
container - the container to which the components of the cells need to be added.

numberOfChildren

public int numberOfChildren()
Returns the number of elements contained in this row or column.

Overrides:
numberOfChildren in class Cell
Returns:
The number of elements in this cell-container.

getChildAt

public Cell getChildAt(int index)
Return the cell associated with the given index within this cell-container , with the first cell corresponding the the zero'th index.

Overrides:
getChildAt in class Cell
Parameters:
index - the index of the cell to be returned.
Returns:
The cell associated with the given index.

replaceChild

public boolean replaceChild(int index,
                            Cell newCell,
                            java.awt.Container parent)
Replace the cell at the specified index with a new cell.

Overrides:
replaceChild in class Cell
Parameters:
index - the index of the cell to be replaced.
newCell - the cell that replaces the current cell at the specified index.
parent - the container (java.awt.Container) in which the components of the cells are placed.
Returns:
true if the replacement was successful, otherwise false.

changeAlignment

public void changeAlignment(int halign,
                            int valign)

getAlignment

public int getAlignment(int coord,
                        int defaultValue)
Description copied from class: Cell
Used by Row and Column during layout of the elements to determine if the alignment of this cell overrides the default alignment for the container.

Overrides:
getAlignment in class Cell
Parameters:
coord - the direction: 0 for for horizontal alignment, 1 for vertical alignment.
defaultValue - the default alignment for the row or column.
Returns:
defaultValue if the alignment has not been specified for this cell to override the default, or the specified alignment.

layout

protected void layout(int x,
                      int y,
                      int width,
                      int height)
Description copied from class: Cell
This method of the top level cell is called by the layout manager whenever the container calls the manager to layout the components within it. Depending on the preferred and maximum size of the cell, appropriately modified parameters of the bounding rectangle within the container are passed to the setBounds method of this cell. In each cell, the the two-dimensional spring associated with each child is used to determine the actual layout dimension of the box within which the child is to laid out. This process continues recursively till all the components have been laid out.

Overrides:
layout in class Cell
Parameters:
x - the x-coordinate of the top left of the rectangle.
y - the y-coordinate of the top left of the rectangle.
width - the width of the rectangle.
height - the height of the rectangle.

xmlserialize

public void xmlserialize(XMLPrintStream out,
                         ComponentXMLSerializer c)
Specified by:
xmlserialize in class Cell

clear

public void clear()