manage the column definitions within the layout grid

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/TestTableColumnLayout.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/TestTableColumnLayout.java
index e800a77..e58d050 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/TestTableColumnLayout.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/TestTableColumnLayout.java
@@ -19,11 +19,11 @@
 
 public class TestTableColumnLayout {
 
-	private TableColumnLayout layout;
+	private TableColumnDefinitions layout;
 
 	@Before
 	public void initLayout() {
-		layout = new TableColumnLayout();
+		layout = new TableColumnDefinitions();
 	}
 
 	@Test
@@ -76,6 +76,6 @@
 	@Test
 	public void givenChildLayout_whenColumnIsOnlyDefinedInParent_shouldProvideIndexFromParent() throws Exception {
 		layout.addColumn(1, "columnInParent", null);
-		assertThat(new TableColumnLayout(layout).getIndex("columnInParent"), is(equalTo(1)));
+		assertThat(new TableColumnDefinitions(layout).getIndex("columnInParent"), is(equalTo(1)));
 	}
 }
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java
index 057f591..11ed90d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java
@@ -29,7 +29,6 @@
 	private int height;
 	private final ArrayList<IStructuralBox> children = new ArrayList<IStructuralBox>();
 
-	private TableColumnLayout columnLayout = new TableColumnLayout();
 	private TableLayoutGrid layoutGrid = new TableLayoutGrid();
 
 	@Override
@@ -141,18 +140,6 @@
 		return children;
 	}
 
-	public void setColumnLayout(final TableColumnLayout columnLayout) {
-		if (columnLayout == null) {
-			this.columnLayout = new TableColumnLayout();
-		} else {
-			this.columnLayout = columnLayout;
-		}
-	}
-
-	public TableColumnLayout getColumnLayout() {
-		return columnLayout;
-	}
-
 	public TableLayoutGrid getLayoutGrid() {
 		return layoutGrid;
 	}
@@ -182,10 +169,6 @@
 	}
 
 	private void layoutColumns(final Graphics graphics) {
-		if (columnLayout.getLastIndex() > 0) {
-			columnLayout = new TableColumnLayout(columnLayout.getParentLayout());
-		}
-		TableColumnLayout.addColumnLayoutInformationForChildren(graphics, this, columnLayout);
 		TableLayoutGrid.setupLayoutGrid(graphics, this, layoutGrid);
 	}
 
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
index d64911c..e8ab3e8 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
@@ -25,8 +25,6 @@
 
 	private IHeightAdjustableBox component;
 
-	private int startColumnIndex;
-	private int endColumnIndex;
 	private String columnName;
 	private String startColumnName;
 	private String endColumnName;
@@ -123,22 +121,6 @@
 		return component;
 	}
 
-	public int getStartColumnIndex() {
-		return startColumnIndex;
-	}
-
-	public void setStartColumnIndex(final int startColumnIndex) {
-		this.startColumnIndex = startColumnIndex;
-	}
-
-	public int getEndColumnIndex() {
-		return endColumnIndex;
-	}
-
-	public void setEndColumnIndex(final int endColumnIndex) {
-		this.endColumnIndex = endColumnIndex;
-	}
-
 	public String getColumnName() {
 		return columnName;
 	}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnDefinitions.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnDefinitions.java
