attachlayout
Class AttachLayout.Constraints

java.lang.Object
  |
  +--attachlayout.AttachLayout.Constraints
Enclosing class:
AttachLayout

public static class AttachLayout.Constraints
extends java.lang.Object

Defines constraints by specifying an anchor, connection type and offset for every side of the component to lay out. Can only be used in containers with an AttachLayout layout manager.


Constructor Summary
AttachLayout.Constraints()
          Constructs a new Constraints object.
 
Method Summary
 void addToColumn(java.lang.String boxName, boolean leftElastic, int leftOffset, boolean rightElastic, int rightOffset)
          Attaches a component's left and right side to the left and right side of the specified box.
 void addToRow(java.lang.String boxName, boolean topElastic, int topOffset, boolean bottomElastic, int bottomOffset)
          Attaches a component's top and bottom side to the top and bottom side of the specified box.
 void attachNone(int side)
          Sets a side to be attached to nothing.
 void attachToBorder(int side, boolean elastic, int offset)
          Attaches a component's side to the container's border.
 void attachToBox(int side, boolean elastic, int offset, java.lang.String boxName, int anchorSide)
          Attaches a component's side to a box defined in the same container.
 void attachToComponent(int side, boolean elastic, int offset, java.awt.Component anchor, int anchorSide)
          Attaches a component's side to another component in the same container.
 void attachToComponents(int side, boolean elastic, int offset, java.awt.Component[] anchors, int anchorSide)
          Deprecated. use AttachLayout.defineBox(java.lang.String, attachlayout.AttachLayout.Constraints) and attachToBox(int, boolean, int, java.lang.String, int), addToColumn(java.lang.String, boolean, int, boolean, int) or addToRow(java.lang.String, boolean, int, boolean, int) instead.
 void attachToRelativePosition(int side, boolean elastic, int offset, int percentage)
          Sets a side to be attached to a relative position.
 void setHorizontalAlignment(int percentage)
          Sets the alignment in case both left and right connection types are set to elastic.
 void setMinimumHeight(int height)
          Sets the minimum height for the attached component.
 void setMinimumWidth(int width)
          Sets the minimum width for the attached component.
 void setPreferredHeight(int height)
          Sets the preferred height for the attached component.
 void setPreferredWidth(int width)
          Sets the preferred width for the attached component.
 void setVerticalAlignment(int percentage)
          Sets the alignment in case both top and bottom connection types are set to elastic.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachLayout.Constraints

public AttachLayout.Constraints()
Constructs a new Constraints object. All sides (top, left, bottom and right) are set to "not connected" and all offsets are set to 0.
Constraint instances may be reused to define the Constraints for several different components. Their settings are copied by the layout manager when the component is added.
Method Detail

attachToBorder

public void attachToBorder(int side,
                           boolean elastic,
                           int offset)
Attaches a component's side to the container's border. When the TOP side of a component is attached, the anchor will be the container's top layout border, for the LEFT side the anchor is the container's left layout border, etc. The container's layout border is defined by the edge of the container minus container insets.
Parameters:
side - the side of the component to attach to the container's border. One of TOP, LEFT, BOTTOM, RIGHT.
elastic - when true, the offset defines a minimum offset, when false the offset defines an exact offset.
offset - number of pixels to offset from the anchor. Positive offsets are defined as pointing to the given side of the component. Thus a positive left offset moves the component's left side to the right while a positive right offset moves the component's right side to the left.
Throws:
java.lang.IllegalArgumentException - when side is not a valid side.

attachToComponent

public void attachToComponent(int side,
                              boolean elastic,
                              int offset,
                              java.awt.Component anchor,
                              int anchorSide)
