|Re: Prevent nodes from being dragged out of parent bounds (GEF5) [message #1770449 is a reply to message #1770448]
||Fri, 11 August 2017 14:09
|| Matthias Wienand
Registered: March 2015
there are multiple alternatives available for solving this issue:
A) Exchange child node part's TransformPolicy and prevent translation out of its parent's bounds, e.g. ParentRestrictedTransformPolicy. Then, you can bind it for all parts that should be restricted to their parent's bounds. No special code in the child parts is needed.
B) Override child node part's setVisualTransform() method and prevent translation out of its parent's bounds there. The ITransformableContentPart#setVisualTransform() method is called during interaction to apply the translation to the part's visual. The final visual transform (getVisualTransform()) is applied to the model using setContentTransform(). When choosing this alternative, you should probably factor out a RestrictToParentSupport that can simply be called.
Alternative B) is closer to your current status, so you can try it out easily. However, alternative A) allows for easier re-use, although a little more difficult to set-up.
[Updated on: Fri, 11 August 2017 14:10]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02239 seconds