@@ -1596,35 +1596,35 @@ def draw(self, renderer):
1596
1596
1597
1597
class DraggableBase (object ):
1598
1598
"""
1599
- helper code for a draggable artist (legend, offsetbox)
1600
- The derived class must override following two method.
1599
+ Helper base class for a draggable artist (legend, offsetbox).
1601
1600
1602
- def save_offset(self):
1603
- pass
1601
+ Derived classes must override the following methods::
1604
1602
1605
- def update_offset(self, dx, dy):
1606
- pass
1603
+ def save_offset(self):
1604
+ '''
1605
+ Called when the object is picked for dragging; should save the
1606
+ reference position of the artist.
1607
+ '''
1607
1608
1608
- *save_offset* is called when the object is picked for dragging and it
1609
- is meant to save reference position of the artist.
1609
+ def update_offset(self, dx, dy):
1610
+ '''
1611
+ Called during the dragging; (*dx*, *dy*) is the pixel offset from
1612
+ the point where the mouse drag started.
1613
+ '''
1610
1614
1611
- *update_offset* is called during the dragging. dx and dy is the pixel
1612
- offset from the point where the mouse drag started.
1615
+ Optionally, you may override the following methods::
1613
1616
1614
- Optionally you may override following two methods.
1617
+ def artist_picker(self, artist, evt):
1618
+ '''The picker method that will be used.'''
1619
+ return self.ref_artist.contains(evt)
1615
1620
1616
- def artist_picker (self, artist, evt ):
1617
- return self.ref_artist.contains(evt)
1621
+ def finalize_offset (self):
1622
+ '''Called when the mouse is released.'''
1618
1623
1619
- def finalize_offset(self):
1620
- pass
1621
-
1622
- *artist_picker* is a picker method that will be
1623
- used. *finalize_offset* is called when the mouse is released. In
1624
- current implementation of DraggableLegend and DraggableAnnotation,
1625
- *update_offset* places the artists simply in display
1626
- coordinates. And *finalize_offset* recalculate their position in
1627
- the normalized axes coordinate and set a relevant attribute.
1624
+ In the current implementation of `DraggableLegend` and
1625
+ `DraggableAnnotation`, `update_offset` places the artists in display
1626
+ coordinates, and `finalize_offset` recalculates their position in axes
1627
+ coordinate and set a relevant attribute.
1628
1628
"""
1629
1629
1630
1630
def __init__ (self , ref_artist , use_blit = False ):
@@ -1694,7 +1694,7 @@ def _check_still_parented(self):
1694
1694
return True
1695
1695
1696
1696
def disconnect (self ):
1697
- """disconnect the callbacks"""
1697
+ """Disconnect the callbacks. """
1698
1698
for cid in self .cids :
1699
1699
self .canvas .mpl_disconnect (cid )
1700
1700
try :
@@ -1735,13 +1735,11 @@ def update_offset(self, dx, dy):
1735
1735
self .offsetbox .set_offset (loc_in_canvas )
1736
1736
1737
1737
def get_loc_in_canvas (self ):
1738
-
1739
1738
offsetbox = self .offsetbox
1740
1739
renderer = offsetbox .figure ._cachedRenderer
1741
1740
w , h , xd , yd = offsetbox .get_extent (renderer )
1742
1741
ox , oy = offsetbox ._offset
1743
1742
loc_in_canvas = (ox - xd , oy - yd )
1744
-
1745
1743
return loc_in_canvas
1746
1744
1747
1745
0 commit comments