Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » how can I make the size of a figure adjustable to the canvas?
how can I make the size of a figure adjustable to the canvas? [message #163060] Wed, 28 November 2007 10:09 Go to next message
Eclipse UserFriend
Hi.
I am wondering how I can model a figure which is able to change its
size relative to the canvas.
Thanks.
Michael.
Re: how can I make the size of a figure adjustable to the canvas? [message #163090 is a reply to message #163060] Wed, 28 November 2007 10:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ali.akar.geensys.com

hello,

I have an idea but i didnt try it, you can listen at canvas' size
changes, then calling something like "canvas.getClientArea", here you
will have the new size after this step you can resize your figure with a
coef like "figureSise = canvasSize/2".

I hope this help you !
Ali



Michael a écrit :
> Hi.
> I am wondering how I can model a figure which is able to change its
> size relative to the canvas.
> Thanks.
> Michael.
>
>
Re: how can I make the size of a figure adjustable to the canvas? [message #163131 is a reply to message #163090] Wed, 28 November 2007 11:59 Go to previous messageGo to next message
Eclipse UserFriend
you have to get the bounds of the element you want the picture in, and
then use the value to resize your image.Actually you can make it bigger
than the canvas (gets cropped) or smaller (you got waste space).

something like (this should not work with copy'n paste) but take it as a
track:

MyImage = new Image(Display.getDefault(),MyImageDescriptor.getImageData()) ;
imgRectangle = MyImage.getBounds();

MyPicWidth = imgRectangle.width;
MyPicHeight = imgRectangle.height;

Dimension d = new Dimension(MyPicWidth, MyPicHeight);
setPreferredSize(d);

then you've to make sure that on resizing the node the node dimensions are
read and used as dimension for the image inside.

Hope it helps ;)

Paolo
Re: how can I make the size of a figure adjustable to the canvas? [message #163139 is a reply to message #163131] Wed, 28 November 2007 12:23 Go to previous messageGo to next message
Eclipse UserFriend
Thanks. Your reply is valueable to me. And I still get a solution which can
save us from manually modifying the source code. We can define the figure in
the graphical definition diagram in a way that its containing figure is laid
by a grid layout manage, and the figure, which is required to resize
according to the containing figure, has a GridData. In this GridData, the
attribute of 'Grab excess horizontal space' or 'Grab excess horizontal
space' is set to true. By this means, the figure can adjust its size to its
containing figure. All of these can be finished needless to modify the
source code.

You can see the part of 'GridData' for details at
http://www.eclipse.org/articles/Article-Understanding-Layout s/Understanding-Layouts.htm .

Thanks.
Michael.


"Paolo Russian" <paolo.russian@italtbs.com> wrote in message
news:7cfcc0d93d0bd847122a2463e2324495$1@www.eclipse.org...
> you have to get the bounds of the element you want the picture in, and
> then use the value to resize your image.Actually you can make it bigger
> than the canvas (gets cropped) or smaller (you got waste space).
>
> something like (this should not work with copy'n paste) but take it as a
> track:
>
> MyImage = new
> Image(Display.getDefault(),MyImageDescriptor.getImageData()) ;
> imgRectangle = MyImage.getBounds();
>
> MyPicWidth = imgRectangle.width;
> MyPicHeight = imgRectangle.height;
>
> Dimension d = new Dimension(MyPicWidth, MyPicHeight);
> setPreferredSize(d);
>
> then you've to make sure that on resizing the node the node dimensions are
> read and used as dimension for the image inside.
>
> Hope it helps ;)
>
> Paolo
>
Re: how can I make the size of a figure adjustable to the canvas? [message #163217 is a reply to message #163139] Thu, 29 November 2007 04:52 Go to previous message
Eclipse UserFriend
what do you do exactly to achieve this? If I understood what you said, you
customize the gmgraph by grabbing some node's properties and setting in
there both the image and the gridlayout... but I cannot find such features
in my gmgraph node properties.
In my method I override the default node drawing code telling him to draw
an image, then someway to adapt its size to the node bounds. As the most
of us have to do with gmf (hehe) I proceed by almost-random trials until I
get it to work as I want, and I found that StackLayout works good for this
resize thing, but perhaps it's not the best way to do this.
Previous Topic:ScaledGraphics & SWTGraphics Together for Rotation
Next Topic:sorting custom propsheet in-groups
Goto Forum:
  


Current Time: Sat May 10 11:32:07 EDT 2025

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

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

Back to the top