pagelayout
Class CardCell

java.lang.Object
  extended by pagelayout.Cell
      extended by pagelayout.CardCell

public class CardCell
extends Cell

An object of the class CardCell is a collection of named cells of which only one is visible at a given time. The method showCell of this class can be used to change the currently visible cell. For an example, see CardExample.


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
CardCell()
          Creates a CardCell object.
 
Method Summary
 void add(java.lang.String name, Cell cell)
          Adds a cell to the CardCell.
 void add(java.lang.String name, java.awt.Component component)
          Adds a component to the CardCell.
 void addComponentsToContainer(java.awt.Container parent)
          Recursively calls the addComponentsToContainer method of each cell within the card to add the components of the cells to the container.
 BoundSpring computeBoundSpring()
          Computes the two-dimensional spring associated with the currently visible cell or component.
 Cell duplicate(ComponentDuplicator c)
           
 Cell getChildAt(int i)
          Should be over-ridden by sub-classes that contain child-cells to return the child associated with the given index, or null if the index is out of bounds.
 java.awt.Component getComponent()
          If the currently visble cell is a component cell, this method returns the enclosed component.
 boolean isComponentCell()
          Returns true if the currently visble cell encloses a component.
 int numberOfChildren()
          Returns 1, since only one cell is visible at any time.
 java.awt.Container removeAllComponents(java.awt.Container parent)
          Calls the removeAllComponents method for all the cells in this CardCell.
protected  void setBounds(int x, int y, int width, int height)
          Lays out the currently visble cell or component within the specified rectangle of the container.
 void showCell(java.lang.String name)
          Changes the currently visible cell.
 void xmlserialize(XMLPrintStream out, ComponentXMLSerializer c)
           
 
Methods inherited from class pagelayout.Cell
addArgs, alignBaseline, alignBaseline, checkArgs, createLayout, dupConstraint, getAlignment, getBaseline, getBoundSpring, getCellByName, getComponentCell, 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, replaceCell, replaceChild, setAlignment, 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, toString, wait, wait, wait
 

Constructor Detail

CardCell

public CardCell()
Creates a CardCell object.

Method Detail

add

public void add(java.lang.String name,
                java.awt.Component component)
Adds a component to the CardCell.

Parameters:
name - the identifier for the component. The name can be used in the call to the method showCell of this class to hide the currently visible component/cell and show the component with the given name.
component - the component to be added. To add

add

public void add(java.lang.String name,
                Cell cell)
Adds a cell to the CardCell.

Parameters:
name - the identifier for the cell. The name can be used in the call to the method showCell of this class to hide the currently visible component/cell and show the component with the given name.
cell - the cell to be added.

computeBoundSpring

public BoundSpring computeBoundSpring()
Computes the two-dimensional spring associated with the currently visible cell or component.

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

addComponentsToContainer

public void addComponentsToContainer(java.awt.Container parent)
Recursively calls the addComponentsToContainer method of each cell within the card to add the components of the cells to the container.

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

setBounds

protected void setBounds(int x,
                         int y,
                         int width,
                         int height)
Lays out the currently visble cell or component within the specified rectangle of the container.

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)
Calls the removeAllComponents method for all the cells in this CardCell.

Overrides:
removeAllComponents in class Cell
Parameters:
parent - the container in which the components are placed. If it is null, the parent is retrieved from the first component that is found in the tree.
Returns:
The parent of the removed components.

isComponentCell

public boolean isComponentCell()
Returns true if the currently visble cell encloses a component.

Overrides:
isComponentCell in class Cell
Returns:
true if the currently visible cell encloses a component, false otherwise.

getComponent

public java.awt.Component getComponent()
If the currently visble cell is a component cell, this method returns the enclosed component. Otherwise null is returned.

Overrides:
getComponent in class Cell
Returns:
The component enclosed within the currently visible cell, null if none exists.

duplicate

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

xmlserialize

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

numberOfChildren

public int numberOfChildren()
Returns 1, since only one cell is visible at any time.

Overrides:
numberOfChildren in class Cell
Returns:
The number of child cells that this cell has.

getChildAt

public Cell getChildAt(int i)
Description copied from class: Cell
Should be over-ridden by sub-classes that contain child-cells to return the child associated with the given index, or null if the index is out of bounds.

Overrides:
getChildAt in class Cell
Parameters:
i - the index of the cell that is needed.
Returns:
The currently visible cell.

showCell

public void showCell(java.lang.String name)
Changes the currently visible cell.

Parameters:
name - the name of the cell used in the call to the add or add method of this class.