net.xoetrope.xui.helper
Class XLayoutHelper

java.lang.Object
  extended by net.xoetrope.xui.helper.XLayoutHelper
All Implemented Interfaces:
LayoutHelper

public class XLayoutHelper
extends java.lang.Object
implements LayoutHelper

A helper class for working with layout managers. This class provides mappings between the names of layout styles and constraints and the corresponding Java constants.

Copyright (c) Xoetrope Ltd., 2002-2003

License: see license.txt

$Revision: 2.21 $


Field Summary
static int BOTTOM
           
static int LEFT
           
static int RIGHT
           
static int TOP
           
 
Constructor Summary
XLayoutHelper()
           
 
Method Summary
 java.lang.Object addLayout(java.lang.Object cont, int type)
          Sets a LayoutManager for the panel
 java.lang.Object addLayout(java.lang.Object cont, int type, java.util.Hashtable attribs)
          Sets a LayoutManager for the panel
 int getAlignment(java.lang.String name)
          Gets a constraint object corresponding to a constraint name
protected  java.lang.Integer getBoxAlignment(java.lang.String value)
          Convert an attribute value to the equivalent BoxLayout constant, defaults to x-axis if not found.
 java.lang.Object getConstraint(java.lang.String name)
          Gets a constraint object corresponding to a constraint name
protected  int getIntAttrib(java.util.Hashtable attribs, java.lang.String attrib)
          Get an attribute as an int value
 java.lang.String getLayoutClass(java.lang.Object layout)
          Get the layout type
 int getLayoutType(java.lang.String ls)
          Get the layout type enumerated in XPage
 boolean getUsesConstraints(java.lang.Object layout)
          Does the layout manager use constraints for its children?
 boolean getUsesDimensions(java.lang.Object layout)
          Does this layout manager used the absoulte dimensions?
 void setAttrib(java.lang.Object cont, java.lang.Object lm, java.lang.String attrib, java.lang.Object value)
          Set the attributes for a layout manager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values
Constructor Detail

XLayoutHelper

public XLayoutHelper()
Method Detail

addLayout

public java.lang.Object addLayout(java.lang.Object cont,
                                  int type)
Sets a LayoutManager for the panel

Specified by:
addLayout in interface LayoutHelper
Parameters:
cont - the container whose layout manager is being set or null to set the parent panel's layout manager
type - the layout manager as defined in the XLayoutHelper class

addLayout

public java.lang.Object addLayout(java.lang.Object cont,
                                  int type,
                                  java.util.Hashtable attribs)
Sets a LayoutManager for the panel

Specified by:
addLayout in interface LayoutHelper
Parameters:
cont - the container whose layout manager is being set or null to set the parent panel's layout manager
type - the layout manager as defined in the XLayoutHelper class

getAlignment

public int getAlignment(java.lang.String name)
Gets a constraint object corresponding to a constraint name

Specified by:
getAlignment in interface LayoutHelper
Parameters:
name - the constraint name
Returns:
the constraint object

getLayoutType

public int getLayoutType(java.lang.String ls)
Get the layout type enumerated in XPage

Specified by:
getLayoutType in interface LayoutHelper
Parameters:
ls - the layout style
Returns:
the type id

getLayoutClass

public java.lang.String getLayoutClass(java.lang.Object layout)
Get the layout type

Specified by:
getLayoutClass in interface LayoutHelper
Parameters:
layout - the layout manager instance
Returns:
the type name e.g. FLOW or BORDER

getUsesConstraints

public boolean getUsesConstraints(java.lang.Object layout)
Does the layout manager use constraints for its children?

Specified by:
getUsesConstraints in interface LayoutHelper
Parameters:
layout - the layout manager instance
Returns:
true if the layout uses constraints

getUsesDimensions

public boolean getUsesDimensions(java.lang.Object layout)
Does this layout manager used the absoulte dimensions?

Specified by:
getUsesDimensions in interface LayoutHelper
Parameters:
layout - the layout manager instance
Returns:
true if the X,Y,W,H dimensions are used

getConstraint

public java.lang.Object getConstraint(java.lang.String name)
Gets a constraint object corresponding to a constraint name

Specified by:
getConstraint in interface LayoutHelper
Parameters:
name - the quoted constraint name e.g. "WEST"
  • WEST=BorderLayout.WEST
  • EAST=BorderLayout.EAST
  • NORTH=BorderLayout.NORTH
  • SOUTH=BorderLayout.SOUTH
  • CENTER=BorderLayout.CENTER
  • AFTER_LAST_LINE=BorderLayout.AFTER_LAST_LINE
  • AFTER_LINE_ENDS=BorderLayout.AFTER_LINE_ENDS
  • BEFORE_FIRST_LINE=BorderLayout.BEFORE_FIRST_LINE
  • BEFORE_LINE_BEGINS=BorderLayout.BEFORE_LINE_BEGINS
  • GridBagConstraints=14 GridBagConstraint parameters separated by commas
    1. gridx - The initial gridx value
    2. gridy - The initial gridy value.
    3. gridwidth - The initial gridwidth value.
    4. gridheight - The initial gridheight value.
    5. weightx - The initial weightx value.
    6. weighty - The initial weighty value.
    7. anchorstr - The anchor string value (EAST|WEST|NORTH|SOUTH|NORTHEAST|NORTHWEST|SOUTHEAST|SOUTHWEST)
    8. fillstr - The fill string value (HORIZONTAL|VERTICAL)
    9. insets top - The initial inset
    10. insets left - The initial inset
    11. insets right - The initial inset
    12. insets bottom - The initial inset
    13. ipadx - The initial ipadx value
    14. ipady - The initial ipady value
Returns:
the constraint object

getIntAttrib

protected int getIntAttrib(java.util.Hashtable attribs,
                           java.lang.String attrib)
Get an attribute as an int value

Parameters:
attribs - the attribs hashtable
attrib - the attribute key
Returns:
the integer value

setAttrib

public void setAttrib(java.lang.Object cont,
                      java.lang.Object lm,
                      java.lang.String attrib,
                      java.lang.Object value)
Set the attributes for a layout manager

Specified by:
setAttrib in interface LayoutHelper
Parameters:
cont - the container
lm - the layout manager
attrib - the attribute name
value - the value of the attribute

getBoxAlignment

protected java.lang.Integer getBoxAlignment(java.lang.String value)
Convert an attribute value to the equivalent BoxLayout constant, defaults to x-axis if not found.

Parameters:
value - the attribute value specifying the alignment
Returns:
the equivalent BoxLayout integer constant