pagelayout
Class PanelCell

java.lang.Object
  extended by pagelayout.Cell
      extended by pagelayout.PanelCell
Direct Known Subclasses:
FillerPanelCell

public class PanelCell
extends Cell

A PanelCell is a cell associated with a child component (usually a panel, an object of the class javax.swing.Janel) which itself contains other child components. The layout of such a panel can be managed in one of the two ways. The first option is to set a new layout manager for the panel, which may or may not be an instance of the class PageLayout, and to add the panel to its container in the manner required by the layout manager of the parent of the panel (e.g. PageLayout requires that the panel not be directly be added to the parent, but to the tree of cells whose root is the parent's top level cell). The PanelCell offers an alternative that may be simpler, at least within the context of PageLayout. An object of the class PanelCell is created by using the panel together with its top level cell. Once instantiated, this PanelCell object can be added to other cells of the parent container just like any other cell, and thus there is no need to create a separate layout manager for the panel.


Nested Class Summary
 
Nested classes/interfaces inherited from class pagelayout.Cell
Cell.Constraint
 
Field Summary
 
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
PanelCell(java.awt.Container container, Cell cell)
          Creates the PanelCell associated with the given container.
 
Method Summary
 void addComponentsToContainer(java.awt.Container parent)
          Adds the panel of this PanelCell to the parent, and the components contained in the top level cell of this object to the panel.
 BoundSpring computeBoundSpring()
          Computes the BoundSpring of the panel associated with this object on the basis of the BoundSpring of the top level cell.
 Cell duplicate(ComponentDuplicator c)
           
 Cell getCell()
           
 Cell getChildAt(int index)
          Return the top level cell of this panel.
 java.awt.Component getComponent()
          Returns the panel wrapped by this object.
 ComponentCell getComponentCell()
           
 boolean isComponentCell()
          Returns true as this cell encloses a component.
 int numberOfChildren()
          Returns 1, as a panel cell has only one child, the top level cell.
 java.awt.Container removeAllComponents(java.awt.Container parent)
          Removes the panel associated with this object from its parent, and all the components that are in the tree of the cells that has its root the top level cell of the panel.
 int replaceCell(Cell currentCell, Cell newCell, java.awt.Container parent)
          Replaces an existing cell by a new cell.
protected  void setBounds(int x, int y, int width, int height)
          Lays out panel of this PanelCell and its children within the specified rectangle of the panel's parent.
 void setComponentGaps(int hgap, int vgap)
          Sets the size of the empty area around all enclosed components.
 void setContainerGaps(int hgap, int vgap)
           
 void xmlserialize(XMLPrintStream out, ComponentXMLSerializer c)
           
 
Methods inherited from class pagelayout.Cell
addArgs, alignBaseline, alignBaseline, checkArgs, createLayout, dupConstraint, getAlignment, getBaseline, getBoundSpring, getCellByName, getComponentCell, getConstraint, getContainer, getDim, getFilledSizeX, getFilledSizeY, getName, getParent, getRootCell, getSize, invalidate, isCell, isCellOrComponent, isFixedHeight, isFixedSize, isFixedWidth, layout, linkHeight, linkHeight, linkHeight, linkToContainerHeight, linkToContainerWidth, linkWidth, linkWidth, linkWidth, removeComponent, replaceChild, setAlignment, setBounds, 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, toString, wait, wait, wait
 

Constructor Detail

PanelCell

public PanelCell(java.awt.Container container,
                 Cell cell)
Creates the PanelCell associated with the given container.

Parameters:
container - the container of this PanelCell.
cell - the top level cell of the container.
Method Detail

computeBoundSpring

public BoundSpring computeBoundSpring()
Computes the BoundSpring of the panel associated with this object on the basis of the BoundSpring of the top level cell.

Specified by:
computeBoundSpring in class Cell
Returns:
The computed two-dimensional spring.

addComponentsToContainer

public void addComponentsToContainer(java.awt.Container parent)
Adds the panel of this PanelCell to the parent, and the components contained in the top level cell of this object to the panel.

Overrides:
addComponentsToContainer in class Cell
Parameters:
parent - The container that contains the panel of this PanelCell.

numberOfChildren

public int numberOfChildren()
Returns 1, as a panel cell has only one child, the top level cell.

Overrides:
numberOfChildren in class Cell
Returns:
1, as a panel cell has only one child, the top level cell.

getChildAt

public Cell getChildAt(int index)
Return the top level cell of this panel.

Overrides:
getChildAt in class Cell
Parameters:
index - the index of the cell to be returned. This is ignored.
Returns:
The top level cell.

setBounds

protected void setBounds(int x,
                         int y,
                         int width,
                         int height)
Lays out panel of this PanelCell and its children within the specified rectangle of the panel's parent.

Overrides:
setBounds 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.

removeAllComponents

public java.awt.Container removeAllComponents(java.awt.Container parent)
Removes the panel associated with this object from its parent, and all the components that are in the tree of the cells that has its root the top level cell of the panel.

Overrides:
removeAllComponents in class Cell
Parameters:
parent - not used.
Returns:
The parent of the panel.

isComponentCell

public boolean isComponentCell()
Returns true as this cell encloses a component.

Overrides:
isComponentCell in class Cell
Returns:
true as this cell encloses a component.

getComponent

public java.awt.Component getComponent()
Returns the panel wrapped by this object. component.

Overrides:
getComponent in class Cell
Returns:
The panel wrapped by this object.

replaceCell

public int replaceCell(Cell currentCell,
                       Cell newCell,
                       java.awt.Container parent)
Replaces an existing cell by a new cell. If the first argument is null, and this cell is a row or a column, the newCell is added to this cell.

Overrides:
replaceCell in class Cell
Parameters:
currentCell - current cell that is to be replaced.
newCell - the new cell that replaces the current cell at the specified index.
parent - the container in which the components of the cells are placed.
Returns:
NOT_FOUND if the currentCell was not found, FOUND_NOTREPLACED if it was found but could not be replaced, and FOUND_REPLACED if it was found and successfully replaced.

setComponentGaps

public void setComponentGaps(int hgap,
                             int vgap)
Sets the size of the empty area around all enclosed components.

Overrides:
setComponentGaps in class Cell
Parameters:
hgap - the width of the vertical strips around the vertical edges.
vgap - the height of the horizontal strips around the horizontal edges.

setContainerGaps

public void setContainerGaps(int hgap,
                             int vgap)

duplicate

public Cell duplicate(ComponentDuplicator c)
Specified by:
duplicate in class Cell

getCell

public Cell getCell()

xmlserialize

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

getComponentCell

public ComponentCell getComponentCell()
Overrides:
getComponentCell in class Cell