@@ -240,7 +240,8 @@ def update(self, kwargs):
240
240
"""
241
241
bbox = kwargs .pop ('bbox' , None )
242
242
super (Text , self ).update (kwargs )
243
- self .set_bbox (bbox ) # depends on font properties
243
+ if bbox :
244
+ self .set_bbox (bbox ) # depends on font properties
244
245
245
246
def __getstate__ (self ):
246
247
d = super (Text , self ).__getstate__ ()
@@ -280,7 +281,7 @@ def contains(self, mouseevent):
280
281
281
282
def _get_xy_display (self ):
282
283
'get the (possibly unit converted) transformed x, y in display coords'
283
- x , y = self .get_position ()
284
+ x , y = self .get_unitless_position ()
284
285
return self .get_transform ().transform_point ((x , y ))
285
286
286
287
def _get_multialignment (self ):
@@ -536,8 +537,8 @@ def update_bbox_position_size(self, renderer):
536
537
537
538
trans = self .get_transform ()
538
539
539
- # don't use self.get_position here, which refers to text position
540
- # in Text, and dash position in TextWithDash:
540
+ # don't use self.get_unitless_position here, which refers to text
541
+ # position in Text, and dash position in TextWithDash:
541
542
posx = float (self .convert_xunits (self ._x ))
542
543
posy = float (self .convert_yunits (self ._y ))
543
544
@@ -877,12 +878,20 @@ def get_horizontalalignment(self):
877
878
"""
878
879
return self ._horizontalalignment
879
880
880
- def get_position (self ):
881
- "Return the position of the text as a tuple (*x*, *y*)"
881
+ def get_unitless_position (self ):
882
+ "Return the unitless position of the text as a tuple (*x*, *y*)"
883
+ # This will get the position with all unit information stripped away.
884
+ # This is here for convienience since it is done in several locations.
882
885
x = float (self .convert_xunits (self ._x ))
883
886
y = float (self .convert_yunits (self ._y ))
884
887
return x , y
885
888
889
+ def get_position (self ):
890
+ "Return the position of the text as a tuple (*x*, *y*)"
891
+ # This should return the same data (possible unitized) as was
892
+ # specified with 'set_x' and 'set_y'.
893
+ return self ._x , self ._y
894
+
886
895
def get_prop_tup (self ):
887
896
"""
888
897
Return a hashable tuple of properties.
@@ -891,7 +900,7 @@ def get_prop_tup(self):
891
900
want to cache derived information about text (e.g., layouts) and
892
901
need to know if the text has changed.
893
902
"""
894
- x , y = self .get_position ()
903
+ x , y = self .get_unitless_position ()
895
904
return (x , y , self .get_text (), self ._color ,
896
905
self ._verticalalignment , self ._horizontalalignment ,
897
906
hash (self ._fontproperties ),
@@ -950,7 +959,7 @@ def get_window_extent(self, renderer=None, dpi=None):
950
959
raise RuntimeError ('Cannot get window extent w/o renderer' )
951
960
952
961
bbox , info , descent = self ._get_layout (self ._renderer )
953
- x , y = self .get_position ()
962
+ x , y = self .get_unitless_position ()
954
963
x , y = self .get_transform ().transform_point ((x , y ))
955
964
bbox = bbox .translated (x , y )
956
965
if dpi is not None :
@@ -1365,12 +1374,20 @@ def __init__(self,
1365
1374
1366
1375
#self.set_bbox(dict(pad=0))
1367
1376
1368
- def get_position (self ):
1369
- "Return the position of the text as a tuple (*x*, *y*)"
1377
+ def get_unitless_position (self ):
1378
+ "Return the unitless position of the text as a tuple (*x*, *y*)"
1379
+ # This will get the position with all unit information stripped away.
1380
+ # This is here for convienience since it is done in several locations.
1370
1381
x = float (self .convert_xunits (self ._dashx ))
1371
1382
y = float (self .convert_yunits (self ._dashy ))
1372
1383
return x , y
1373
1384
1385
+ def get_position (self ):
1386
+ "Return the position of the text as a tuple (*x*, *y*)"
1387
+ # This should return the same data (possibly unitized) as was
1388
+ # specified with set_x and set_y
1389
+ return self ._dashx , self ._dashy
1390
+
1374
1391
def get_prop_tup (self ):
1375
1392
"""
1376
1393
Return a hashable tuple of properties.
@@ -1402,7 +1419,7 @@ def update_coords(self, renderer):
1402
1419
with respect to the actual canvas's coordinates we need to map
1403
1420
back and forth.
1404
1421
"""
1405
- dashx , dashy = self .get_position ()
1422
+ dashx , dashy = self .get_unitless_position ()
1406
1423
dashlength = self .get_dashlength ()
1407
1424
# Shortcircuit this process if we don't have a dash
1408
1425
if dashlength == 0.0 :
0 commit comments