Attaches a component's side to another component in the same container.
Parameters:
side - the side of the component to attach to the other component. One of TOP, LEFT, BOTTOM, RIGHT.
elastic - when true this attachment defines a minimum offset, when false the attachment defines an exact offset.
offset - number of pixels to offset from the anchor. Positive offsets are defined as pointing from the anchor to the component. Thus a positive left offset moves the component's left side to the right while a positive right offset moves the component's right side to the left.
anchor - the component to attach to.
anchorSide - the side of the anchor to attach to. One of TOP, LEFT, BOTTOM, RIGHT.
Throws:
java.lang.IllegalArgumentException - when an invalid side or anchorSide is given. A left or right side can only be attached to another component's left or right side. A top or a bottom side can only be attached to another component's top or bottom side.

attachToBox

public void attachToBox(int side,
                        boolean elastic,
                        int offset,
                        java.lang.String boxName,
                        int anchorSide)
Attaches a component's side to a box defined in the same container.
Parameters:
side - the side of the component to attach to the other component. One of TOP, LEFT, BOTTOM, RIGHT.
elastic - when true this attachment defines a minimum offset, when false the attachment defines an exact offset.
offset - number of pixels to offset from the anchor. Positive offsets are defined as pointing from the anchor to the component. Thus a positive left offset moves the component's left side to the right while a positive right offset moves the component's right side to the left.
boxName - the name of the box to attach to.
anchorSide - the side of the anchor to attach to. One of TOP, LEFT, BOTTOM, RIGHT.
Throws:
java.lang.IllegalArgumentException - when an invalid side or anchorSide is given. A left or right side can only be attached to another component's left or right side. A top or a bottom side can only be attached to another component's top or bottom side.

attachToComponents

public void attachToComponents(int side,
                               boolean elastic,
                               int offset,
                               java.awt.Component[] anchors,
                               int anchorSide)
Deprecated. use AttachLayout.defineBox(java.lang.String, attachlayout.AttachLayout.Constraints) and attachToBox(int, boolean, int, java.lang.String, int), addToColumn(java.lang.String, boolean, int, boolean, int) or addToRow(java.lang.String, boolean, int, boolean, int) instead.

Attaches a component's side to other components in the same container.
Parameters:
side - the side of the component to attach to the other component. One of TOP, LEFT, BOTTOM, RIGHT.
elastic - when true this attachment defines a minimum offset, when false the attachment defines an exact offset.
offset - number of pixels to offset from the anchor. Positive offsets are defined as pointing from the anchor to the component. Thus a positive left offset moves the component's left side to the right while a positive right offset moves the component's right side to the left.
anchors - a valid array of valid components to attach to. The components must be in the same container as the component being attached.
anchorSide - the side of the anchors to attach to. One of TOP, LEFT, BOTTOM, RIGHT. If anchorSide is LEFT, the final anchor position will be the leftmost left side of the components specified as anchors. If anchorside is RIGHT, the final anchor position will be the rightmost right side of the components specified as anchors. The same principle holds for TOP or BOTTOM attachments.
Throws:
java.lang.IllegalArgumentException - when an invalid side or anchorSide is given. A left or right side can only be attached to another component's left or right side. A top or a bottom side can only be attached to another component's top or bottom side.

attachNone

public void attachNone(int side)
Sets a side to be attached to nothing. This will allow the component to have its preferred size in the direction of the unattached side.
Remark that this may cause the component to be partially outside its container's edges.
Parameters:
side - the side of the component set free. One of TOP, LEFT, BOTTOM, RIGHT.
Throws:
java.lang.IllegalArgumentException - when an invalid side is given.

attachToRelativePosition

public void attachToRelativePosition(int side,
                                     boolean elastic,
                                     int offset,
                                     int percentage)
Sets a side to be attached to a relative position. A relative position is defined as a percentage of the container's layout area size. The layout area is the area inside the layout borders. The container's layout borders are defined by the edge of the container minus container insets.
For example, a relative position of 50 for the left side of a component, will attach the component's left side to the left-right center of the area in the container's layout borders.
Parameters:
side - the side of the component to attach to the relative position. One of TOP, LEFT, BOTTOM, RIGHT.
elastic - when true this attachment defines a minimum offset, when false the attachment defines an exact offset.
offset - number of pixels to offset from the anchor. Positive offsets are defined as pointing from the anchor to the component. Thus a positive left offset moves the component's left side to the right while a positive right offset moves the component's right side to the left.
percentage - the relative position in percentages; 0 is the left or top layout border of the container, 100 is the right or bottom layout border.
Throws:
java.lang.IllegalArgumentException - when an invalid side or an invalid percentage is given.