new file mode 100644
index 0000000..3dfc7dd
--- /dev/null
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnDefinitions.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Florian Thienel and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * 		Florian Thienel - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.core.internal.boxes;
+
+import java.util.HashMap;
+
+/**
+ * @author Florian Thienel
+ */
+public class TableColumnDefinitions {
+
+	private final TableColumnDefinitions parent;
+	private int width;
+
+	private int lastIndex;
+	private final HashMap<String, Span> spanByName = new HashMap<String, Span>();
+
+	public TableColumnDefinitions() {
+		this(null);
+	}
+
+	public TableColumnDefinitions(final TableColumnDefinitions parent) {
+		this.parent = parent;
+	}
+
+	public int addColumn(final int index, final String name, final String width) {
+		final int columnIndex;
+		if (index <= lastIndex) {
+			columnIndex = lastIndex += 1;
+		} else {
+			columnIndex = lastIndex = index;
+		}
+
+		if (name != null) {
+			spanByName.put(name, new Span(columnIndex));
+		}
+
+		return columnIndex;
+	}
+
+	public void addSpan(final int startIndex, final int endIndex, final String name) {
+		spanByName.put(name, new Span(startIndex, endIndex));
+	}
+
+	public int getWidth() {
+		return width;
+	}
+
+	public void setWidth(final int width) {
+		this.width = width;
+	}
+
+	public int getLastIndex() {
+		return lastIndex;
+	}
+
+	public boolean isEmpty() {
+		return lastIndex == 0;
+	}
+
+	public int getIndex(final String name) {
+		return getStartIndex(name);
+	}
+
+	public int getStartIndex(final String name) {
+		return getSpan(name).start;
+	}
+
+	public int getEndIndex(final String name) {
+		return getSpan(name).end;
+	}
+
+	private Span getSpan(final String name) {
+		if (spanByName.containsKey(name)) {
+			return spanByName.get(name);
+		}
+		if (parent != null) {
+			return parent.getSpan(name);
+		}
+		return Span.NULL;
+	}
+
+	public int getWidth(final int startIndex, final int endIndex) {
+		return 0;
+	}
+
+	public int getWidth(final int index) {
+		return 0;
+	}
+
+	private static class Span {
+		public static final Span NULL = new Span(0, 0);
+
+		public final int start;
+		public final int end;
+
+		public Span(final int index) {
+			this(index, index);
+		}
+
+		public Span(final int start, final int end) {
+			this.start = start;
+			this.end = end;
+		}
+
+		@Override
+		public int hashCode() {
+			final int prime = 31;
+			int result = 1;
+			result = prime * result + end;
+			result = prime * result + start;
+			return result;
+		}
+
+		@Override
+		public boolean equals(final Object obj) {
+			if (this == obj) {
+				return true;
+			}
+			if (obj == null) {
+				return false;
+			}
+			if (getClass() != obj.getClass()) {
+				return false;
+			}
+			final Span other = (Span) obj;
+			if (end != other.end) {
+				return false;
+			}
+			if (start != other.start) {
+				return false;
+			}
+			return true;
+		}
+	}
+}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnLayout.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnLayout.java
deleted file mode 100644
index 4eaa2af..0000000
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnLayout.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Florian Thienel and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * 		Florian Thienel - initial API and implementation
- *******************************************************************************/
-package org.eclipse.vex.core.internal.boxes;
-
-import java.util.HashMap;
-
-import org.eclipse.vex.core.internal.core.Graphics;
-
-/**
- * @author Florian Thienel
- */
-public class TableColumnLayout {
-
-	private final TableColumnLayout parentLayout;
-	private int width;
-
-	private int lastIndex;
-	private final HashMap<String, Span> indexByName = new HashMap<String, Span>();
-
-	public static void addColumnLayoutInformationForChildren(final Graphics graphics, final IStructuralBox parent, final TableColumnLayout parentColumnLayout) {
-		parent.accept(new DepthFirstBoxTraversal<Object>() {
-			@Override
-			public Object visit(final Table box) {
-				if (box == parent) {
-					traverseChildren(box);
-				} else {
-					box.setColumnLayout(new TableColumnLayout(parentColumnLayout));
-				}
-				return null;
-			}
-
-			@Override
-			public Object visit(final TableRowGroup box) {
-				if (box == parent) {
-					traverseChildren(box);
-				} else {
-					box.setColumnLayout(new TableColumnLayout(parentColumnLayout));
-				}
-				return null;
-			}
-
-			@Override
-			public Object visit(final TableColumnSpec box) {
-				if (box.getStartName() != null) {
-					box.setStartIndex(parentColumnLayout.getIndex(box.getStartName()));
-				}
-				if (box.getEndName() != null) {
-					box.setEndIndex(parentColumnLayout.getIndex(box.getEndName()));
-				}
-				if (box.getStartIndex() == box.getEndIndex()) {
-					parentColumnLayout.addColumn(box.getStartIndex(), box.getName(), box.getWidthExpression());
-				} else {
-					parentColumnLayout.addSpan(box.getStartIndex(), box.getEndIndex(), box.getName());
-				}
-				return null;
-			}
-
-			@Override
-			public Object visit(final TableRow box) {
-				if (box == parent) {
-					traverseChildren(box);
-				} else {
-					box.setColumnLayout(parentColumnLayout);
-				}
-				return null;
-			}
-
-			@Override
-			public Object visit(final TableCell box) {
-				if (box.getColumnName() != null) {
-					box.setStartColumnIndex(parentColumnLayout.getStartIndex(box.getColumnName()));
-					box.setEndColumnIndex(parentColumnLayout.getEndIndex(box.getColumnName()));
-				} else if (box.getStartColumnName() != null && box.getEndColumnName() != null) {
-					box.setStartColumnIndex(parentColumnLayout.getIndex(box.getStartColumnName()));
-					box.setEndColumnIndex(parentColumnLayout.getIndex(box.getEndColumnName()));
-				}
-				return null;
-			}
-		});
-	}
-
-	public TableColumnLayout() {
-		this(null);
-	}
-
-	public TableColumnLayout(final TableColumnLayout parentLayout) {
-		this.parentLayout = parentLayout;
-	}
-
-	public TableColumnLayout getParentLayout() {
-		return parentLayout;
-	}
-
-	public int addColumn(final int index, final String name, final String width) {
-		final int columnIndex;
-		if (index <= lastIndex) {
-			columnIndex = lastIndex += 1;
-		} else {
-			columnIndex = lastIndex = index;
-		}
-
-		if (name != null) {
-			indexByName.put(name, new Span(columnIndex));
-		}
-
-		return columnIndex;
-	}
-
-	public void addSpan(final int startIndex, final int endIndex, final String name) {
-		indexByName.put(name, new Span(startIndex, endIndex));
-	}
-
-	public int getWidth() {
-		return width;
-	}
-
-	public void setWidth(final int width) {
-		this.width = width;
-	}
-
-	public int getLastIndex() {
-		if (parentLayout != null) {
-			return Math.max(lastIndex, parentLayout.getLastIndex());
-		}
-		return lastIndex;
-	}
-
-	public int getIndex(final String name) {
-		return getStartIndex(name);
-	}
-
-	public int getStartIndex(final String name) {
-		return getSpan(name).start;
-	}
-
-	public int getEndIndex(final String name) {
-		return getSpan(name).end;
-	}
-
-	private Span getSpan(final String name) {
-		if (indexByName.containsKey(name)) {
-			return indexByName.get(name);
-		}
-		if (parentLayout != null) {
-			return parentLayout.getSpan(name);
-		}
-		return Span.NULL;
-	}
-
-	public int getWidth(final int startIndex, final int endIndex) {
-		return 0;
-	}
-
-	public int getWidth(final int index) {
-		return 0;
-	}
-
-	private static class Span {
-		public static final Span NULL = new Span(0, 0);
-
-		public final int start;
-		public final int end;
-
-		public Span(final int index) {
-			this(index, index);
-		}
-
-		public Span(final int start, final int end) {
-			this.start = start;
-			this.end = end;
-		}
-
-		@Override
-		public int hashCode() {
-			final int prime = 31;
-			int result = 1;
-			result = prime * result + end;
-			result = prime * result + start;
-			return result;
-		}
-
-		@Override
-		public boolean equals(final Object obj) {
-			if (this == obj) {
-				return true;
-			}
-			if (obj == null) {
-				return false;
-			}
-			if (getClass() != obj.getClass()) {
-				return false;
-			}
-			final Span other = (Span) obj;
-			if (end != other.end) {
-				return false;
-			}
-			if (start != other.start) {
-				return false;
-			}
-			return true;
-		}
-	}
-}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java
index 632da46..d55a863 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java
@@ -19,6 +19,9 @@
  */
 public class TableLayoutGrid {
 
+	private final TableLayoutGrid parentGrid;
+	private final TableColumnDefinitions columnDefinitions;
+
 	private final HashMap<GridPosition, TableCell> grid = new HashMap<GridPosition, TableCell>();
 	private int currentRow = 0;
 	private int nextColumn = 1;
@@ -32,7 +35,7 @@
 				if (box == parent) {
 					traverseChildren(box);
 				} else {
-					box.setLayoutGrid(layoutGrid);
+					box.setLayoutGrid(new TableLayoutGrid(layoutGrid));
 				}
 				return null;
 			}
