Update pixel positions for the annotated point, the text, and the arrow.
(self, renderer)
| 1479 | for child in self.get_children()]) |
| 1480 | |
| 1481 | def update_positions(self, renderer): |
| 1482 | """Update pixel positions for the annotated point, the text, and the arrow.""" |
| 1483 | |
| 1484 | ox0, oy0 = self._get_xy(renderer, self.xybox, self.boxcoords) |
| 1485 | bbox = self.offsetbox.get_bbox(renderer) |
| 1486 | fw, fh = self._box_alignment |
| 1487 | self.offsetbox.set_offset( |
| 1488 | (ox0 - fw*bbox.width - bbox.x0, oy0 - fh*bbox.height - bbox.y0)) |
| 1489 | |
| 1490 | bbox = self.offsetbox.get_window_extent(renderer) |
| 1491 | self.patch.set_bounds(bbox.bounds) |
| 1492 | |
| 1493 | mutation_scale = renderer.points_to_pixels(self.get_fontsize()) |
| 1494 | self.patch.set_mutation_scale(mutation_scale) |
| 1495 | |
| 1496 | if self.arrowprops: |
| 1497 | # Use FancyArrowPatch if self.arrowprops has "arrowstyle" key. |
| 1498 | |
| 1499 | # Adjust the starting point of the arrow relative to the textbox. |
| 1500 | # TODO: Rotation needs to be accounted. |
| 1501 | arrow_begin = bbox.p0 + bbox.size * self._arrow_relpos |
| 1502 | arrow_end = self._get_position_xy(renderer) |
| 1503 | # The arrow (from arrow_begin to arrow_end) will be first clipped |
| 1504 | # by patchA and patchB, then shrunk by shrinkA and shrinkB (in |
| 1505 | # points). If patch A is not set, self.bbox_patch is used. |
| 1506 | self.arrow_patch.set_positions(arrow_begin, arrow_end) |
| 1507 | |
| 1508 | if "mutation_scale" in self.arrowprops: |
| 1509 | mutation_scale = renderer.points_to_pixels( |
| 1510 | self.arrowprops["mutation_scale"]) |
| 1511 | # Else, use fontsize-based mutation_scale defined above. |
| 1512 | self.arrow_patch.set_mutation_scale(mutation_scale) |
| 1513 | |
| 1514 | patchA = self.arrowprops.get("patchA", self.patch) |
| 1515 | self.arrow_patch.set_patchA(patchA) |
| 1516 | |
| 1517 | def draw(self, renderer): |
| 1518 | # docstring inherited |
no test coverage detected