Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » draw2d: label follows figure
draw2d: label follows figure [message #229283] Wed, 17 January 2007 22:05 Go to next message
Eclipse UserFriend
Originally posted by: aleksandr_kravets.iwaysoftware.com

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
Re: draw2d: label follows figure [message #229292 is a reply to message #229283] Thu, 18 January 2007 07:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jakub.jurkiewicz.gmail.com

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
You could try to create your own figure, taht would based on
ImageFigure. Than you just would have to add the label with some offset.
Maybe there is some better way to do it, so if somebody knows how to do
it more efficiently, then please write.

regards,
Jakub Jurkiewicz
Re: draw2d: label follows figure [message #229313 is a reply to message #229292] Thu, 18 January 2007 08:35 Go to previous messageGo to next message
Manuel Selva is currently offline Manuel SelvaFriend
Messages: 189
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

Yes you should create your own figure LabeledImage for example, using its
own layout (FlowLayout maybe ...) to display the image and an underneath
label.

Hope this can help you

Manu


Re: draw2d: label follows figure [message #229330 is a reply to message #229283] Thu, 18 January 2007 14:43 Go to previous messageGo to next message
Nhu Le is currently offline Nhu LeFriend
Messages: 47
Registered: July 2009
Member
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
Re: draw2d: label follows figure [message #229345 is a reply to message #229313] Thu, 18 January 2007 14:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aleksandr_kravets.iwaysoftware.com

Thanks. But won't this be within bounds of one figure and essentially
what I will have is a figure with image and label. That is not what I am
looking for though. Here is the picture of what I mean:
http://farm1.static.flickr.com/136/361569642_20340e26b4.jpg? v=0

So I was thinking that even if I add a label to my figure and try to
offset it, the parent will clip it (?) and cut off the label so it will
not be visible since child is only visible within bounds of its parent, no?

thanks,
Alex

Manu wrote:
> Hi,
>
> Yes you should create your own figure LabeledImage for example, using
> its own layout (FlowLayout maybe ...) to display the image and an
> underneath label.
>
> Hope this can help you
>
> Manu
>
Re: draw2d: label follows figure [message #229351 is a reply to message #229330] Thu, 18 January 2007 15:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aleksandr_kravets.iwaysoftware.com

But the image and label will be part of one figure, and perimeter of
handles will go around both image and label. Ok, this is a better
picture of what I am talking about:
http://farm1.static.flickr.com/146/361592242_a221ec83c1.jpg? v=0

So only image is selectable, dragable and can be connected to or from,
label is just a satellite that follows this image figure always at the
same location.

I don't know may be this is not even possible?

thanks,
Alex

Nhu Le wrote:
> 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
Re: draw2d: label follows figure [message #229358 is a reply to message #229351] Thu, 18 January 2007 16:48 Go to previous messageGo to next message
Nhu Le is currently offline Nhu LeFriend
Messages: 47
Registered: July 2009
Member
In the first option I discussed, they image and label are technically
the same figure but visually, it should be exactly like what you
describe in the picture.

In your figure, you implements HandleBounds and the method
getHandleBounds() should return the image figure only (not the parent
figure which will contain both the image figure and the label). When
this is done, the selection handles will be placed around the handle
bound figure only (your image figure).




Aleksandr Kravets wrote:
> But the image and label will be part of one figure, and perimeter of
> handles will go around both image and label. Ok, this is a better
> picture of what I am talking about:
> http://farm1.static.flickr.com/146/361592242_a221ec83c1.jpg? v=0
>
> So only image is selectable, dragable and can be connected to or from,
> label is just a satellite that follows this image figure always at the
> same location.
>
> I don't know may be this is not even possible?
>
> thanks,
> Alex
>
> Nhu Le wrote:
>> 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
Re: draw2d: label follows figure [message #229374 is a reply to message #229358] Thu, 18 January 2007 18:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aleksandr_kravets.iwaysoftware.com

Ah, got it. Will try it. Thanks!
Nhu Le wrote:
> In the first option I discussed, they image and label are technically
> the same figure but visually, it should be exactly like what you
> describe in the picture.
>
> In your figure, you implements HandleBounds and the method
> getHandleBounds() should return the image figure only (not the parent
> figure which will contain both the image figure and the label). When
> this is done, the selection handles will be placed around the handle
> bound figure only (your image figure).
>
>
>
>
> Aleksandr Kravets wrote:
>> But the image and label will be part of one figure, and perimeter of
>> handles will go around both image and label. Ok, this is a better
>> picture of what I am talking about:
>> http://farm1.static.flickr.com/146/361592242_a221ec83c1.jpg? v=0
>>
>> So only image is selectable, dragable and can be connected to or from,
>> label is just a satellite that follows this image figure always at the
>> same location.
>>
>> I don't know may be this is not even possible?
>>
>> thanks,
>> Alex
>>
>> Nhu Le wrote:
>>> 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
Re: draw2d: label follows figure [message #229382 is a reply to message #229374] Thu, 18 January 2007 18:37 Go to previous messageGo to next message
Nhu Le is currently offline Nhu LeFriend
Messages: 47
Registered: July 2009
Member
If you want it so that user has to click on the image figure to select
the main figure, you have to override containPoint() and test the
parameter against whatever child figure you want.

Nhu

Aleksandr Kravets wrote:
> Ah, got it. Will try it. Thanks!
> Nhu Le wrote:
>> In the first option I discussed, they image and label are technically
>> the same figure but visually, it should be exactly like what you
>> describe in the picture.
>>
>> In your figure, you implements HandleBounds and the method
>> getHandleBounds() should return the image figure only (not the parent
>> figure which will contain both the image figure and the label). When
>> this is done, the selection handles will be placed around the handle
>> bound figure only (your image figure).
>>
>>
>>
>>
>> Aleksandr Kravets wrote:
>>> But the image and label will be part of one figure, and perimeter of
>>> handles will go around both image and label. Ok, this is a better
>>> picture of what I am talking about:
>>> http://farm1.static.flickr.com/146/361592242_a221ec83c1.jpg? v=0
>>>
>>> So only image is selectable, dragable and can be connected to or
>>> from, label is just a satellite that follows this image figure always
>>> at the same location.
>>>
>>> I don't know may be this is not even possible?
>>>
>>> thanks,
>>> Alex
>>>
>>> Nhu Le wrote:
>>>> 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
Re: draw2d: label follows figure [message #237199 is a reply to message #229330] Wed, 25 July 2007 13:38 Go to previous message
Eclipse UserFriend
Originally posted by: alexandre.magillem.com

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
Previous Topic:"Link cursor" when dragging parts in outline view
Next Topic:Loading a file causes layout problems
Goto Forum:
  


Current Time: Fri Apr 19 03:33:06 GMT 2024

Powered by FUDForum. Page generated in 0.02690 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top