net.xoetrope.optional.layout
Class GuideLayout

java.lang.Object
  extended by net.xoetrope.optional.layout.ScaleLayout
      extended by net.xoetrope.optional.layout.GuideLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, XLayoutSupport
Direct Known Subclasses:
GuideLayoutEx

public class GuideLayout
extends ScaleLayout
implements java.awt.LayoutManager2, XLayoutSupport

A guide layout manager. Uses the guides setup in the KalIDEoscope to control the layout. Guides can be positioned absolutely in terms of pixels, relative to one another or relative to the container so that they scale as the page is resized.

Copyright (c) Xoetrope Ltd., 2002-2005

$Revision: 1.12 $


Field Summary
protected  java.util.Hashtable constraints
           
protected  java.awt.Component page
           
 
Constructor Summary
GuideLayout()
          Creates a new instance of GuideLayout
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object objConstraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
protected  Guide[] findGuides(java.lang.Object compConstraints)
          Get the component constraints.
 java.lang.Object getConstraints(java.lang.Object comp)
          Get the layout constraints
 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.
 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 specified container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Calculates the maximum size dimensions for the specified container, given the components it contains.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified container, given the components it contains.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified container, given the components it contains.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setPage(java.awt.Component comp)
          Set the root or page for the layout.
 
Methods inherited from class net.xoetrope.optional.layout.ScaleLayout
getScaleAll, getScaleFonts, iterateComps, scaleComponent, setScaleAll, setScaleFonts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraints

protected java.util.Hashtable constraints

page

protected java.awt.Component page
Constructor Detail

GuideLayout

public GuideLayout()
Creates a new instance of GuideLayout

Method Detail

layoutContainer

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

Specified by:
layoutContainer in interface java.awt.LayoutManager
Overrides:
layoutContainer in class ScaleLayout
Parameters:
parent - the container to be laid out

findGuides

protected Guide[] findGuides(java.lang.Object compConstraints)
Get the component constraints. In this case the reference is assumed to be an array of the guide objects. Derived classes may specify the constraints in other ways.

Parameters:
compConstraints - the constraints specification or reference
Returns:
an array of component constraints, one for each of the four edges

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object objConstraints)
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
objConstraints - where/how the component is added to the layout.

preferredLayoutSize

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

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Overrides:
preferredLayoutSize in class ScaleLayout
Parameters:
parent - the container to be laid out
Returns:
the preferred layout size
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

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

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Overrides:
minimumLayoutSize in class ScaleLayout
Parameters:
parent - the component to be laid out
Returns:
the max layout size
See Also:
preferredLayoutSize(java.awt.Container)

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Calculates the maximum size dimensions for the specified container, given the components it contains.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
Parameters:
target -
Returns:
the max layout size
See Also:
Component.getMaximumSize(), 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
Parameters:
target - the container to lay out

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
Parameters:
target - the container to lay out

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
Parameters:
target - the container to lay out

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Overrides:
addLayoutComponent in class ScaleLayout
Parameters:
name - the string to be associated with the component
comp - the component to be added

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 ScaleLayout
Parameters:
comp - the component to be removed

getConstraints

public java.lang.Object getConstraints(java.lang.Object comp)
Get the layout constraints

Specified by:
getConstraints in interface XLayoutSupport
Parameters:
comp - the component for which the constraints are being retrieved
Returns:
the constraints or null if none have been specified.

setPage

public void setPage(java.awt.Component comp)
Set the root or page for the layout. The guides are specified in terms of this object.

Parameters:
comp - the root component