Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » External labels on node - question on positioning
External labels on node - question on positioning [message #187049] Wed, 14 May 2008 21:58 Go to next message
Philip Mayer is currently offline Philip Mayer
Messages: 17
Registered: July 2009
Junior Member
Hi,

I am attaching an external label to a node using the approach described
below. However, positioning the external label is rather cumbersome - it
only allows certain positions (in a circle) around the node. I have the
same problem in the official Eclipse UML2 Activity Diagram Editor when
adding pins to an action and naming them (Eclipse 3.3.2).

Is there any way, preferable without changing code, to get external
labels of a node to act like the ones on connections, i.e. completely
free positioning, and a (ideally) dotted line displayed while moving
them, as for example in the EMF Class Diagram Editor for connections?

Thanks!

-phil

How I add external labels:

* In .gmfgraph, add a custom Figure Descriptor in the Figure Gallery
with one child - the label.
* In .gmfgraph, add a Diagram Label for this very figure
* In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning [message #187308 is a reply to message #187049] Thu, 15 May 2008 13:00 Go to previous messageGo to next message
Eclipse User
Originally posted by: 5d5.mail.ru

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=127491

Philip Mayer wrote:
> Hi,
>
> I am attaching an external label to a node using the approach described
> below. However, positioning the external label is rather cumbersome - it
> only allows certain positions (in a circle) around the node. I have the
> same problem in the official Eclipse UML2 Activity Diagram Editor when
> adding pins to an action and naming them (Eclipse 3.3.2).
>
> Is there any way, preferable without changing code, to get external
> labels of a node to act like the ones on connections, i.e. completely
> free positioning, and a (ideally) dotted line displayed while moving
> them, as for example in the EMF Class Diagram Editor for connections?
>
> Thanks!
>
> -phil
>
> How I add external labels:
>
> * In .gmfgraph, add a custom Figure Descriptor in the Figure Gallery
> with one child - the label.
> * In .gmfgraph, add a Diagram Label for this very figure
> * In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning [message #187391 is a reply to message #187308] Thu, 15 May 2008 19:10 Go to previous messageGo to next message
Philip Mayer is currently offline Philip Mayer
Messages: 17
Registered: July 2009
Junior Member
Hello Dmitry,

thanks for your answer! I am not sure what to make of it, though :(.

The bug report (comment #15/#16) seem to suggest that the current
implementation of GMF handles free positioning by default. If this is
indeed the case then I obviously have done something wrong, because I
can only navigate those labels to about 4 to 8 positions around the node
in a fixed distance. Are my steps which I wrote in the last post
incorrect? My label edit part implements IBorderItemEditPart, it is
added as a border item with a BorderItemLocator (I tried switching to
LabelLocator, to no avail).

Or are you suggesting I follow the approach with a second layer for
labels as described in the bug report?

Thanks again,

Philip



Dmitry Stadnik schrieb:
> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=127491
>
> Philip Mayer wrote:
>> Hi,
>>
>> I am attaching an external label to a node using the approach
>> described below. However, positioning the external label is rather
>> cumbersome - it only allows certain positions (in a circle) around the
>> node. I have the same problem in the official Eclipse UML2 Activity
>> Diagram Editor when adding pins to an action and naming them (Eclipse
>> 3.3.2).
>>
>> Is there any way, preferable without changing code, to get external
>> labels of a node to act like the ones on connections, i.e. completely
>> free positioning, and a (ideally) dotted line displayed while moving
>> them, as for example in the EMF Class Diagram Editor for connections?
>>
>> Thanks!
>>
>> -phil
>>
>> How I add external labels:
>>
>> * In .gmfgraph, add a custom Figure Descriptor in the Figure Gallery
>> with one child - the label.
>> * In .gmfgraph, add a Diagram Label for this very figure
>> * In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning [message #187411 is a reply to message #187391] Fri, 16 May 2008 08:49 Go to previous messageGo to next message
Eclipse User
Originally posted by: 5d5.mail.ru

Briefly said I tried to let labels float far away but got many problems
(see the request) and eventually switched to bordered items. You may try
to mess with layers or bordered item locator - basically you may code
greater distance or custom positioning. The percieved '4 to 8 positions'
may be a consequence of having a small host figure with long label - as
a border item it should be positioned on the imaginary border of the
host and since this border is too small item is placed only in the
corner of the border; there is simply not enough place.

Philip Mayer wrote:
>
> Hello Dmitry,
>
> thanks for your answer! I am not sure what to make of it, though :(.
>
> The bug report (comment #15/#16) seem to suggest that the current
> implementation of GMF handles free positioning by default. If this is
> indeed the case then I obviously have done something wrong, because I
> can only navigate those labels to about 4 to 8 positions around the node
> in a fixed distance. Are my steps which I wrote in the last post
> incorrect? My label edit part implements IBorderItemEditPart, it is
> added as a border item with a BorderItemLocator (I tried switching to
> LabelLocator, to no avail).
>
> Or are you suggesting I follow the approach with a second layer for
> labels as described in the bug report?
>
> Thanks again,
>
> Philip
>
>
>
> Dmitry Stadnik schrieb:
>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=127491
>>
>> Philip Mayer wrote:
>>> Hi,
>>>
>>> I am attaching an external label to a node using the approach
>>> described below. However, positioning the external label is rather
>>> cumbersome - it only allows certain positions (in a circle) around
>>> the node. I have the same problem in the official Eclipse UML2
>>> Activity Diagram Editor when adding pins to an action and naming them
>>> (Eclipse 3.3.2).
>>>
>>> Is there any way, preferable without changing code, to get external
>>> labels of a node to act like the ones on connections, i.e. completely
>>> free positioning, and a (ideally) dotted line displayed while moving
>>> them, as for example in the EMF Class Diagram Editor for connections?
>>>
>>> Thanks!
>>>
>>> -phil
>>>
>>> How I add external labels:
>>>
>>> * In .gmfgraph, add a custom Figure Descriptor in the Figure Gallery
>>> with one child - the label.
>>> * In .gmfgraph, add a Diagram Label for this very figure
>>> * In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning [message #188681 is a reply to message #187411] Thu, 22 May 2008 10:49 Go to previous messageGo to next message
Philip Mayer is currently offline Philip Mayer
Messages: 17
Registered: July 2009
Junior Member
Dear Dmitry,

thanks again for your input. I have now written my own BorderItemLocator
which allows the placement as I would like it to have.

It is working now as I intended it to. Thanks!

Philip


Dmitry Stadnik schrieb:
> Briefly said I tried to let labels float far away but got many problems
> (see the request) and eventually switched to bordered items. You may try
> to mess with layers or bordered item locator - basically you may code
> greater distance or custom positioning. The percieved '4 to 8 positions'
> may be a consequence of having a small host figure with long label - as
> a border item it should be positioned on the imaginary border of the
> host and since this border is too small item is placed only in the
> corner of the border; there is simply not enough place.
>
> Philip Mayer wrote:
>>
>> Hello Dmitry,
>>
>> thanks for your answer! I am not sure what to make of it, though :(.
>>
>> The bug report (comment #15/#16) seem to suggest that the current
>> implementation of GMF handles free positioning by default. If this is
>> indeed the case then I obviously have done something wrong, because I
>> can only navigate those labels to about 4 to 8 positions around the
>> node in a fixed distance. Are my steps which I wrote in the last post
>> incorrect? My label edit part implements IBorderItemEditPart, it is
>> added as a border item with a BorderItemLocator (I tried switching to
>> LabelLocator, to no avail).
>>
>> Or are you suggesting I follow the approach with a second layer for
>> labels as described in the bug report?
>>
>> Thanks again,
>>
>> Philip
>>
>>
>>
>> Dmitry Stadnik schrieb:
>>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=127491
>>>
>>> Philip Mayer wrote:
>>>> Hi,
>>>>
>>>> I am attaching an external label to a node using the approach
>>>> described below. However, positioning the external label is rather
>>>> cumbersome - it only allows certain positions (in a circle) around
>>>> the node. I have the same problem in the official Eclipse UML2
>>>> Activity Diagram Editor when adding pins to an action and naming
>>>> them (Eclipse 3.3.2).
>>>>
>>>> Is there any way, preferable without changing code, to get external
>>>> labels of a node to act like the ones on connections, i.e.
>>>> completely free positioning, and a (ideally) dotted line displayed
>>>> while moving them, as for example in the EMF Class Diagram Editor
>>>> for connections?
>>>>
>>>> Thanks!
>>>>
>>>> -phil
>>>>
>>>> How I add external labels:
>>>>
>>>> * In .gmfgraph, add a custom Figure Descriptor in the Figure Gallery
>>>> with one child - the label.
>>>> * In .gmfgraph, add a Diagram Label for this very figure
>>>> * In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning [message #188868 is a reply to message #187049] Thu, 22 May 2008 23:01 Go to previous messageGo to next message
Eclipse User
Originally posted by: ste-re.gmx.de

Hi,

I got similar problem. I created an external Label for a node which
shows the expected value., but I got problems with position of rhis
label. I'd like to have it on a fixed side of the node (at the right
upper corner) but i can move it around the hole node figure.
I tried to fix it by setting "affixed parent side" but it seems to
have no effect.
BTW: I use Eplise 3.3.2 with GMF 2.02

Any ideas? Thanks
Stefan

Philip Mayer schrieb:
> Hi,
>
> I am attaching an external label to a node using the approach described
> below. However, positioning the external label is rather cumbersome - it
> only allows certain positions (in a circle) around the node. I have the
> same problem in the official Eclipse UML2 Activity Diagram Editor when
> adding pins to an action and naming them (Eclipse 3.3.2).
>
> Is there any way, preferable without changing code, to get external
> labels of a node to act like the ones on connections, i.e. completely
> free positioning, and a (ideally) dotted line displayed while moving
> them, as for example in the EMF Class Diagram Editor for connections?
>
> Thanks!
>
> -phil
>
> How I add external labels:
>
> * In .gmfgraph, add a custom Figure Descriptor in the Figure Gallery
> with one child - the label.
> * In .gmfgraph, add a Diagram Label for this very figure
> * In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning (solved) [message #191800 is a reply to message #188681] Tue, 10 June 2008 08:30 Go to previous messageGo to next message
Philip Mayer is currently offline Philip Mayer
Messages: 17
Registered: July 2009
Junior Member
Follow-up to my answer: If you want to have a line during the drag
operation as well, you can do the following:

Additionally to adding your own BorderItemLocator, you create your own
BorderItemSelectionEditPolicy in which you can (additionally) add a
PolyLineConnection between the current drag figure and the parent (just
add it with addFeeback(), and be sure to remove it later on). You can
then add the policy in the edit parts of the parent figure.

Using these two changes, dragging of labels on nodes effectively looks
like the dragging of labels on connections, which was my original
question. Nice! :)

Philip


Philip Mayer wrote:
>
> Dear Dmitry,
>
> thanks again for your input. I have now written my own BorderItemLocator
> which allows the placement as I would like it to have.
>
> It is working now as I intended it to. Thanks!
>
> Philip
>
>
> Dmitry Stadnik schrieb:
>> Briefly said I tried to let labels float far away but got many
>> problems (see the request) and eventually switched to bordered items.
>> You may try to mess with layers or bordered item locator - basically
>> you may code greater distance or custom positioning. The percieved '4
>> to 8 positions' may be a consequence of having a small host figure
>> with long label - as a border item it should be positioned on the
>> imaginary border of the host and since this border is too small item
>> is placed only in the corner of the border; there is simply not enough
>> place.
>>
>> Philip Mayer wrote:
>>>
>>> Hello Dmitry,
>>>
>>> thanks for your answer! I am not sure what to make of it, though :(.
>>>
>>> The bug report (comment #15/#16) seem to suggest that the current
>>> implementation of GMF handles free positioning by default. If this is
>>> indeed the case then I obviously have done something wrong, because I
>>> can only navigate those labels to about 4 to 8 positions around the
>>> node in a fixed distance. Are my steps which I wrote in the last post
>>> incorrect? My label edit part implements IBorderItemEditPart, it is
>>> added as a border item with a BorderItemLocator (I tried switching to
>>> LabelLocator, to no avail).
>>>
>>> Or are you suggesting I follow the approach with a second layer for
>>> labels as described in the bug report?
>>>
>>> Thanks again,
>>>
>>> Philip
>>>
>>>
>>>
>>> Dmitry Stadnik schrieb:
>>>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=127491
>>>>
>>>> Philip Mayer wrote:
>>>>> Hi,
>>>>>
>>>>> I am attaching an external label to a node using the approach
>>>>> described below. However, positioning the external label is rather
>>>>> cumbersome - it only allows certain positions (in a circle) around
>>>>> the node. I have the same problem in the official Eclipse UML2
>>>>> Activity Diagram Editor when adding pins to an action and naming
>>>>> them (Eclipse 3.3.2).
>>>>>
>>>>> Is there any way, preferable without changing code, to get external
>>>>> labels of a node to act like the ones on connections, i.e.
>>>>> completely free positioning, and a (ideally) dotted line displayed
>>>>> while moving them, as for example in the EMF Class Diagram Editor
>>>>> for connections?
>>>>>
>>>>> Thanks!
>>>>>
>>>>> -phil
>>>>>
>>>>> How I add external labels:
>>>>>
>>>>> * In .gmfgraph, add a custom Figure Descriptor in the Figure
>>>>> Gallery with one child - the label.
>>>>> * In .gmfgraph, add a Diagram Label for this very figure
>>>>> * In .gmfmap, add a Feature Label Mapping using this figure.
Re: External labels on node - question on positioning (solved) [message #665858 is a reply to message #191800] Sun, 17 April 2011 10:35 Go to previous messageGo to next message
Piotr Trojanek is currently offline Piotr Trojanek
Messages: 7
Registered: October 2010
Junior Member
Dear Philip,

can you share your BorderItemLocator code (preferably together with a link during dragging)?

This is exactly what I need in my GMF editor. Your post is pretty old, but I could not find any more up-to-date reference about this issue.

Thanks in advance,
Piotr
Re: External labels on node - question on positioning (solved) [message #665884 is a reply to message #665858] Sun, 17 April 2011 21:59 Go to previous message
Piotr Trojanek is currently offline Piotr Trojanek
Messages: 7
Registered: October 2010
Junior Member
I have finally found a complete solution.

1. In order to allow a label to float around a node you have to override two following two methods when creating the BorderItemLocator in the addBorderItem() (do not forget to change the @generator to NOT).

BorderItemLocator locator = new BorderItemLocator(getMainFigure(),
		PositionConstants.SOUTH) {
	@Override
	protected Point locateOnParent(Point suggestedLocation,
			int suggestedSide, IFigure borderItem) {
		return suggestedLocation;
	}

	@Override
	public Rectangle getValidLocation(Rectangle proposedLocation,
			IFigure borderItem) {
		return proposedLocation;
	}
};


2. If you need a link during dragging the label you have to substitute the EditPolicy in the createLayoutPolicy() method:

		//return new BorderItemSelectionEditPolicy() {
		return new NonResizableLabelEditPolicy() {


I Hope this post will be helpful for other GMF users.

Piotr.

[Updated on: Sun, 17 April 2011 22:00]

Report message to a moderator

Previous Topic:Changing Palette Icons programmatically
Next Topic:How to modify a position attribute in real time?
Goto Forum:
  


Current Time: Fri Sep 19 10:03:15 GMT 2014

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

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