addToColumn

public void addToColumn(java.lang.String boxName,
                        boolean leftElastic,
                        int leftOffset,
                        boolean rightElastic,
                        int rightOffset)
Attaches a component's left and right side to the left and right side of the specified box. This way the the component is positioned inside the box's horizontal bounds. The box does not have to be a box that was defined as a column, any box will do. It also does not matter how the component is laid out vertically. Vertically the component may be outside the box's bounds.
Parameters:
boxName - the name of box to position the component in horizontally.
leftElastic - defines the nature of the left attachment, true to define a minimum offset, false to define an exact offset.
leftOffset - number of pixels to offset on the left side.
rightElastic - defines the nature of the right attachment, true to define a minimum offset, false to define an exact offset.
rightOffset - number of pixels to offset on the right side.

addToRow

public void addToRow(java.lang.String boxName,
                     boolean topElastic,
                     int topOffset,
                     boolean bottomElastic,
                     int bottomOffset)
Attaches a component's top and bottom side to the top and bottom side of the specified box. This way the the component is positioned inside the box's vertical bounds. The box does not have to be a box that was defined as a row, any box will do. It also does not matter how the component is laid out horizontally. Horizontally the component may be outside the box's bounds.
Parameters:
boxName - the name of box to position the component in vertically.
topElastic - defines the nature of the top attachment, true to define a minimum offset, false to define an exact offset.
topOffset - number of pixels to offset on the top side.
bottomElastic - defines the nature of the bottom attachment, true to define a minimum offset, false to define an exact offset.
bottomOffset - number of pixels to offset on the bottom side.

setPreferredWidth

public void setPreferredWidth(int width)
Sets the preferred width for the attached component. If not restricted by other layout constraints, this width will be set for the component laid out.
Parameters:
width - the preferred width for the attached component. Specifying COMPONENT_PREFERRED indicates the preferred width of the component.

setPreferredHeight

public void setPreferredHeight(int height)
Sets the preferred height for the attached component. If not restricted by other layout constraints, this height will be set for the component laid out.
Parameters:
height - the preferred height for the attached component. Specifying COMPONENT_PREFERRED indicates the default preferred height of the component.

setMinimumWidth

public void setMinimumWidth(int width)
Sets the minimum width for the attached component. If not restricted by other layout constraints, this width will be set for the component laid out.
Parameters:
width - the minimum width for the attached component. Specifying COMPONENT_PREFERRED indicates the minimum width of the component.

setMinimumHeight

public void setMinimumHeight(int height)
Sets the minimum height for the attached component. If not restricted by other layout constraints, this height will be set for the component laid out.
Parameters:
height - the minimum height for the attached component. Specifying COMPONENT_PREFERRED indicates the default minimum height of the component.

setVerticalAlignment

public void setVerticalAlignment(int percentage)
Sets the alignment in case both top and bottom connection types are set to elastic. When the available space for the component to lay out is greater than its preferred size, the free space is added to the offsets at the front and back side. The number given in this method indicates the percentage of free space to put at the front side of the component.
Parameters:
percentage - indicates the percentage of free space to add to the front side offset, (0 <= percentage <= 100).
Since:
2.3

setHorizontalAlignment

public void setHorizontalAlignment(int percentage)
Sets the alignment in case both left and right connection types are set to elastic. When the available space for the component to lay out is greater than its preferred size, the free space is added to the offsets at the front and back side. The number given in this method indicates the percentage of free space to put at the front side of the component.
Parameters:
percentage - indicates the percentage of free space to add to the front side offset, (0 <= percentage <= 100).
Since:
2.3

Copyright © 2003-2008, Paul Neyens SourceForge.net Logo
All Rights Reserved.