How to get default size of a node [message #208181] |
Thu, 09 October 2008 15:00 |
Eclipse User |
|
|
|
Originally posted by: zzhangh.cn.ibm.com
Hi,
Suppose I have an instance of org.eclipse.gmf.runtime.notation.Node, using Node#getLayoutConstraint I can get its Bounds
instance, but mostly bounds.getWidth() and bounds.getHeight() return -1, unless I changed the node's size before. So the
question is how to get the node's default width and height, thanks!
Regards,
Hao
|
|
|
Re: How to get default size of a node [message #208318 is a reply to message #208181] |
Fri, 10 October 2008 21:44 |
Eclipse User |
|
|
|
Originally posted by: thomas.beyer.t-online.de
Hello Hao,
my experience: you simply can't!
If you do an auto-resize on the figure, the figure will not have width
and height constraints either (even if it had before).
I tried two steps to get the bounds:
1. Access the matching EditPart for this node and get the bounds from
there. If you do not have the editor open, you could use the
OffScreenEditPartFactory (not sure what the exact name is) or
CopyToImageUtil to create a DiagramEditPart from the notational Diagram
and go from there.
2. You could modify your save-routine in the generated DiagramEditor to
make sure, all nodes get persisted with height and width parameters in
the layout constraints. You should check, if you could live with
auto-resize side-effect that come with this approach. I remember, there
were some issues.
HTH & regards
Thomas
Hao Zhang schrieb:
> Hi,
> Suppose I have an instance of org.eclipse.gmf.runtime.notation.Node, using Node#getLayoutConstraint I can get its Bounds
> instance, but mostly bounds.getWidth() and bounds.getHeight() return -1, unless I changed the node's size before. So the
> question is how to get the node's default width and height, thanks!
>
> Regards,
> Hao
|
|
|
Powered by
FUDForum. Page generated in 0.01857 seconds