I'm using RaphaelGWT to draw shapes with the underlying RaphaelJS library. Both projects are wonderful. However I was stuck for awhile on the issue of Text objects in Raphael being displayed as centered by default.
I've tried to create one Text object and let it be centered by default, then measure its width in order to adjust the position for a 2nd text object and then remove the first. But I can't get the width of the original Text object.
FYI, in RaphaelGWT, the Shape objects used extend Widget. So I've tried getAbsoluteLeft()
, getElement().getAbsoluteRight()
, getOffsetWidth()
, getElement().getClientWidth()
. getAbsoluteLeft() is the only one that returns what I would expect. getAbsoluteRight()
returns the same value as getAbsoluteLeft()
, and both getOffsetWidth()
and getElement().getClientWidth()
return 0.
Why?
FYI, I calculated the width from the original x value used to create the Text Shape (x then became the center) and getAbsoluteLeft()
, which actually returned the expected value.