Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

openfuture.util.layout
Class XmFormLayout  view XmFormLayout download XmFormLayout.java

java.lang.Object
  extended byopenfuture.util.layout.XmFormLayout
All Implemented Interfaces:
java.awt.LayoutManager

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


Field Summary
(package private) static boolean bigDebug
           
(package private) static int BITSET
           
(package private) static int BOTTOM
           
(package private)  boolean changedFlag
           
(package private) static int COMPONENT
          Component tuple constants, these must range from 0...6.
(package private)  java.lang.String[] constraints
           
(package private) static boolean debug
           
(package private) static int FORM
          Other constants.
(package private)  java.awt.Dimension formDimensions
           
(package private)  java.awt.Point formLocation
           
(package private) static int INVALID
           
(package private) static int LEFT
           
(package private)  java.lang.String myName
          The constraints and the results of the last reshape() computations.
(package private) static int NAME
           
(package private)  java.util.Hashtable nameToIndex
           
(package private) static int RIGHT
           
(package private) static int TOP
           
(package private)  java.util.Vector tuples
           
(package private) static int UNBOUND
           
 
Constructor Summary
XmFormLayout(java.lang.String constraintsURLOrFile)
          The constructor for reading constraints from file or URL
XmFormLayout(java.lang.String[] newConstraints)
          The constructor.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component component)
          Add a component.
private  int evaluate(java.lang.String expression)
          Parses an expression 'a.b+c' (or 'a.b-c' or 'a.b' or '+c' or '-c') into an rvalue 'a.b' and a signed number 'c'.
private  boolean explicit(java.util.BitSet constraintBitset)
          Enforce explicit constraints by binding lvalues and also marking those lvalues which can't be bound.
private  int getAttr(int componentNr, int attrNr)
          If the attribute is bound then return its' value, otherwise return XmFormLayout.UNBOUND.
private  int getAttr(java.lang.String fqAttrName)
          If the attribute is bound then return its' value, otherwise return XmFormLayout.UNBOUND.
private  int getAttrNr(java.lang.String attrName)
           
private  java.util.BitSet getBitset(int componentNr)
           
private  java.awt.Component getComponent(int componentNr)
           
private  java.lang.String getComponentName(int componentNr)
           
private  int getComponentNr(java.lang.String componentName)
           
private  int getOffset(int componentNr, int attrNr)
          Returns the preferred offset (width or height) between the specified attribute and its' opposite.
private  boolean implicit()
          Enforces implicit constraints by binding component attributes which haven't an lvalue in ANY explicit constraint and whose opposite attribute is already bound, e.g.
private  boolean isBound(int componentNr, int attributeNr)
          Returns true if this component's attribute was bound; that is, if this.setAttr() was called.
private  boolean isMarked(int componentNr, int attributeNr)
          Returns true if this component's attribute is an lvalue in any explicit constraint; that is, if this.setMarked() was called.
 void layoutContainer(java.awt.Container parent)
          Reshape all components in the container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          XmFormLayout knowns only one size (the preferred size).
private  int opposite(int attrNr)
           
private  int[] parseAttr(java.lang.String fqAttrName)
          Parse a fully-qualified attribute name 'a.b' into a component 'a' and an attribute 'b', and return the component number and attribute number.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size for this container, taking into account the components it contains.
private  void processConstraints(java.lang.String[] newConstraints)
           
private  java.lang.String[] readConstraintsFromFile(java.lang.String fileConstraints)
           
private  java.lang.String[] readConstraintsFromStream(java.io.BufferedReader inStream)
           
private  java.lang.String[] readConstraintsFromURL(java.lang.String urlConstraints)
           
private  void reconstrain()
          Layout the container according to constraints.
private  java.lang.String removeBlanks(java.lang.String name)
          remove blanks from a constraint and return the result
 void removeLayoutComponent(java.awt.Component oldComponent)
          Removes a component.
private  void reshape(int x, int y, int w, int h)
          If the container's location or shape has changed, or if any of the component's have changed, then re-compute the constraints; otherwise use what was already computed.
private  boolean setAttr(int componentNr, int attrNr, int value)
          Try to set a attribute; returns true if the was set or false if it was deferred (the latter will happen if the value is XmFormLayout.UNBOUND).
private  boolean setAttr(java.lang.String fqAttrName, int value)
          Try to set a attribute 'c.a'; returns true if the was set or false if it was deferred (the latter will happen if the value is XmFormLayout.UNBOUND).
private  void setBound(int componentNr, int attrNr)
           
private  void setMarked(int componentNr, int attrNr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT

static final int COMPONENT
Component tuple constants, these must range from 0...6. Attribute numbers must range from BOTTOM...TOP.

See Also:
Constant Field Values

BOTTOM

static final int BOTTOM
See Also:
Constant Field Values

LEFT

static final int LEFT
See Also:
Constant Field Values

RIGHT

static final int RIGHT
See Also:
Constant Field Values

TOP

static final int TOP
See Also:
Constant Field Values

BITSET

static final int BITSET
See Also:
Constant Field Values

NAME

static final int NAME
See Also:
Constant Field Values

FORM

static final int FORM
Other constants.

See Also:
Constant Field Values

INVALID

static final int INVALID
See Also:
Constant Field Values

UNBOUND

static final int UNBOUND
See Also:
Constant Field Values

debug

static final boolean debug
See Also:
Constant Field Values

bigDebug

static final boolean bigDebug
See Also:
Constant Field Values

myName

java.lang.String myName
The constraints and the results of the last reshape() computations.


formDimensions

java.awt.Dimension formDimensions

formLocation

java.awt.Point formLocation

tuples

java.util.Vector tuples

nameToIndex

java.util.Hashtable nameToIndex

constraints

java.lang.String[] constraints

changedFlag

boolean changedFlag
Constructor Detail

XmFormLayout

public XmFormLayout(java.lang.String[] newConstraints)
The constructor.


XmFormLayout

public XmFormLayout(java.lang.String constraintsURLOrFile)
The constructor for reading constraints from file or URL

Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component component)
Add a component.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

