Displays the elements according to the align properties.

def render(self, rect, data):
        """
        Displays the elements according to the align properties.
        """
        # Make sure we're aligned correctly
        if self.horizontal_align not in VerticalLM._VALID_ALIGN_HORIZONTAL:
            raise ValueError('Horizontal align is not valid.')
        if self.vertical_align not in VerticalLM._VALID_ALIGN_VERTICAL:
            raise ValueError('Vertical align is not valid.')

        # Work out the extra height we have to distribute
        extra_height = rect.h - self.get_minimum_size(data).y
        num_elements = len(self.elements)
        if num_elements == 0:
            return
        elif num_elements > 1:
            per_margin = 1.0 / float(num_elements-1)
        else:
            per_margin = 0.0
        per_element = 1.0 / float(num_elements)

        # Work out the starting y coordinate
        y = rect.y
        if self.vertical_align == VerticalLM.ALIGN_MIDDLE:
            y = rect.y + extra_height*0.5
        elif self.vertical_align == VerticalLM.ALIGN_TOP:
            y = rect.y + extra_height

        # Render each child element
        for element in reversed(self.elements):
            size = element.get_minimum_size(data)

            # Work out the x-coordinates
            if self.horizontal_align == VerticalLM.ALIGN_LEFT:
                x = rect.x
                w = size.x
            elif self.horizontal_align == VerticalLM.ALIGN_CENTER:
                x = rect.center - size.x*0.5
                w = size.x
            elif self.horizontal_align == VerticalLM.ALIGN_RIGHT:
                x = rect.right - size.x
                w = size.x
            else:
                assert self.horizontal_align == VerticalLM.ALIGN_GROW
                x = rect.x
                w = rect.w

            # Work out the y-coordinates
            if self.vertical_align in VerticalLM._ALIGN_SIMPLE_SET:
                h = size.y
                next_y = y + size.y + self.margin
            elif self.vertical_align == VerticalLM.ALIGN_EQUAL_SPACING:
                h = size.y
                next_y = y + size.y + self.margin + extra_height*per_margin
            else:
                assert self.vertical_align == VerticalLM.ALIGN_EQUAL_GROWTH
                h = size.y + extra_height*per_element
                next_y = y + h + self.margin

            # Render and move on.
            element.render(datatypes.Rectangle(x, y, w, h), data)
            y = next_y