'Returns the maximum line width for wrapping text based on the
current orientation.'

def _get_wrap_line_width(self):

    (x0, y0) = self.get_transform().transform(self.get_position())
    figure_box = self.get_figure().get_window_extent()
    alignment = self.get_horizontalalignment()
    self.set_rotation_mode(u'anchor')
    rotation = self.get_rotation()
    left = self._get_dist_to_box(rotation, x0, y0, figure_box)
    right = self._get_dist_to_box(((180 + rotation) % 360), x0, y0, figure_box)
    if (alignment == u'left'):
        line_width = left
    elif (alignment == u'right'):
        line_width = right
    else:
        line_width = (2 * min(left, right))
    return line_width
