**Overview**

To develop an algorithm that positions a hierarchy of boxes and connecting lines on a page. Boxes shall never overlaps other boxes or any connecting lines. Each box shall be assigned a branch style which determines how it shall be positioned with respect to it peers and its manager.

# Input/Output

**Inputs**

- A Tree of boxes (each box knows its parent and its children)

The properties of a box are:

- Parent Box (null if root)
- Box Width
- Box Height
- Minimum External Margins (Top, Left, Bottom, Right)
- Minimum External Spacers (Top, Left, Bottom, Right)
- List of Rectangles that describe adorners
- Rectangle that is positioned with respect to the box
- 0 to n adornments per box
- Rectangles are never fully contained by parent box

- Branch Style
- Child boxes

**Outputs**

- Position of upper, left corner set for each box
- Line segments for connectors (need to define line segment relationships to associated boxes)

# External Margins

External margins shall be considered when checking if boxes overlap lines or other boxes. Margins for each side of a box (Top, Left, Bottom, Right) are independent (For example, Left = 10, Right =6).

# Sub-chart arrow

Some boxes have a sub-chart arrow associated with them. When positioning a box, the sub-chart arrow must be considered as its height may exceed the bottom margin.

# Branch Styles

The following branch styles are available:

Standard Styles:

- Tree Style
- Two column
- Four column
- Six column
- Eight column
- One column center right
- One column center left
- One column right
- One column left
- Stagger style

Assistant Styles:

- Assistant Peer Right
- Assistant Peer Left
- Assistant Right
- Assistant Left

A given set of subordinates can only have one 'Standard Style' and any number of Assistant Styles.

var enumBranchStyle = { tree:0, twocolumn:1, fourcolumn:2, sixcolumn:3, eightcolumn:4, onecolumncenterright:5, onecolumncenterleft:6, onecolumnright:7, onecolumnleft:8, placeholder:9,

assistantpeerright: 10, assistantpeerleft:11, assistantright:12, assistantleft:13 };

**Tree Style**

The tree forces all subordinates into a horizontal row beneath a manager. The tops of all subordinates in a 'tree group' must be aligned vertically.

**Two column**

The two column style forces all subordinates into 2 columns by 'n' rows. Where 'n' is determined by the number of boxes in the '2 column group'. Each row much be aligned vertically.

**Four column**

The four column style forces all subordinates into 4 columns by 'n' rows. Where 'n' is determined by the number of boxes in the '4 column group'. Each row much be aligned vertically.

**Six column**

The six column style forces all subordinates into 6 columns by 'n' rows. Where 'n' is determined by the number of boxes in the '6 column group'. Each row much be aligned vertically.

**Eight column**

The eight column style forces all subordinates into 8 columns by 'n' rows. Where 'n' is determined by the number of boxes in the ' 8 column group'. Each row much be aligned vertically.

**One column center right**

The One column center right style forces all subordinates into a single columns by 'n' rows. Where 'n' is determined by the number of boxes in the group. The vertical connecting line on the left is aligned with the left edge of the parent box.

**One column center left**

The One column center left style forces all subordinates into a single columns by 'n' rows. Where 'n' is determined by the number of boxes in the group. The vertical connecting line on the right is aligned with the right edge of the parent box.

**One column right**

The One column right style forces all subordinates into a single columns by 'n' rows. Where 'n' is determined by the number of boxes in the group. The vertical connecting line on the left is offset 12 pixels from the left edge of the parent box.

**One column left**

The One column center left style forces all subordinates into a single columns by 'n' rows. Where 'n' is determined by the number of boxes in the group. The vertical connecting line on the right offset 12 pixels from the right edge of the parent box.

# Connecting Lines

Line segments shall be returned as a list. Each segment shall contain a list of which boxes "own" the segment.