fr.upd.jby
Class SinLayout

java.lang.Object
  extended by fr.upd.jby.SinLayout
All Implemented Interfaces:
LayoutManager

public class SinLayout
extends Object
implements LayoutManager

Using this layout in a real application is a sin. It has been designed to demonstrate how to implement a LayoutManager. It lays components one below the other, starting from the top of the container space, and such that, left and right margins draw a sinusoid. Source code here and a sample here.

Since:
1.6
Version:
1.0
Author:
J.-B. Yunès

Constructor Summary
SinLayout()
          Constructs a default SinLayout which glues component's borders to the respective left and right borders of their container.
SinLayout(int cpc, int zenith)
          Constructs a SinLayout which glues component's borders to the respective left and right sinusoidal border of their container, with strict respect to their minimum size.
 
Method Summary
 void addLayoutComponent(String n, Component c)
          Adds the specified component to the layout.
 void layoutContainer(Container c)
          Lays out the container.
 Dimension minimumLayoutSize(Container c)
          Returns the minimum dimensions needed to layout the visible components contained in the specified target container.
 Dimension preferredLayoutSize(Container c)
          Returns the preferred dimensions for this layout given the visible components in the specified target container.
 void removeLayoutComponent(Component c)
          Removes the specified component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SinLayout

public SinLayout()
Constructs a default SinLayout which glues component's borders to the respective left and right borders of their container.


SinLayout

public SinLayout(int cpc,
                 int zenith)
Constructs a SinLayout which glues component's borders to the respective left and right sinusoidal border of their container, with strict respect to their minimum size.

Parameters:
cpc - the number of component per period of the sinusoid.
zenith - the zenith of the sinusoid, in pixels.
Method Detail

addLayoutComponent

public void addLayoutComponent(String n,
                               Component c)
Adds the specified component to the layout. Not used by this class.

Specified by:
addLayoutComponent in interface LayoutManager

layoutContainer

public void layoutContainer(Container c)
Lays out the container.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
c - the container to be laid out

minimumLayoutSize

public Dimension minimumLayoutSize(Container c)
Returns the minimum dimensions needed to layout the visible components contained in the specified target container.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
c - the container to bo laid out.

preferredLayoutSize

public Dimension preferredLayoutSize(Container c)
Returns the preferred dimensions for this layout given the visible components in the specified target container.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
c - the container to bo laid out.

removeLayoutComponent

public void removeLayoutComponent(Component c)
Removes the specified component from the layout. Forces a repaint to clean the space previously used by the component in the container.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
c - the component to be removed.