net.goui.awt
Class GoLayout.Cell

java.lang.Object
  extended bynet.goui.util.GraphLayout.Edge
      extended bynet.goui.awt.GoLayout.Cell
All Implemented Interfaces:
GraphLayout.EdgeConstraint
Enclosing class:
GoLayout

public final class GoLayout.Cell
extends GraphLayout.Edge

Author:
David Beaumont, Copyright 2005

This class encapsulates a cell within the layout structure. Instances of this class are obtained by using the getCell() method of Row. Primarily knowledge of this class will be required if you wish to modify the attributes of a Cell after the layout has been created.


Method Summary
 boolean getActive()
          Return the active status of this Cell.
 int getAlignment()
          This method returns the vertical alignment constant for this Cell.
 java.awt.Dimension getCellSize()
          Returns the current explicitly set size for this Cell.
 int getComponentIndex()
          This method returns the Component index for this Cell.
 int getMaxSize()
          This method exists as part of the internal implementation of the GoLayout classes and should not be called directly.
 int getMinSize()
          This method exists as part of the internal implementation of the GoLayout classes and should not be called directly.
 int getWeight()
          This method returns the horizontal layout weight for this Cell.
 void invalidate()
          This method exists as part of the internal implementation of the GoLayout classes and should not be called directly.
 void setActive(boolean flag)
          This methods controls whether the Cell is active or not.
 void setAlignment(int align)
          This method sets the vertical alignment for this Cell.
 void setCellSize(int width, int height)
          This method is used to override the minimum and preferred size of the Component with which this Cell is associated or to explicitly set a size for an empty Cell.
 void setComponentIndex(int index)
          This method sets the Component index for this Cell.
 void setWeight(int weight)
          Set the weight of this Cell instance.
 
Methods inherited from class net.goui.util.GraphLayout.Edge
getSize, getVertexNeg, getVertexPos, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setActive

public void setActive(boolean flag)
This methods controls whether the Cell is active or not. By default a Cell is active and will be laid out normally within the layout. An inactive Cell will not be laid out and it is as if that Cell was never specified in the original layout string. Note that setting a Cell to be inactive has exactly the same effect as temporarily setting the Cell to have zero width and height, but using this method will not modify the Cell's size and avoids the need to restore the size value later.

Note that if the active status of a Cell is changed then any Containers using the associated layout will need to be laid out again before the changes will take effect.

Parameters:
flag - The boolean which controls if the Cell is active.

getActive

public boolean getActive()
Return the active status of this Cell.

Returns:
The current active status of the Cell.

setAlignment

public void setAlignment(int align)
This method sets the vertical alignment for this Cell.

Parameters:
align - The vertical alignment constant.

getAlignment

public int getAlignment()
This method returns the vertical alignment constant for this Cell.

Returns:
The vertical alignment for this Cell.

setComponentIndex

public void setComponentIndex(int index)
This method sets the Component index for this Cell. The Component index should be a non-negative number which corresponds to the index of the Component with which this Cell will be associated or -1 to make the Cell empty.

Note that if during the layout of a Container, a Cell's index does not correspond to a Component within the Container then an exception will be thrown and it is up to the user of this class to ensure that any explicitly set indices on Cells correspond to valid Components.

Parameters:
index - The index of the Component for this Cell or -1.

getComponentIndex

public int getComponentIndex()
This method returns the Component index for this Cell. If the Cell is empty then -1 will be returned.

Returns:
The index of the Component for this Cell or -1.

setCellSize

public void setCellSize(int width,
                        int height)
This method is used to override the minimum and preferred size of the Component with which this Cell is associated or to explicitly set a size for an empty Cell. If a non-negative value is passed in for either the width or the height then that value will become the size of this Cell, ignoring any constraints that the Component may have. Passing in a negative value will restore the default behaviour. The width and height values are independent and one dimension can be set to a specific value while the other uses the associated Component.

Note that this method is the only way in which a Component can be laid out below its minimum size and care should be taken when using it to ensure that any sizes used are always sufficient to ensure that the Components will always be rendered correctly.

Also because this method is not advocated for normal use, the layout string syntax does not support the declaration of an explicit size for a Cell so this method is the only means by which this behaviour can be controlled.

Parameters:
width - The forced width for this Cell or -1.
height - The forced width for this Cell or -1.

getCellSize

public java.awt.Dimension getCellSize()
Returns the current explicitly set size for this Cell. If either the width or height are negative then there is no explicit size for that dimension and the minimum / preferred size of the Cell's Component will be used as normal.

Returns:
A new Dimension instance holding the current explicit size for this Cell.

setWeight

public void setWeight(int weight)
Set the weight of this Cell instance. This method modifies the existing weight of this Cell and will affect the horizontal layout of Components. Setting a value here has the same effect as specifying the same weight value for this Cell in the original layout string with which the GraphLayout was constructed.

Parameters:
weight - The non-negative weight value for this Cell.

getWeight

public int getWeight()
This method returns the horizontal layout weight for this Cell.

Specified by:
getWeight in interface GraphLayout.EdgeConstraint
Overrides:
getWeight in class GraphLayout.Edge
Returns:
The non-negative weight of this Row.
See Also:
GraphLayout.EdgeConstraint

getMinSize

public int getMinSize()
This method exists as part of the internal implementation of the GoLayout classes and should not be called directly.

Specified by:
getMinSize in interface GraphLayout.EdgeConstraint
Overrides:
getMinSize in class GraphLayout.Edge
See Also:
GraphLayout.EdgeConstraint

getMaxSize

public int getMaxSize()
This method exists as part of the internal implementation of the GoLayout classes and should not be called directly.

Specified by:
getMaxSize in interface GraphLayout.EdgeConstraint
Overrides:
getMaxSize in class GraphLayout.Edge
See Also:
GraphLayout.EdgeConstraint

invalidate

public void invalidate()
This method exists as part of the internal implementation of the GoLayout classes and should not be called directly.

Specified by:
invalidate in interface GraphLayout.EdgeConstraint
Overrides:
invalidate in class GraphLayout.Edge
See Also:
GraphLayout.EdgeConstraint