Return the maximum line width for wrapping text based on the current orientation.
(self)
| 727 | self._wrap = wrap |
| 728 | |
| 729 | def _get_wrap_line_width(self): |
| 730 | """ |
| 731 | Return the maximum line width for wrapping text based on the current |
| 732 | orientation. |
| 733 | """ |
| 734 | x0, y0 = self.get_transform().transform(self.get_position()) |
| 735 | figure_box = self.get_figure().get_window_extent() |
| 736 | |
| 737 | # Calculate available width based on text alignment |
| 738 | alignment = self.get_horizontalalignment() |
| 739 | self.set_rotation_mode('anchor') |
| 740 | angle = self.get_rotation() |
| 741 | |
| 742 | left = self._get_dist_to_box(angle, x0, y0, figure_box) |
| 743 | right = self._get_dist_to_box( |
| 744 | (180 + angle) % 360, x0, y0, figure_box) |
| 745 | |
| 746 | if alignment == 'left': |
| 747 | line_width = left |
| 748 | elif alignment == 'right': |
| 749 | line_width = right |
| 750 | else: |
| 751 | line_width = 2 * min(left, right) |
| 752 | |
| 753 | return line_width |
| 754 | |
| 755 | def _get_dist_to_box(self, rotation, x0, y0, figure_box): |
| 756 | """ |
no test coverage detected