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

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.library.layout.DeckLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

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

This layout manager is a CardLayout substitute. If fixes one bug in removeComponent() and has enhanced capabilities. When you add components to a container that is using DeckLayout, you must add a constraint, which is a string that is a unique name for the component. DeckLayout stores the components in a list in the order in which they are added to the layout.

See Also:
Serialized Form

Nested Class Summary
(package private)  class DeckLayout.Info
          An internal class with no expected public access.
 
Field Summary
private  java.awt.Container _container
          The container I am laying out.
private  java.util.ArrayList<DeckLayout.Info> _data
          A list of all components (Info) controlled by this layout manager.
private  java.awt.Insets _insets
          My insets.
private  int _showing
          Index of the current visible component.
private static java.awt.Dimension MAXLAYOUTSIZE
           
private static long serialVersionUID
           
 
Constructor Summary
DeckLayout(java.awt.Container parent)
          The DeckLayout constructor.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraint)
          Add a component to the layout.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Add a component to the layout.
private  int find(java.lang.String name)
          Find a component by name in my internal list.
 java.awt.Component getComponent(java.lang.String name)
          Get the component with the passed name.
 java.awt.Component getFirstComponent()
          Get the first component.
 java.awt.Component getLastComponent()
          Get the last component.
 float getLayoutAlignmentX(java.awt.Container parent)
          Get DeckLayout's X alignment.
 float getLayoutAlignmentY(java.awt.Container parent)
          Get DeckLayout's Y alignment.
 java.awt.Component getNextComponent()
          Get the next component after the currently showing one.
 java.awt.Component getPreviousComponent()
          Get the component that precedes the currently showing one.
 java.awt.Component getVisibleComponent()
          Get the currently visible component.
 int getVisibleComponentIndex()
          Get the name index of the currently visible component.
 java.lang.String getVisibleComponentName()
          Get the name of the currently visible component.
 void invalidateLayout(java.awt.Container parent)
          Invalidate the layout.
 boolean isFirstShowing()
          Determine if the first component is currently showing.
 boolean isLastShowing()
          Determine if the last component is currently showing.
 void layoutContainer(java.awt.Container parent)
          Lay out the components in the parent container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
          Get the maximum layout size.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Get the minimum layout size.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Get the preferred layout size.
 void removeLayoutComponent(java.awt.Component comp)
          Remove a component from the layout.
 void setInsets(java.awt.Insets i)
          Set a blank border.
private  void show(int index)
          Show the component identified by the name index.
 void show(java.lang.String name)
          Show the component with the passed component name.
 void showFirst()
          Show the first component.
 void showLast()
          Show the last component.
 void showNext()
          Show the next component after the currently showing one.
 void showPrevious()
          Show the component that precedes the currently showing one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXLAYOUTSIZE

private static final java.awt.Dimension MAXLAYOUTSIZE

_data

private java.util.ArrayList<DeckLayout.Info> _data
A list of all components (Info) controlled by this layout manager.


_showing

private int _showing
Index of the current visible component.


_insets

private java.awt.Insets _insets
My insets.


_container

private java.awt.Container _container
The container I am laying out.


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

DeckLayout

public DeckLayout(java.awt.Container parent)
The DeckLayout constructor.

Parameters:
parent - The container that uses this layout manager.
Method Detail

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraint)
Add a component to the layout.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - The component to be added
constraint - This must be a string. It is a label by which DeckLayout references the component. It must be unique.

addLayoutComponent

public final void addLayoutComponent(java.lang.String name,
                                     java.awt.Component comp)
Add a component to the layout.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - This string is a label by which DeckLayout references the component. It must be unique.
comp - The component to be added

find

private final int find(java.lang.String name)
Find a component by name in my internal list.

Returns:
the index of the component or -1 if the name is not a component name.

setInsets

public final void setInsets(java.awt.Insets i)
Set a blank border.


removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove a component from the layout. DeckLayout will not remove a component if it is visible or the last one in the layout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Get the preferred layout size.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Get the minimum layout size.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
Get the maximum layout size.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2

getLayoutAlignmentX

public final float getLayoutAlignmentX(java.awt.Container parent)
Get DeckLayout's X alignment. DeckLayout does not use the X alignment, so this value is always 0.5.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public final float getLayoutAlignmentY(java.awt.Container parent)
Get DeckLayout's Y alignment. DeckLayout does not use the Y alignment, so this value is always 0.5.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container parent)
Invalidate the layout.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lay out the components in the parent container.

Specified by:
layoutContainer in interface java.awt.LayoutManager

show

private void show(int index)
Show the component identified by the name index.


showFirst

public void showFirst()
Show the first component.


getFirstComponent

public java.awt.Component getFirstComponent()
Get the first component.


showNext

public void showNext()
Show the next component after the currently showing one. If the current component is the last one, show the first component.


getNextComponent

public java.awt.Component getNextComponent()
Get the next component after the currently showing one. If the current component is the last one, get the first component.


showPrevious

public void showPrevious()
Show the component that precedes the currently showing one. If the current component is the first one, show the last component.


getPreviousComponent

public java.awt.Component getPreviousComponent()
Get the component that precedes the currently showing one. If the current component is the first one, get the last component.


showLast

public void showLast()
Show the last component.


getLastComponent

public java.awt.Component getLastComponent()
Get the last component.


getVisibleComponent

public java.awt.Component getVisibleComponent()
Get the currently visible component.


getVisibleComponentIndex

public int getVisibleComponentIndex()
Get the name index of the currently visible component.


isLastShowing

public boolean isLastShowing()
Determine if the last component is currently showing.


isFirstShowing

public boolean isFirstShowing()
Determine if the first component is currently showing.


getVisibleComponentName

public java.lang.String getVisibleComponentName()
Get the name of the currently visible component.


show

public void show(java.lang.String name)
Show the component with the passed component name. If the name does not exist, the method throws an IllegalArgumentException.


getComponent

public java.awt.Component getComponent(java.lang.String name)
Get the component with the passed name. If the name does not exist, the method throws an IllegalArgumentException.