@@ -42,15 +45,25 @@
 				if (box == parent) {
 					traverseChildren(box);
 				} else {
-					box.setLayoutGrid(layoutGrid);
+					box.setLayoutGrid(new TableLayoutGrid(layoutGrid));
 				}
 				return null;
 			}
 
 			@Override
 			public Object visit(final TableColumnSpec box) {
-				// TODO Auto-generated method stub
-				return super.visit(box);
+				if (box.getStartName() != null) {
+					box.setStartIndex(layoutGrid.getColumnIndex(box.getStartName()));
+				}
+				if (box.getEndName() != null) {
+					box.setEndIndex(layoutGrid.getColumnIndex(box.getEndName()));
+				}
+				if (box.getStartIndex() == box.getEndIndex()) {
+					layoutGrid.addColumnDefinition(box.getStartIndex(), box.getName(), box.getWidthExpression());
+				} else {
+					layoutGrid.addSpanDefinition(box.getStartIndex(), box.getEndIndex(), box.getName());
+				}
+				return null;
 			}
 
 			@Override
@@ -66,8 +79,21 @@
 
 			@Override
 			public Object visit(final TableCell box) {
-				if (box.getStartColumnIndex() > 0 && box.getEndColumnIndex() > 0) {
-					layoutGrid.addCellOnCurrentRow(box, box.getStartColumnIndex(), box.getEndColumnIndex());
+				int startIndex;
+				int endIndex;
+				if (box.getColumnName() != null) {
+					startIndex = layoutGrid.getColumnStartIndex(box.getColumnName());
+					endIndex = layoutGrid.getColumnEndIndex(box.getColumnName());
+				} else if (box.getStartColumnName() != null && box.getEndColumnName() != null) {
+					startIndex = layoutGrid.getColumnIndex(box.getStartColumnName());
+					endIndex = layoutGrid.getColumnIndex(box.getEndColumnName());
+				} else {
+					startIndex = 0;
+					endIndex = 0;
+				}
+
+				if (startIndex > 0 && endIndex > 0) {
+					layoutGrid.addCellOnCurrentRow(box, startIndex, endIndex);
 				} else {
 					layoutGrid.addNextCellOnCurrentRow(box);
 				}
@@ -76,6 +102,16 @@
 		});
 	}
 
