(self, renderer)
| 839 | |
| 840 | @artist.allow_rasterization |
| 841 | def draw(self, renderer): |
| 842 | # docstring inherited |
| 843 | |
| 844 | if renderer is not None: |
| 845 | self._renderer = renderer |
| 846 | if not self.get_visible(): |
| 847 | return |
| 848 | if self.get_text() == '': |
| 849 | return |
| 850 | |
| 851 | renderer.open_group('text', self.get_gid()) |
| 852 | |
| 853 | bbox, info, _ = self._get_layout(renderer) |
| 854 | trans = self.get_transform() |
| 855 | |
| 856 | # don't use self.get_position here, which refers to text |
| 857 | # position in Text: |
| 858 | x, y = self._x, self._y |
| 859 | if np.ma.is_masked(x): |
| 860 | x = np.nan |
| 861 | if np.ma.is_masked(y): |
| 862 | y = np.nan |
| 863 | posx = float(self.convert_xunits(x)) |
| 864 | posy = float(self.convert_yunits(y)) |
| 865 | posx, posy = trans.transform((posx, posy)) |
| 866 | if np.isnan(posx) or np.isnan(posy): |
| 867 | return # don't throw a warning here |
| 868 | if not np.isfinite(posx) or not np.isfinite(posy): |
| 869 | _log.warning("posx and posy should be finite values") |
| 870 | return |
| 871 | canvasw, canvash = renderer.get_canvas_width_height() |
| 872 | |
| 873 | # Update the location and size of the bbox |
| 874 | # (`.patches.FancyBboxPatch`), and draw it. |
| 875 | if self._bbox_patch: |
| 876 | self.update_bbox_position_size(renderer) |
| 877 | self._bbox_patch.draw(renderer) |
| 878 | |
| 879 | gc = renderer.new_gc() |
| 880 | gc.set_foreground(mcolors.to_rgba(self.get_color()), isRGBA=True) |
| 881 | gc.set_alpha(self.get_alpha()) |
| 882 | gc.set_url(self._url) |
| 883 | gc.set_antialiased(self._antialiased) |
| 884 | gc.set_snap(self.get_snap()) |
| 885 | self._set_gc_clip(gc) |
| 886 | |
| 887 | angle = self.get_rotation() |
| 888 | |
| 889 | for line, wad, (x, y) in info: |
| 890 | |
| 891 | mtext = self if len(info) == 1 else None |
| 892 | x = x + posx |
| 893 | y = y + posy |
| 894 | if renderer.flipy(): |
| 895 | y = canvash - y |
| 896 | clean_line, ismath = self._preprocess_math(line) |
| 897 | |
| 898 | if self.get_path_effects(): |
no test coverage detected