What's the most efficient way to find the first common parent of two graphics objects?

2 visualizaciones (últimos 30 días)
After searching quite a bit, I'm hoping someone can help. I'm looking to find the first "connection point" or common ancestor between two graphics objects. The best I could find so far is very hackjob-ish:
PH = [];
H = get(H,'Parent');
while H ~= 0
PH = [PH,H]; % Note lack of preallocation
H = get(H,'Parent');
end
This would get every object in the ancestry line of H, all the way up to the containing figure. I could then do this a second time, this time for the second object, say, H2.
Seems rather inefficient, though, and I hate not preallocating.
In the end, what I really want is the ability to cast the Position of any Position-property-having object (this includes both 4-element Position vector objects and 3-element Position vector objects, namely, Text objects) into a new Position vector such that the repositioned object can be aligned with an object from another parent while still, of course, being defined in the reference frame of its own parent. To this end, I did check out two things: the align() function, which will not work with Text objects, and some undocumented Java stuff on Yair Altman's blog, specifically this:
However, this link is old, and the challenges being discussed there were overcome for my purposes by simply converting Text objects to units of 'normalized' prior to doing any transformations on the position property.
Any thoughts are appreciated!
Justin

Respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by