net.xoetrope.optional.layout
Class ScaleLayout

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

public class ScaleLayout
extends java.lang.Object
implements java.awt.LayoutManager

A scaling layout manager. Scales the components in proportion to their original layout size relative to the original container size

Copyright (c) Xoetrope Ltd., 2002-2007

License: see License.txt

$Revision: 1.2 $


Constructor Summary
ScaleLayout()
           
ScaleLayout(int designWidth, int designHeight)
          Creates a new ScaleLayout
ScaleLayout(int designWidth, int designHeight, boolean scales)
          Creates a new ScaleLayout
 
Method Summary
 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.
 boolean getScaleAll()
          Sets the state of the scale all flag.
 boolean getScaleFonts()
          Sets the state of the scale fonts flag.
protected  void iterateComps(java.awt.Component comp)
          Modify this component and its children, if any
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container.
 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 scaleComponent(java.awt.Component comp)
          Scale the component
 void setScaleAll(boolean scales)
          Sets the state of the scale all flag.
 void setScaleFonts(boolean scales)
          Sets the state of the scale fonts flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScaleLayout

public ScaleLayout()

ScaleLayout

public ScaleLayout(int designWidth,
                   int designHeight)
Creates a new ScaleLayout

Parameters:
designWidth - the original design width for the container
designHeight - the original design height for the container

ScaleLayout

public ScaleLayout(int designWidth,
                   int designHeight,
                   boolean scales)
Creates a new ScaleLayout

Parameters:
designWidth - the original design width for the container
designHeight - the original design height for the container
scales - true to scale all the children including containers and the container's children.
false to scale only the container that owns this layout and any child container with a null layout.
Method Detail

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
Parameters:
name - the string to be associated with the component
comp - the component to be added

layoutContainer

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

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

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
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

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
Parameters:
parent - the container to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

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

iterateComps

protected void iterateComps(java.awt.Component comp)
Modify this component and its children, if any

Parameters:
comp - the component to be modified

scaleComponent

public void scaleComponent(java.awt.Component comp)
Scale the component

Parameters:
comp - the component to be modified

setScaleAll

public void setScaleAll(boolean scales)
Sets the state of the scale all flag. Does not layout the container.

Parameters:
scales - true to scale all the children including containers and the container's children.
false to scale only the container that owns this layout and any child container with a null layout.

getScaleAll

public boolean getScaleAll()
Sets the state of the scale all flag. Does not layout the container.

Returns:
true if all the children including containers and the container's children are scaled, otherwise false when only the container that owns this layout and any child container with a null layout are scaled.

setScaleFonts

public void setScaleFonts(boolean scales)
Sets the state of the scale fonts flag.

Parameters:
scales - true to scale all the fonts of a rescaled container
false to leave the font unchanged.

getScaleFonts

public boolean getScaleFonts()
Sets the state of the scale fonts flag. Does not layout the container.

Returns:
true if fonts in the children are scaled, false when no changes are made to the fonts.