Return the maximum line width for wrapping text based on the current orientation.
(self)
| 598 | self._wrap = wrap |
| 599 | |
| 600 | def _get_wrap_line_width(self): |
| 601 | """ |
| 602 | Return the maximum line width for wrapping text based on the current |
| 603 | orientation. |
| 604 | """ |
| 605 | x0, y0 = self.get_transform().transform(self.get_position()) |
| 606 | figure_box = self.get_figure().get_window_extent() |
| 607 | |
| 608 | # Calculate available width based on text alignment |
| 609 | alignment = self.get_horizontalalignment() |
| 610 | self.set_rotation_mode('anchor') |
| 611 | rotation = self.get_rotation() |
| 612 | |
| 613 | left = self._get_dist_to_box(rotation, x0, y0, figure_box) |
| 614 | right = self._get_dist_to_box( |
| 615 | (180 + rotation) % 360, x0, y0, figure_box) |
| 616 | |
| 617 | if alignment == 'left': |
| 618 | line_width = left |
| 619 | elif alignment == 'right': |
| 620 | line_width = right |
| 621 | else: |
| 622 | line_width = 2 * min(left, right) |
| 623 | |
| 624 | return line_width |
| 625 | |
| 626 | def _get_dist_to_box(self, rotation, x0, y0, figure_box): |
| 627 | """ |
no test coverage detected