evaluate

private final int evaluate(java.lang.String expression)
                    throws java.lang.Exception
Parses an expression 'a.b+c' (or 'a.b-c' or 'a.b' or '+c' or '-c') into an rvalue 'a.b' and a signed number 'c'. If the rvalue is unbound then return XmFormLayout.UNBOUND, otherwise return the value of the expression.


explicit

private final boolean explicit(java.util.BitSet constraintBitset)
                        throws java.lang.Exception
Enforce explicit constraints by binding lvalues and also marking those lvalues which can't be bound. Parses an explicit constraint 'a.b=c.d+e' into an lvalue 'a.b' and an expression 'c.d+e'. Returns true if all possible explicit lvalues are bound.


getAttr

private final int getAttr(int componentNr,
                          int attrNr)
If the attribute is bound then return its' value, otherwise return XmFormLayout.UNBOUND.


getAttr

private final int getAttr(java.lang.String fqAttrName)
                   throws java.lang.Exception
If the attribute is bound then return its' value, otherwise return XmFormLayout.UNBOUND.


getAttrNr

private final int getAttrNr(java.lang.String attrName)

getBitset

private final java.util.BitSet getBitset(int componentNr)

getComponent

private final java.awt.Component getComponent(int componentNr)

getComponentName

private final java.lang.String getComponentName(int componentNr)

getComponentNr

private final int getComponentNr(java.lang.String componentName)
                          throws java.lang.Exception

getOffset

private final int getOffset(int componentNr,
                            int attrNr)
Returns the preferred offset (width or height) between the specified attribute and its' opposite.


implicit

private final boolean implicit()
                        throws java.lang.Exception
Enforces implicit constraints by binding component attributes which haven't an lvalue in ANY explicit constraint and whose opposite attribute is already bound, e.g. if foo.top isn't an lvalue in any explicit constraint, and foo.bottom is bound, and foo has a preferred height of 123, then enforce this implicit constraint: "foo.top=foo.bottom-123" Returns true if all possible implicit constraints are bound.


isBound

private final boolean isBound(int componentNr,
                              int attributeNr)
Returns true if this component's attribute was bound; that is, if this.setAttr() was called.


isMarked

private final boolean isMarked(int componentNr,
                               int attributeNr)
Returns true if this component's attribute is an lvalue in any explicit constraint; that is, if this.setMarked() was called.


layoutContainer

public void layoutContainer(java.awt.Container parent)
Reshape all components in the container. Typically, this causes a call to this.reconstrain() only the first time.

Specified by:
layoutContainer in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
XmFormLayout knowns only one size (the preferred size).

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

opposite

private final int opposite(int attrNr)

parseAttr

private final int[] parseAttr(java.lang.String fqAttrName)
                       throws java.lang.Exception
Parse a fully-qualified attribute name 'a.b' into a component 'a' and an attribute 'b', and return the component number and attribute number.


preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Description copied from interface: java.awt.LayoutManager
Calculates the preferred size for this container, taking into account the components it contains.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

processConstraints

private void processConstraints(java.lang.String[] newConstraints)

readConstraintsFromFile

private java.lang.String[] readConstraintsFromFile(java.lang.String fileConstraints)

readConstraintsFromStream

private java.lang.String[] readConstraintsFromStream(java.io.BufferedReader inStream)

readConstraintsFromURL

private java.lang.String[] readConstraintsFromURL(java.lang.String urlConstraints)

reconstrain

private final void reconstrain()
                        throws java.lang.Exception
Layout the container according to constraints. This may be time-consuming, so it should only be done if changedFlag is true.


removeBlanks

private java.lang.String removeBlanks(java.lang.String name)
remove blanks from a constraint and return the result


removeLayoutComponent

public void removeLayoutComponent(java.awt.Component oldComponent)
Removes a component. This isn't particularly fast, but it is rarely called, if ever.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

reshape

private final void reshape(int x,
                           int y,
                           int w,
                           int h)
If the container's location or shape has changed, or if any of the component's have changed, then re-compute the constraints; otherwise use what was already computed.


setAttr

private final boolean setAttr(int componentNr,
                              int attrNr,
                              int value)
                       throws java.lang.Exception
Try to set a attribute; returns true if the was set or false if it was deferred (the latter will happen if the value is XmFormLayout.UNBOUND).


setAttr

private final boolean setAttr(java.lang.String fqAttrName,
                              int value)
                       throws java.lang.Exception
Try to set a attribute 'c.a'; returns true if the was set or false if it was deferred (the latter will happen if the value is XmFormLayout.UNBOUND).


setBound

private final void setBound(int componentNr,
                            int attrNr)

setMarked

private final void setMarked(int componentNr,
                             int attrNr)