com.objectwave.tools.propertyEditor
Class DeckLayout

java.lang.Object
  |
  +--com.objectwave.tools.propertyEditor.AbstractLayout
        |
        +--com.objectwave.tools.propertyEditor.DeckLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class DeckLayout
extends AbstractLayout
implements java.awt.LayoutManager2, java.io.Serializable

DeckLayout treats each component in the container as a card. Only one card is visible at a time, and the container acts like a deck of cards. The ordering of cards is determined by the container's own internal ordering of its component objects. DeckLayout defines a set of methods that allow an application to flip through the cards sequentially, or to show a specified card. The addLayoutComponent method can be used to associate a string identifier with a given card for faster random access.

See Also:
Serialized Form

Field Summary
protected  int count
           
protected  java.util.Hashtable tab
           
protected  boolean wrap
           
 
Fields inherited from class com.objectwave.tools.propertyEditor.AbstractLayout
hgap, vgap
 
Constructor Summary
DeckLayout()
           
DeckLayout(boolean wrap)
           
DeckLayout(int hgap, int vgap)
           
DeckLayout(int hgap, int vgap, boolean wrap)
           
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to this deck layout's internal table, by name.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
 void first(java.awt.Container parent)
          Flips to the first card of the container.
 java.awt.Component getComponent(java.lang.String name)
           
 int getIndex(java.awt.Container parent, java.lang.String name)
           
 java.lang.String getName(java.awt.Container parent, int index)
           
 void last(java.awt.Container parent)
          Flips to the last card of the container.
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container using this deck layout.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size for the specified panel.
 int next(java.awt.Container parent)
          Flips to the next card of the specified container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size for the specified panel.
 int previous(java.awt.Container parent)
          Flips to the previous card of the specified container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void show(java.awt.Container parent, int index)
          Flips to the component at the numbered position.
 void show(java.awt.Container parent, java.lang.String name)
          Flips to the component that was added to this layout using the specified name.
 
Methods inherited from class com.objectwave.tools.propertyEditor.AbstractLayout
getHgap, getLayoutAlignmentX, getLayoutAlignmentY, getVgap, invalidateLayout, maximumLayoutSize, setHgap, setVgap, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.LayoutManager2
getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize
 

Field Detail

tab

protected java.util.Hashtable tab

count

protected int count

wrap

protected boolean wrap
Constructor Detail

DeckLayout

public DeckLayout()

DeckLayout

public DeckLayout(int hgap,
                  int vgap)

DeckLayout

public DeckLayout(int hgap,
                  int vgap,
                  boolean wrap)

DeckLayout

public DeckLayout(boolean wrap)
Method Detail

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to this deck layout's internal table, by name. The object specified by constraints must be a string. The deck layout stores this string as a key-value pair that can be used for random access to a particular card. By calling the show method, an application can display the component with the specified name.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Overrides:
addLayoutComponent in class AbstractLayout
Parameters:
comp - The component to be added.
constraints - A name that identifies the component

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Deprecated. replaced by addLayoutComponent(Component, Object)

Description copied from class: AbstractLayout
Adds the specified component with the specified name to the layout. By default, we call the more recent addLayoutComponent method with an object constraint argument. The name is passed through directly.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Overrides:
addLayoutComponent in class AbstractLayout
Parameters:
name - The name of the component
comp - The component to be added

first

public void first(java.awt.Container parent)
Flips to the first card of the container.

Parameters:
parent - The name of the parent container

getComponent

public java.awt.Component getComponent(java.lang.String name)

getIndex

public int getIndex(java.awt.Container parent,
                    java.lang.String name)

getName

public java.lang.String getName(java.awt.Container parent,
                                int index)

last

public void last(java.awt.Container parent)
Flips to the last card of the container.

Parameters:
parent - The name of the parent container

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the specified container using this deck layout. Each component in the parent container is reshaped to be the same size as the container, minus insets, horizontal and vertical gaps.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - The name of the parent container

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size for the specified panel.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - The name of the parent container
Returns:
minimum dimensions required to lay out the components.

next

public int next(java.awt.Container parent)
Flips to the next card of the specified container. If the currently visible card is the last one, this method flips to the first card in the layout.

Parameters:
parent - The name of the parent container
Returns:
Index of the selected component

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size for the specified panel.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - The name of the parent container
Returns:
minimum dimensions required to lay out the components.

previous

public int previous(java.awt.Container parent)
Flips to the previous card of the specified container. If the currently visible card is the first one, this method flips to the last card in the layout.

Parameters:
parent - The name of the parent container
Returns:
Index of the selected component

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Overrides:
removeLayoutComponent in class AbstractLayout
Parameters:
comp - The component to be removed.

show

public void show(java.awt.Container parent,
                 int index)
Flips to the component at the numbered position. If no such component exists, nothing happens.

Parameters:
parent - The name of the parent container in which to do the layout.
index - The index (between 0 and component count - 1)

show

public void show(java.awt.Container parent,
                 java.lang.String name)
Flips to the component that was added to this layout using the specified name. If no such component exists, nothing happens.

Parameters:
parent - The name of the parent container in which to do the layout.
name - The component name.