org.genepi.swing
Class TimeLineLayout

java.lang.Object
  extended by org.genepi.swing.TimeLineLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2

public final class TimeLineLayout
extends java.lang.Object
implements java.awt.LayoutManager2

The TimeLineLayout class is a layout manager that lays out a container's components on a TimeLine grid.

 import java.awt.*;
 import java.applet.Applet;
 public class TimeLine extends JFrame {
     public void buildPanel() {
         setLayout(new GraphPaperLayout());
         foo = new SimpleInterval(2,3);
         add(new IntervalView(foo,11,foo), foo);
     }
 }
 

Author:
Stˇphane Descorps-Declere

Constructor Summary
TimeLineLayout(java.awt.Container cont)
          Creates a map layout with the given grid size and padding.
TimeLineLayout(java.awt.Container cont, float scale)
           
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified name to the layout.
 float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the y axis.
protected  java.awt.Dimension getLayoutSize(java.awt.Container parent, boolean isPreferred)
          Algorithm for calculating layout size (minimum or preferred).
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container parent)
          Lays out the container in the specified container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum size of this component.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setConstraints(java.awt.Component comp, Interval cons)
           
 void setScale(float scale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeLineLayout

public TimeLineLayout(java.awt.Container cont)
Creates a map layout with the given grid size and padding.

Parameters:
gridSize - size of the graph paper in logical units (n x m)
hgap - horizontal padding
vgap - vertical padding

TimeLineLayout

public TimeLineLayout(java.awt.Container cont,
                      float scale)
Method Detail

setConstraints

public void setConstraints(java.awt.Component comp,
                           Interval cons)

setScale

public void setScale(float scale)

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component with the specified name to the layout. This does nothing in Layout, since constraints are required.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

removeLayoutComponent

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

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

getLayoutSize

protected java.awt.Dimension getLayoutSize(java.awt.Container parent,
                                           boolean isPreferred)
Algorithm for calculating layout size (minimum or preferred).

Parameters:
parent - the container in which to do the layout.
isPreferred - true for calculating preferred size, false for calculating minimum size.
Returns:
the dimensions to lay out the subcomponents of the specified container.
See Also:
java.awt.GraphPaperLayout#getLargestCellSize

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container in the specified container.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the component which needs to be laid out

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
See Also:
Component.getMinimumSize(), Component.getPreferredSize(), LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2