MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / _get_wrap_line_width

Method _get_wrap_line_width

site-packages/matplotlib/text.py:600–624  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

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 """

Callers 1

_get_wrapped_textMethod · 0.95

Calls 10

get_positionMethod · 0.95
set_rotation_modeMethod · 0.95
get_rotationMethod · 0.95
_get_dist_to_boxMethod · 0.95
minFunction · 0.85
transformMethod · 0.45
get_transformMethod · 0.45
get_window_extentMethod · 0.45
get_figureMethod · 0.45

Tested by

no test coverage detected