'Calculate row heights and column widths.
Position cells accordingly.'

def _do_cell_alignment(self):

    widths = {}
    heights = {}
    for ((row, col), cell) in six.iteritems(self._cells):
        height = heights.setdefault(row, 0.0)
        heights[row] = max(height, cell.get_height())
        width = widths.setdefault(col, 0.0)
        widths[col] = max(width, cell.get_width())
    xpos = 0
    lefts = {}
    for col in sorted(widths):
        lefts[col] = xpos
        xpos += widths[col]
    ypos = 0
    bottoms = {}
    for row in sorted(heights, reverse=True):
        bottoms[row] = ypos
        ypos += heights[row]
    for ((row, col), cell) in six.iteritems(self._cells):
        cell.set_x(lefts[col])
        cell.set_y(bottoms[row])