+	public TableLayoutGrid() {
+		this(null);
+	}
+
+	public TableLayoutGrid(final TableLayoutGrid parentGrid) {
+		this.parentGrid = parentGrid;
+		final TableColumnDefinitions parentColumnDefinitions = parentGrid == null ? null : parentGrid.columnDefinitions;
+		columnDefinitions = new TableColumnDefinitions(parentColumnDefinitions);
+	}
+
 	public int getRows() {
 		return currentRow;
 	}
@@ -84,25 +120,14 @@
 		return maxColumn;
 	}
 
-	public int addNextRow(final TableRow row) {
+	private int addNextRow(final TableRow row) {
 		currentRow += 1;
 		row.setRowIndex(currentRow);
 		nextColumn = 1;
 		return currentRow;
 	}
 
-	public boolean addCellOnCurrentRow(final TableCell cell, final int column) {
-		final GridArea area = new GridArea(currentRow, column, currentRow + cell.getVerticalSpan() - 1, column);
-		if (isOccupied(area)) {
-			return false;
-		}
-		occupy(area, cell);
-		cell.setGridArea(area);
-		updateNextColumn();
-		return true;
-	}
-
-	public boolean addCellOnCurrentRow(final TableCell cell, final int startColumn, final int endColumn) {
+	private boolean addCellOnCurrentRow(final TableCell cell, final int startColumn, final int endColumn) {
 		final GridArea area = new GridArea(currentRow, startColumn, currentRow + cell.getVerticalSpan() - 1, endColumn);
 		if (isOccupied(area)) {
 			return false;
@@ -113,7 +138,7 @@
 		return true;
 	}
 
-	public void addNextCellOnCurrentRow(final TableCell cell) {
+	private void addNextCellOnCurrentRow(final TableCell cell) {
 		final GridArea area = new GridArea(currentRow, nextColumn, currentRow + cell.getVerticalSpan() - 1, nextColumn);
 		occupy(area, cell);
 		cell.setGridArea(area);
@@ -226,6 +251,34 @@
 		});
 	}
 
+	private void addColumnDefinition(final int index, final String name, final String width) {
+		columnDefinitions.addColumn(index, name, width);
+	}
+
+	private void addSpanDefinition(final int startIndex, final int endIndex, final String name) {
+		columnDefinitions.addSpan(startIndex, endIndex, name);
+	}
+
+	private int getColumnStartIndex(final String name) {
+		return columnDefinitions.getStartIndex(name);
+	}
+
+	private int getColumnEndIndex(final String name) {
+		return columnDefinitions.getEndIndex(name);
+	}
+
+	private int getColumnIndex(final String name) {
+		return columnDefinitions.getIndex(name);
+	}
+
+	public int getColumnWidth(final int startIndex, final int endIndex) {
+		return columnDefinitions.getWidth(startIndex, endIndex);
+	}
+
+	public int getColumnWidth(final int index) {
+		return columnDefinitions.getWidth(index);
+	}
+
 	@Override
 	public String toString() {
 		final StringBuilder builder = new StringBuilder();
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java
index 2fc3678..1bf81af 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java
@@ -31,7 +31,6 @@
 
 	private int rowIndex;
 
-	private TableColumnLayout columnLayout = new TableColumnLayout();
 	private TableLayoutGrid layoutGrid = new TableLayoutGrid();
 
 	@Override
@@ -151,18 +150,6 @@
 		this.rowIndex = rowIndex;
 	}
 
-	public TableColumnLayout getColumnLayout() {
-		return columnLayout;
-	}
-
-	public void setColumnLayout(final TableColumnLayout columnLayout) {
-		if (columnLayout == null) {
-			this.columnLayout = new TableColumnLayout();
-		} else {
-			this.columnLayout = columnLayout;
-		}
-	}
-
 	public TableLayoutGrid getLayoutGrid() {
 		return layoutGrid;
 	}
@@ -176,7 +163,6 @@
 	}
 
 	public void layout(final Graphics graphics) {
-		TableColumnLayout.addColumnLayoutInformationForChildren(graphics, this, columnLayout);
 		TableLayoutGrid.setupLayoutGrid(graphics, this, layoutGrid);
 		int cellHeight = 0;
 
@@ -236,10 +222,10 @@
 	}
 
 	private int getColumnWidth(final int index) {
-		if (index < 1 || index > columnLayout.getLastIndex()) {
+		if (index < 1 || index > layoutGrid.getColumns()) {
 			return 0;
 		}
-		return Math.round(width / columnLayout.getLastIndex());
+		return Math.round(width / layoutGrid.getColumns());
 	}
 
 	@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java
index 59cdf10..a562ab8 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java
@@ -29,7 +29,6 @@
 	private int height;
 	private final ArrayList<IStructuralBox> children = new ArrayList<IStructuralBox>();
 
-	private TableColumnLayout columnLayout = new TableColumnLayout();
 	private TableLayoutGrid layoutGrid = new TableLayoutGrid();
 
 	@Override
@@ -141,14 +140,6 @@
 		return children;
 	}
 
-	public TableColumnLayout getColumnLayout() {
-		return columnLayout;
-	}
-
-	public void setColumnLayout(final TableColumnLayout columnLayout) {
-		this.columnLayout = columnLayout;
-	}
-
 	public TableLayoutGrid getLayoutGrid() {
 		return layoutGrid;
 	}
@@ -167,10 +158,6 @@
 	}
 
 	private void layoutColumns(final Graphics graphics) {
-		if (columnLayout.getLastIndex() > 0) {
-			columnLayout = new TableColumnLayout(columnLayout.getParentLayout());
-		}
-		TableColumnLayout.addColumnLayoutInformationForChildren(graphics, this, columnLayout);
 		TableLayoutGrid.setupLayoutGrid(graphics, this, layoutGrid);
 	}
 
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableBox.java
index 65e94bc..26d4250 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableBox.java
@@ -243,7 +243,6 @@
 		int totalColumnWidth = horizonalSpacing;
 		final int columnWidth = (availableWidth - horizonalSpacing * (columnCount + 1)) / columnCount;
 		for (int i = 0; i < columnWidths.length - 1; i++) {
-			System.err.print(" " + columnWidth);
 			columnWidths[i] = columnWidth;
 			totalColumnWidth += columnWidth + horizonalSpacing;
 		}