CH.ifa.draw.contrib
Class StandardLayouter

java.lang.Object
  extended by CH.ifa.draw.contrib.StandardLayouter
All Implemented Interfaces:
Layouter, Storable, java.io.Serializable

public class StandardLayouter
extends java.lang.Object
implements Layouter

A StandardLayouter contains standard algorithm for layouting a Layoutable. As a standard behaviour all child components of a Layoutable are laid out underneath each other starting from top to bottom while the x position of all child components stays the same and the width is forced to the width of the maximum width. At the end the presentation figure of the Layoutable is set to the maximum x and y size to encompass all contained child components graphically as well.

See Also:
Serialized Form

Constructor Summary
StandardLayouter()
          Default constructor which is needed for the Storable mechanism.
StandardLayouter(Layoutable newLayoutable)
          Constructor which associates a StandardLayouter with a certain Layoutable.
 
Method Summary
 java.awt.Rectangle calculateLayout(java.awt.Point origin, java.awt.Point corner)
           
 java.awt.Insets getInsets()
          Get the insets for spacing between the figure and its subfigures
 Layoutable getLayoutable()
          Get the figure upon which the layout strategy operates.
 java.awt.Rectangle layout(java.awt.Point origin, java.awt.Point corner)
          Method which lays out a figure.
 void read(StorableInput dr)
          Reads the contained figures from StorableInput.
 void setInsets(java.awt.Insets newInsets)
          Set the insets for spacing between the figure and its subfigures
 void setLayoutable(Layoutable newLayoutable)
          Set the figure upon which the layout strategy operates.
 void write(StorableOutput dw)
          Writes the contained figures to the StorableOutput.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardLayouter

public StandardLayouter()
Default constructor which is needed for the Storable mechanism. Usually, the constructor which takes a Layoutable should be used as each StandardLayouter is associated with exactly one Layoutable.


StandardLayouter

public StandardLayouter(Layoutable newLayoutable)
Constructor which associates a StandardLayouter with a certain Layoutable.

Parameters:
newLayoutable - Layoutable to be laid out
Method Detail

getLayoutable

public Layoutable getLayoutable()
Get the figure upon which the layout strategy operates.

Returns:
associated figure which should be laid out

setLayoutable

public void setLayoutable(Layoutable newLayoutable)
Set the figure upon which the layout strategy operates.

Parameters:
newLayoutable - Layoutable to be laid out

calculateLayout

public java.awt.Rectangle calculateLayout(java.awt.Point origin,
                                          java.awt.Point corner)
Specified by:
calculateLayout in interface Layouter

layout

public java.awt.Rectangle layout(java.awt.Point origin,
                                 java.awt.Point corner)
Method which lays out a figure. It is called by the figure if a layout task is to be performed. First, the layout dimension for the figure is calculated and then the figure is arranged newly. All child component are place beneath another. The figure and all its children are forced to the minimium width

Specified by:
layout in interface Layouter
Parameters:
origin - start point for the layout
corner - minimum corner point for the layout

read

public void read(StorableInput dr)
          throws java.io.IOException
Reads the contained figures from StorableInput.

Specified by:
read in interface Storable
Throws:
java.io.IOException

write

public void write(StorableOutput dw)
Writes the contained figures to the StorableOutput.

Specified by:
write in interface Storable

setInsets

public void setInsets(java.awt.Insets newInsets)
Set the insets for spacing between the figure and its subfigures

Specified by:
setInsets in interface Layouter
Parameters:
newInsets - new spacing dimensions

getInsets

public java.awt.Insets getInsets()
Get the insets for spacing between the figure and its subfigures

Specified by:
getInsets in interface Layouter
Returns:
spacing dimensions