[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: draw2d: label follows figure

Hi all,
I've been using the first proposed technique to add Labels following connectors. Works great.
My problem is now that when I want to move the connectors, the constraint I get in the method :
createChangeConstraintCommand(EditPart child, Object constraint);
is computed from the figure bounds and not from the HandleBounds bounds.


The position of the constraint I get is the bounding box of all the figure and not the Rectangle getHandleBounds().

I use the position of the new bounds to see if it's a legal position, my connectors are able to move around their owner.

Does someone know if there is a way to get the HandleBounds bounds of the moved object from the createChangeConstraintCommand method ?

Regards.
Christophe




Nhu Le a écrit :
If you want a label that is always at the same location wrt the figure, then you have to create your own figure with some transparent border to put the label (to create the illusion that the label is outside the figure). Look into getHandleBounds() of interface HandleBounds.

If you want a label that can be moved anywhere on the screen (like in the case of a label of a port for a component) then you may want to create another layer for your labels and create a label locator class (extends AbstractLocator). The parent-child figure relationship will obviously not like usual but since the label should be the leaf of the relationship tree, you can probably create a simple (like getOwner()???) just so that you can get to the figure from the label (to replace getParent()).

Nhu

Aleksandr Kravets wrote:
Hello,

In my GEF application I have a figure which is basically an ImageFigure. I am looking for a way to create a label that follows that figure. I tried using DelegatingLayout on my figure, but of course the label is positioned in the figure, may be there is a way to offset the positioning of the label so it's outside the figure?

Thanks for your help,
Alex