Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Layout question
Layout question [message #230809] Sun, 18 February 2007 17:16 Go to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
Hi,

I have created a UML editor using GEF. It displays an EMF model by creating
edit parts. Sadly the size of the rectangle figures within the edit parts
that display my EMF model vary. Hence when I want to run the entire
hierarchy of figures through my layout algorithm to recompute its X, Y
position, I see that the width and height of the figures are 0. Here is how
I have plugged in my layout algorithm -

Action : Select a node ( Class ) and click Show children
- I get the children from the EMF model
- Create edit parts for the children [ Note each child is a ClassEditPart
and internally it has sub edit parts that are attributes and this is where
the number of attributes and the width of each attribute vary ]
- Add them to the parent edit part
- Add edge edit parts
- Call my layout algorithm

Here is where I have the issue. It appears the actual size of each of the
new child edit parts added to the editor is computed only when the edit
parts are drawn. So when I do a relayout of the entire hierarchy using my
algorithm, it fails since the sizes are incorrect. Could you let me know how
to pre-calculate the size of each edit part, then make a call to my relayout
algorithm and then do a paint of the edit parts?
Should I be writing a layout manager and plug it into the root edit part? If
so where should I be plugging my layout manager?

Thanks.
Re: Layout question [message #230892 is a reply to message #230809] Thu, 22 February 2007 06:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Is this a custom layout that you're using? Perhaps the constraints of the
children haven't been registered when you're laying out? Are you explicitly
forcing a layout? A layout will be triggered on its own when the child
figure is added to the parent. Using smart constraints (-1 means the
preferred size), you should be able to do this within the current framework.

"Rashmy" <appanera@ugs.com> wrote in message
news:era1m1$ntv$1@utils.eclipse.org...
> Hi,
>
> I have created a UML editor using GEF. It displays an EMF model by
> creating edit parts. Sadly the size of the rectangle figures within the
> edit parts that display my EMF model vary. Hence when I want to run the
> entire hierarchy of figures through my layout algorithm to recompute its
> X, Y position, I see that the width and height of the figures are 0. Here
> is how I have plugged in my layout algorithm -
>
> Action : Select a node ( Class ) and click Show children
> - I get the children from the EMF model
> - Create edit parts for the children [ Note each child is a ClassEditPart
> and internally it has sub edit parts that are attributes and this is where
> the number of attributes and the width of each attribute vary ]
> - Add them to the parent edit part
> - Add edge edit parts
> - Call my layout algorithm
>
> Here is where I have the issue. It appears the actual size of each of the
> new child edit parts added to the editor is computed only when the edit
> parts are drawn. So when I do a relayout of the entire hierarchy using my
> algorithm, it fails since the sizes are incorrect. Could you let me know
> how to pre-calculate the size of each edit part, then make a call to my
> relayout algorithm and then do a paint of the edit parts?
> Should I be writing a layout manager and plug it into the root edit part?
> If so where should I be plugging my layout manager?
>
> Thanks.
>
Re: Layout question [message #231076 is a reply to message #230892] Mon, 26 February 2007 15:22 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
Yes, I would like to do an explicit call to do a layout. The reason being,
the children added will be of different widht and height. I have to
calculate their width and height in one pass and then invoke a relayout on
all objects in my canvas.

Is there any article on custom layouts that I can refer to? How would I make
a single call to my custom layout algo to do the layout and then invoke a
repaint method to refresh the objects position on the canvas?

Thanks.

"Pratik Shah" <none@unknown.com> wrote in message
news:erjclh$m5i$1@utils.eclipse.org...
> Is this a custom layout that you're using? Perhaps the constraints of the
> children haven't been registered when you're laying out? Are you
> explicitly forcing a layout? A layout will be triggered on its own when
> the child figure is added to the parent. Using smart constraints (-1
> means the preferred size), you should be able to do this within the
> current framework.
>
> "Rashmy" <appanera@ugs.com> wrote in message
> news:era1m1$ntv$1@utils.eclipse.org...
>> Hi,
>>
>> I have created a UML editor using GEF. It displays an EMF model by
>> creating edit parts. Sadly the size of the rectangle figures within the
>> edit parts that display my EMF model vary. Hence when I want to run the
>> entire hierarchy of figures through my layout algorithm to recompute its
>> X, Y position, I see that the width and height of the figures are 0. Here
>> is how I have plugged in my layout algorithm -
>>
>> Action : Select a node ( Class ) and click Show children
>> - I get the children from the EMF model
>> - Create edit parts for the children [ Note each child is a ClassEditPart
>> and internally it has sub edit parts that are attributes and this is
>> where the number of attributes and the width of each attribute vary ]
>> - Add them to the parent edit part
>> - Add edge edit parts
>> - Call my layout algorithm
>>
>> Here is where I have the issue. It appears the actual size of each of the
>> new child edit parts added to the editor is computed only when the edit
>> parts are drawn. So when I do a relayout of the entire hierarchy using my
>> algorithm, it fails since the sizes are incorrect. Could you let me know
>> how to pre-calculate the size of each edit part, then make a call to my
>> relayout algorithm and then do a paint of the edit parts?
>> Should I be writing a layout manager and plug it into the root edit part?
>> If so where should I be plugging my layout manager?
>>
>> Thanks.
>>
>
>
Re: Layout question [message #231219 is a reply to message #231076] Wed, 28 February 2007 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Figure#invalidateTree() can be used to invalidate the entire figure
hierarchy by invoking it on the root figure. You can then revalidate() the
root figure, and when validation happens, everything will be laid out again
for you. You shouldn't be invoking layout or repaint explicitly.

"Rashmy" <appanera@ugs.com> wrote in message
news:erutv4$e86$1@utils.eclipse.org...
> Yes, I would like to do an explicit call to do a layout. The reason being,
> the children added will be of different widht and height. I have to
> calculate their width and height in one pass and then invoke a relayout on
> all objects in my canvas.
>
> Is there any article on custom layouts that I can refer to? How would I
> make a single call to my custom layout algo to do the layout and then
> invoke a repaint method to refresh the objects position on the canvas?
>
> Thanks.
>
> "Pratik Shah" <none@unknown.com> wrote in message
> news:erjclh$m5i$1@utils.eclipse.org...
>> Is this a custom layout that you're using? Perhaps the constraints of
>> the children haven't been registered when you're laying out? Are you
>> explicitly forcing a layout? A layout will be triggered on its own when
>> the child figure is added to the parent. Using smart constraints (-1
>> means the preferred size), you should be able to do this within the
>> current framework.
>>
>> "Rashmy" <appanera@ugs.com> wrote in message
>> news:era1m1$ntv$1@utils.eclipse.org...
>>> Hi,
>>>
>>> I have created a UML editor using GEF. It displays an EMF model by
>>> creating edit parts. Sadly the size of the rectangle figures within the
>>> edit parts that display my EMF model vary. Hence when I want to run the
>>> entire hierarchy of figures through my layout algorithm to recompute its
>>> X, Y position, I see that the width and height of the figures are 0.
>>> Here is how I have plugged in my layout algorithm -
>>>
>>> Action : Select a node ( Class ) and click Show children
>>> - I get the children from the EMF model
>>> - Create edit parts for the children [ Note each child is a
>>> ClassEditPart and internally it has sub edit parts that are attributes
>>> and this is where the number of attributes and the width of each
>>> attribute vary ]
>>> - Add them to the parent edit part
>>> - Add edge edit parts
>>> - Call my layout algorithm
>>>
>>> Here is where I have the issue. It appears the actual size of each of
>>> the new child edit parts added to the editor is computed only when the
>>> edit parts are drawn. So when I do a relayout of the entire hierarchy
>>> using my algorithm, it fails since the sizes are incorrect. Could you
>>> let me know how to pre-calculate the size of each edit part, then make a
>>> call to my relayout algorithm and then do a paint of the edit parts?
>>> Should I be writing a layout manager and plug it into the root edit
>>> part? If so where should I be plugging my layout manager?
>>>
>>> Thanks.
>>>
>>
>>
>
>
Re: Layout question [message #231527 is a reply to message #231219] Fri, 09 March 2007 14:29 Go to previous message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
Hi,
I tried to use the invalidateTree() and revalidateTree() on my root figures
but it does not help me. The reason I see is that the width and height of my
figures is determined only when child edit part are created. Here is what I
have -
A ClassEditPart with all its attributes shown in teh UML editor.
Next I select this class and say show children
Now the child class view nodes are created and added to the parent view node
This will trigger creation of a ClassEditPart for each of the child view
node objects.
When a ClassEditpart is created it will internally then trigger adding
AttributeEditParts for each class
Thus until all edit parts are created I do not know what is the width and
height of each figure to do my layout.

Could you let me know how I can pre-calculate the width and height of the
edit parts and then trigger a relayout?
It would help if you can point me to some examples or articles on GEF
layouts.

Thanks,
Rashmy


"Pratik Shah" <none@unknown.com> wrote in message
news:es45pb$6rq$1@utils.eclipse.org...
> Figure#invalidateTree() can be used to invalidate the entire figure
> hierarchy by invoking it on the root figure. You can then revalidate()
> the root figure, and when validation happens, everything will be laid out
> again for you. You shouldn't be invoking layout or repaint explicitly.
>
> "Rashmy" <appanera@ugs.com> wrote in message
> news:erutv4$e86$1@utils.eclipse.org...
>> Yes, I would like to do an explicit call to do a layout. The reason
>> being, the children added will be of different widht and height. I have
>> to calculate their width and height in one pass and then invoke a
>> relayout on all objects in my canvas.
>>
>> Is there any article on custom layouts that I can refer to? How would I
>> make a single call to my custom layout algo to do the layout and then
>> invoke a repaint method to refresh the objects position on the canvas?
>>
>> Thanks.
>>
>> "Pratik Shah" <none@unknown.com> wrote in message
>> news:erjclh$m5i$1@utils.eclipse.org...
>>> Is this a custom layout that you're using? Perhaps the constraints of
>>> the children haven't been registered when you're laying out? Are you
>>> explicitly forcing a layout? A layout will be triggered on its own when
>>> the child figure is added to the parent. Using smart constraints (-1
>>> means the preferred size), you should be able to do this within the
>>> current framework.
>>>
>>> "Rashmy" <appanera@ugs.com> wrote in message
>>> news:era1m1$ntv$1@utils.eclipse.org...
>>>> Hi,
>>>>
>>>> I have created a UML editor using GEF. It displays an EMF model by
>>>> creating edit parts. Sadly the size of the rectangle figures within the
>>>> edit parts that display my EMF model vary. Hence when I want to run the
>>>> entire hierarchy of figures through my layout algorithm to recompute
>>>> its X, Y position, I see that the width and height of the figures are
>>>> 0. Here is how I have plugged in my layout algorithm -
>>>>
>>>> Action : Select a node ( Class ) and click Show children
>>>> - I get the children from the EMF model
>>>> - Create edit parts for the children [ Note each child is a
>>>> ClassEditPart and internally it has sub edit parts that are attributes
>>>> and this is where the number of attributes and the width of each
>>>> attribute vary ]
>>>> - Add them to the parent edit part
>>>> - Add edge edit parts
>>>> - Call my layout algorithm
>>>>
>>>> Here is where I have the issue. It appears the actual size of each of
>>>> the new child edit parts added to the editor is computed only when the
>>>> edit parts are drawn. So when I do a relayout of the entire hierarchy
>>>> using my algorithm, it fails since the sizes are incorrect. Could you
>>>> let me know how to pre-calculate the size of each edit part, then make
>>>> a call to my relayout algorithm and then do a paint of the edit parts?
>>>> Should I be writing a layout manager and plug it into the root edit
>>>> part? If so where should I be plugging my layout manager?
>>>>
>>>> Thanks.
>>>>
>>>
>>>
>>
>>
>
>
Previous Topic:zoom and connection-width
Next Topic:REQ_MOVE and overlapping Layers problem
Goto Forum:
  


Current Time: Thu Apr 25 10:02:55 GMT 2024

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

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

Back to the top