offsetbox.pyi 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. import matplotlib.artist as martist
  2. from matplotlib.backend_bases import RendererBase, Event, FigureCanvasBase
  3. from matplotlib.colors import Colormap, Normalize
  4. import matplotlib.text as mtext
  5. from matplotlib.figure import Figure
  6. from matplotlib.font_manager import FontProperties
  7. from matplotlib.image import BboxImage
  8. from matplotlib.patches import FancyArrowPatch, FancyBboxPatch
  9. from matplotlib.transforms import Bbox, BboxBase, Transform
  10. import numpy as np
  11. from numpy.typing import ArrayLike
  12. from collections.abc import Callable, Sequence
  13. from typing import Any, Literal, overload
  14. DEBUG: bool
  15. def bbox_artist(*args, **kwargs) -> None: ...
  16. def _get_packed_offsets(
  17. widths: Sequence[float],
  18. total: float | None,
  19. sep: float | None,
  20. mode: Literal["fixed", "expand", "equal"] = ...,
  21. ) -> tuple[float, np.ndarray]: ...
  22. class OffsetBox(martist.Artist):
  23. width: float | None
  24. height: float | None
  25. def __init__(self, *args, **kwargs) -> None: ...
  26. def set_figure(self, fig: Figure) -> None: ...
  27. def set_offset(
  28. self,
  29. xy: tuple[float, float]
  30. | Callable[[float, float, float, float, RendererBase], tuple[float, float]],
  31. ) -> None: ...
  32. @overload
  33. def get_offset(self, bbox: Bbox, renderer: RendererBase) -> tuple[float, float]: ...
  34. @overload
  35. def get_offset(
  36. self,
  37. width: float,
  38. height: float,
  39. xdescent: float,
  40. ydescent: float,
  41. renderer: RendererBase
  42. ) -> tuple[float, float]: ...
  43. def set_width(self, width: float) -> None: ...
  44. def set_height(self, height: float) -> None: ...
  45. def get_visible_children(self) -> list[martist.Artist]: ...
  46. def get_children(self) -> list[martist.Artist]: ...
  47. def get_bbox(self, renderer: RendererBase) -> Bbox: ...
  48. def get_extent_offsets(
  49. self, renderer: RendererBase
  50. ) -> tuple[float, float, float, float, list[tuple[float, float]]]: ...
  51. def get_extent(
  52. self, renderer: RendererBase
  53. ) -> tuple[float, float, float, float]: ...
  54. def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ...
  55. class PackerBase(OffsetBox):
  56. height: float | None
  57. width: float | None
  58. sep: float | None
  59. pad: float | None
  60. mode: Literal["fixed", "expand", "equal"]
  61. align: Literal["top", "bottom", "left", "right", "center", "baseline"]
  62. def __init__(
  63. self,
  64. pad: float | None = ...,
  65. sep: float | None = ...,
  66. width: float | None = ...,
  67. height: float | None = ...,
  68. align: Literal["top", "bottom", "left", "right", "center", "baseline"] = ...,
  69. mode: Literal["fixed", "expand", "equal"] = ...,
  70. children: list[martist.Artist] | None = ...,
  71. ) -> None: ...
  72. class VPacker(PackerBase): ...
  73. class HPacker(PackerBase): ...
  74. class PaddedBox(OffsetBox):
  75. pad: float | None
  76. patch: FancyBboxPatch
  77. def __init__(
  78. self,
  79. child: martist.Artist,
  80. pad: float | None = ...,
  81. *,
  82. draw_frame: bool = ...,
  83. patch_attrs: dict[str, Any] | None = ...,
  84. ) -> None: ...
  85. def update_frame(self, bbox: Bbox, fontsize: float | None = ...) -> None: ...
  86. def draw_frame(self, renderer: RendererBase) -> None: ...
  87. class DrawingArea(OffsetBox):
  88. width: float
  89. height: float
  90. xdescent: float
  91. ydescent: float
  92. offset_transform: Transform
  93. dpi_transform: Transform
  94. def __init__(
  95. self,
  96. width: float,
  97. height: float,
  98. xdescent: float = ...,
  99. ydescent: float = ...,
  100. clip: bool = ...,
  101. ) -> None: ...
  102. @property
  103. def clip_children(self) -> bool: ...
  104. @clip_children.setter
  105. def clip_children(self, val: bool) -> None: ...
  106. def get_transform(self) -> Transform: ...
  107. # does not accept all options of superclass
  108. def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override]
  109. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  110. def add_artist(self, a: martist.Artist) -> None: ...
  111. class TextArea(OffsetBox):
  112. offset_transform: Transform
  113. def __init__(
  114. self,
  115. s: str,
  116. *,
  117. textprops: dict[str, Any] | None = ...,
  118. multilinebaseline: bool = ...,
  119. ) -> None: ...
  120. def set_text(self, s: str) -> None: ...
  121. def get_text(self) -> str: ...
  122. def set_multilinebaseline(self, t: bool) -> None: ...
  123. def get_multilinebaseline(self) -> bool: ...
  124. # does not accept all options of superclass
  125. def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override]
  126. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  127. class AuxTransformBox(OffsetBox):
  128. aux_transform: Transform
  129. offset_transform: Transform
  130. ref_offset_transform: Transform
  131. def __init__(self, aux_transform: Transform) -> None: ...
  132. def add_artist(self, a: martist.Artist) -> None: ...
  133. def get_transform(self) -> Transform: ...
  134. # does not accept all options of superclass
  135. def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override]
  136. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  137. class AnchoredOffsetbox(OffsetBox):
  138. zorder: float
  139. codes: dict[str, int]
  140. loc: int
  141. borderpad: float
  142. pad: float
  143. prop: FontProperties
  144. patch: FancyBboxPatch
  145. def __init__(
  146. self,
  147. loc: str,
  148. *,
  149. pad: float = ...,
  150. borderpad: float = ...,
  151. child: OffsetBox | None = ...,
  152. prop: FontProperties | None = ...,
  153. frameon: bool = ...,
  154. bbox_to_anchor: BboxBase
  155. | tuple[float, float]
  156. | tuple[float, float, float, float]
  157. | None = ...,
  158. bbox_transform: Transform | None = ...,
  159. **kwargs
  160. ) -> None: ...
  161. def set_child(self, child: OffsetBox | None) -> None: ...
  162. def get_child(self) -> OffsetBox | None: ...
  163. def get_children(self) -> list[martist.Artist]: ...
  164. def get_bbox_to_anchor(self) -> Bbox: ...
  165. def set_bbox_to_anchor(
  166. self, bbox: BboxBase, transform: Transform | None = ...
  167. ) -> None: ...
  168. def update_frame(self, bbox: Bbox, fontsize: float | None = ...) -> None: ...
  169. class AnchoredText(AnchoredOffsetbox):
  170. txt: TextArea
  171. def __init__(
  172. self,
  173. s: str,
  174. loc: str,
  175. *,
  176. pad: float = ...,
  177. borderpad: float = ...,
  178. prop: dict[str, Any] | None = ...,
  179. **kwargs
  180. ) -> None: ...
  181. class OffsetImage(OffsetBox):
  182. image: BboxImage
  183. def __init__(
  184. self,
  185. arr: ArrayLike,
  186. *,
  187. zoom: float = ...,
  188. cmap: Colormap | str | None = ...,
  189. norm: Normalize | str | None = ...,
  190. interpolation: str | None = ...,
  191. origin: Literal["upper", "lower"] | None = ...,
  192. filternorm: bool = ...,
  193. filterrad: float = ...,
  194. resample: bool = ...,
  195. dpi_cor: bool = ...,
  196. **kwargs
  197. ) -> None: ...
  198. stale: bool
  199. def set_data(self, arr: ArrayLike | None) -> None: ...
  200. def get_data(self) -> ArrayLike | None: ...
  201. def set_zoom(self, zoom: float) -> None: ...
  202. def get_zoom(self) -> float: ...
  203. def get_children(self) -> list[martist.Artist]: ...
  204. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  205. class AnnotationBbox(martist.Artist, mtext._AnnotationBase):
  206. zorder: float
  207. offsetbox: OffsetBox
  208. arrowprops: dict[str, Any] | None
  209. xybox: tuple[float, float]
  210. boxcoords: str | tuple[str, str] | martist.Artist | Transform | Callable[
  211. [RendererBase], Bbox | Transform
  212. ]
  213. arrow_patch: FancyArrowPatch | None
  214. patch: FancyBboxPatch
  215. prop: FontProperties
  216. def __init__(
  217. self,
  218. offsetbox: OffsetBox,
  219. xy: tuple[float, float],
  220. xybox: tuple[float, float] | None = ...,
  221. xycoords: str
  222. | tuple[str, str]
  223. | martist.Artist
  224. | Transform
  225. | Callable[[RendererBase], Bbox | Transform] = ...,
  226. boxcoords: str
  227. | tuple[str, str]
  228. | martist.Artist
  229. | Transform
  230. | Callable[[RendererBase], Bbox | Transform]
  231. | None = ...,
  232. *,
  233. frameon: bool = ...,
  234. pad: float = ...,
  235. annotation_clip: bool | None = ...,
  236. box_alignment: tuple[float, float] = ...,
  237. bboxprops: dict[str, Any] | None = ...,
  238. arrowprops: dict[str, Any] | None = ...,
  239. fontsize: float | str | None = ...,
  240. **kwargs
  241. ) -> None: ...
  242. @property
  243. def xyann(self) -> tuple[float, float]: ...
  244. @xyann.setter
  245. def xyann(self, xyann: tuple[float, float]) -> None: ...
  246. @property
  247. def anncoords(
  248. self,
  249. ) -> str | tuple[str, str] | martist.Artist | Transform | Callable[
  250. [RendererBase], Bbox | Transform
  251. ]: ...
  252. @anncoords.setter
  253. def anncoords(
  254. self,
  255. coords: str
  256. | tuple[str, str]
  257. | martist.Artist
  258. | Transform
  259. | Callable[[RendererBase], Bbox | Transform],
  260. ) -> None: ...
  261. def get_children(self) -> list[martist.Artist]: ...
  262. def set_figure(self, fig: Figure) -> None: ...
  263. def set_fontsize(self, s: str | float | None = ...) -> None: ...
  264. def get_fontsize(self) -> float: ...
  265. def get_tightbbox(self, renderer: RendererBase | None = ...) -> Bbox: ...
  266. def update_positions(self, renderer: RendererBase) -> None: ...
  267. class DraggableBase:
  268. ref_artist: martist.Artist
  269. got_artist: bool
  270. mouse_x: int
  271. mouse_y: int
  272. background: Any
  273. @property
  274. def canvas(self) -> FigureCanvasBase: ...
  275. @property
  276. def cids(self) -> list[int]: ...
  277. def __init__(self, ref_artist: martist.Artist, use_blit: bool = ...) -> None: ...
  278. def on_motion(self, evt: Event) -> None: ...
  279. def on_pick(self, evt: Event) -> None: ...
  280. def on_release(self, event: Event) -> None: ...
  281. def disconnect(self) -> None: ...
  282. def save_offset(self) -> None: ...
  283. def update_offset(self, dx: float, dy: float) -> None: ...
  284. def finalize_offset(self) -> None: ...
  285. class DraggableOffsetBox(DraggableBase):
  286. offsetbox: OffsetBox
  287. def __init__(
  288. self, ref_artist: martist.Artist, offsetbox: OffsetBox, use_blit: bool = ...
  289. ) -> None: ...
  290. def save_offset(self) -> None: ...
  291. def update_offset(self, dx: float, dy: float) -> None: ...
  292. def get_loc_in_canvas(self) -> tuple[float, float]: ...
  293. class DraggableAnnotation(DraggableBase):
  294. annotation: mtext.Annotation
  295. def __init__(self, annotation: mtext.Annotation, use_blit: bool = ...) -> None: ...
  296. def save_offset(self) -> None: ...
  297. def update_offset(self, dx: float, dy: float) -> None: ...