Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to get Diagram size in layoutProvider
How to get Diagram size in layoutProvider [message #74282] Sat, 04 November 2006 14:24 Go to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hello all,

I am using a layoutProvider to create a grid like layout.
I need to put a column at the left extreme of the diagram space and one at
the right extreme also.
The left hand one is ok as I know I am starting from 0,0.
However I can't figure out the right hand side one.
I was thinking to get the figure used for the diagram and call getClientArea
on it.
However I can't figure out how to get that info into the layoutprovider
class.

Can anyone help ?

Thanks.
Re: How to get Diagram size in layoutProvider [message #74639 is a reply to message #74282] Mon, 06 November 2006 09:50 Go to previous messageGo to next message
Eclipse UserFriend
There is a helper method on the DiagramEditPart called getChildrenBounds
the method will return the children bounds (based on the current bounds
of the figures)




Alan wrote:
> Hello all,
>
> I am using a layoutProvider to create a grid like layout.
> I need to put a column at the left extreme of the diagram space and one at
> the right extreme also.
> The left hand one is ok as I know I am starting from 0,0.
> However I can't figure out the right hand side one.
> I was thinking to get the figure used for the diagram and call getClientArea
> on it.
> However I can't figure out how to get that info into the layoutprovider
> class.
>
> Can anyone help ?
>
> Thanks.
>
>
Re: How to get Diagram size in layoutProvider [message #74807 is a reply to message #74639] Mon, 06 November 2006 13:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hi,

Thanks for getting back to me.
How do I get a handle on the DiagramEditPart.

My class is called GridLayoutProvider and extends
AbstractLayoutNodeProvider.

The two methods are
public Runnable layoutLayoutNodes(List layoutNodes, boolean
offsetFromBoundingBox,IAdaptable layoutHint)

and

public boolean provides(IOperation operation)

I can't see obviously how to get a handle to the DiagramEditPart.

I can get the Diagram as:

ILayoutNode lnode = (ILayoutNode)li.next();

NodeImpl node = (NodeImpl)lnode.getNode();

Diagram di = node.basicGetDiagram();

But still can't seem to figure how to get the DiagramEditPart from here ?

Any thoughts ?









"Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
news:eini62$f2g$1@utils.eclipse.org...
> There is a helper method on the DiagramEditPart called getChildrenBounds
> the method will return the children bounds (based on the current bounds of
> the figures)
>
>
>
>
> Alan wrote:
>> Hello all,
>>
>> I am using a layoutProvider to create a grid like layout.
>> I need to put a column at the left extreme of the diagram space and one
>> at
>> the right extreme also.
>> The left hand one is ok as I know I am starting from 0,0.
>> However I can't figure out the right hand side one.
>> I was thinking to get the figure used for the diagram and call
>> getClientArea
>> on it.
>> However I can't figure out how to get that info into the layoutprovider
>> class.
>>
>> Can anyone help ?
>>
>> Thanks.
>>
Re: How to get Diagram size in layoutProvider [message #75455 is a reply to message #74807] Tue, 07 November 2006 11:24 Go to previous messageGo to next message
Eclipse UserFriend
try :

IGraphicalEditPart gep = (IGraphicalEditPart) layoutHint
.getAdapter(IGraphicalEditPart.class);
if (gep!=null){
Map registry = gep.getViewer().getEditPartRegistry();
// then get the diagram object some how
EditPart diagramEditPart = registry.get(diagram);
}

one comment though; avoid using the NodeImpl use Node instead
and use getDiagram instead of basicGetDiagram()

Frank Abercorn wrote:



> Hi,
>
> Thanks for getting back to me.
> How do I get a handle on the DiagramEditPart.
>
> My class is called GridLayoutProvider and extends
> AbstractLayoutNodeProvider.
>
> The two methods are
> public Runnable layoutLayoutNodes(List layoutNodes, boolean
> offsetFromBoundingBox,IAdaptable layoutHint)
>
> and
>
> public boolean provides(IOperation operation)
>
> I can't see obviously how to get a handle to the DiagramEditPart.
>
> I can get the Diagram as:
>
> ILayoutNode lnode = (ILayoutNode)li.next();
>
> NodeImpl node = (NodeImpl)lnode.getNode();
>
> Diagram di = node.basicGetDiagram();
>
> But still can't seem to figure how to get the DiagramEditPart from here ?
>
> Any thoughts ?
>
>
>
>
>
>
>
>
>
> "Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
> news:eini62$f2g$1@utils.eclipse.org...
>> There is a helper method on the DiagramEditPart called getChildrenBounds
>> the method will return the children bounds (based on the current bounds of
>> the figures)
>>
>>
>>
>>
>> Alan wrote:
>>> Hello all,
>>>
>>> I am using a layoutProvider to create a grid like layout.
>>> I need to put a column at the left extreme of the diagram space and one
>>> at
>>> the right extreme also.
>>> The left hand one is ok as I know I am starting from 0,0.
>>> However I can't figure out the right hand side one.
>>> I was thinking to get the figure used for the diagram and call
>>> getClientArea
>>> on it.
>>> However I can't figure out how to get that info into the layoutprovider
>>> class.
>>>
>>> Can anyone help ?
>>>
>>> Thanks.
>>>
>
Re: How to get Diagram size in layoutProvider [message #75576 is a reply to message #75455] Tue, 07 November 2006 14:24 Go to previous message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Thanks a lot that seems to have done it.


"Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
news:eiqc34$2vf$1@utils.eclipse.org...
> try :
>
> IGraphicalEditPart gep = (IGraphicalEditPart) layoutHint
> .getAdapter(IGraphicalEditPart.class);
> if (gep!=null){
> Map registry = gep.getViewer().getEditPartRegistry();
> // then get the diagram object some how
> EditPart diagramEditPart = registry.get(diagram);
> }
>
> one comment though; avoid using the NodeImpl use Node instead
> and use getDiagram instead of basicGetDiagram()
>
> Frank Abercorn wrote:
>
>
>
>> Hi,
>>
>> Thanks for getting back to me.
>> How do I get a handle on the DiagramEditPart.
>>
>> My class is called GridLayoutProvider and extends
>> AbstractLayoutNodeProvider.
>>
>> The two methods are
>> public Runnable layoutLayoutNodes(List layoutNodes, boolean
>> offsetFromBoundingBox,IAdaptable layoutHint)
>>
>> and
>>
>> public boolean provides(IOperation operation)
>>
>> I can't see obviously how to get a handle to the DiagramEditPart.
>>
>> I can get the Diagram as:
>>
>> ILayoutNode lnode = (ILayoutNode)li.next();
>>
>> NodeImpl node = (NodeImpl)lnode.getNode();
>>
>> Diagram di = node.basicGetDiagram();
>>
>> But still can't seem to figure how to get the DiagramEditPart from here ?
>>
>> Any thoughts ?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> "Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
>> news:eini62$f2g$1@utils.eclipse.org...
>>> There is a helper method on the DiagramEditPart called getChildrenBounds
>>> the method will return the children bounds (based on the current bounds
>>> of the figures)
>>>
>>>
>>>
>>>
>>> Alan wrote:
>>>> Hello all,
>>>>
>>>> I am using a layoutProvider to create a grid like layout.
>>>> I need to put a column at the left extreme of the diagram space and one
>>>> at
>>>> the right extreme also.
>>>> The left hand one is ok as I know I am starting from 0,0.
>>>> However I can't figure out the right hand side one.
>>>> I was thinking to get the figure used for the diagram and call
>>>> getClientArea
>>>> on it.
>>>> However I can't figure out how to get that info into the layoutprovider
>>>> class.
>>>>
>>>> Can anyone help ?
>>>>
>>>> Thanks.
>>>>
>>
Previous Topic:Changin the palette background and foreground colors
Next Topic:How can I refresh the diagram when properties change, that aer shown as labels in the diagram
Goto Forum:
  


Current Time: Fri Sep 19 06:22:52 EDT 2025

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

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

Back to the top