Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Creating an Image
Creating an Image [message #130459] Tue, 04 May 2004 14:04 Go to next message
Eclipse UserFriend
Originally posted by: phil.williams.toadmail.com

I asked this in the past, but have gotten no responses, so let me rephrase:

I would like to be able to create an action that can capture the diagram
in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
loss as to how to start.

Does anyone out there have any pointers or sample code to help me get
started?

Thanks in advance,
Phil
Re: Creating an Image [message #130490 is a reply to message #130459] Tue, 04 May 2004 15:10 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Create an image of the right size and tell the root figure of your diagram
to paint on that image (using a Graphics that delegates to a GC created for
that image). Or you might be able to just have the control (FigureCanvas?)
paint on the image using a GC.

Keep in mind however that there are size restrictions (platform and hardware
dependent) on how big an image you can create. Do you want to capture just
what's visible or the entire diagram? If you want everything, you might
want to scale it down (using ScaledGraphics).

"Phil Williams" <phil.williams@toadmail.com> wrote in message
news:c787he$4t8$1@eclipse.org...
> I asked this in the past, but have gotten no responses, so let me
rephrase:
>
> I would like to be able to create an action that can capture the diagram
> in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
> loss as to how to start.
>
> Does anyone out there have any pointers or sample code to help me get
> started?
>
> Thanks in advance,
> Phil
Re: Creating an Image [message #130618 is a reply to message #130459] Tue, 04 May 2004 20:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Image image = new Image(null, width, height);
GC gc = new GC(image);
SWTGraphics g = new SWTGraphics(gc);
figure.paint(g);

"Phil Williams" <phil.williams@toadmail.com> wrote in message
news:c787he$4t8$1@eclipse.org...
> I asked this in the past, but have gotten no responses, so let me
rephrase:
>
> I would like to be able to create an action that can capture the diagram
> in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
> loss as to how to start.
>
> Does anyone out there have any pointers or sample code to help me get
> started?
>
> Thanks in advance,
> Phil
Re: Creating an Image [message #130893 is a reply to message #130618] Wed, 05 May 2004 17:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: phil.williams.toadmail.com

This is a multi-part message in MIME format.
--------------010704040008050901050407
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Seems easy enough. The problem that I seem to be having is how to get a
handle to the figure that I want to paint. I want to have an action
that will save off an image. The action extends EditorPartAction and
will be created on my Editor. My editor has a handle to the model class
only. When getGraphicalViewer().setContents(model) is called is when
the part corresponding to the model, and hence the figure is created
(via my part factory). There does not seem to be a way to get the Part
from within the action or the editor.

How is this accomplished?

Thanks again,
Phil

Randy Hudson wrote:

>Image image = new Image(null, width, height);
>GC gc = new GC(image);
>SWTGraphics g = new SWTGraphics(gc);
>figure.paint(g);
>
>"Phil Williams" <phil.williams@toadmail.com> wrote in message
>news:c787he$4t8$1@eclipse.org...
>
>
>>I asked this in the past, but have gotten no responses, so let me
>>
>>
>rephrase:
>
>
>>I would like to be able to create an action that can capture the diagram
>>in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
>>loss as to how to start.
>>
>>Does anyone out there have any pointers or sample code to help me get
>>started?
>>
>>Thanks in advance,
>>Phil
>>
>>
>
>
>
>

--------------010704040008050901050407
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body>
Seems easy enough.&nbsp; The problem that I seem to be having is how to get
a handle to the figure that I want to paint.&nbsp; I want to have an action
that will save off an image.&nbsp; The action extends EditorPartAction and
will be created on my Editor.&nbsp; My editor has a handle to the model
class only.&nbsp;&nbsp; When getGraphicalViewer().setContents(model) is called is
when the part corresponding to the model, and hence the figure is
created (via my part factory).&nbsp; There does not seem to be a way to get
the Part from within the action or the editor.<br>
<br>
How is this accomplished?<br>
<br>
Thanks again,<br>
Phil<br>
<br>
Randy Hudson wrote:<br>
<blockquote cite="midc78stf$2jv$1@eclipse.org" type="cite">
<pre wrap="">Image image = new Image(null, width, height);
GC gc = new GC(image);
SWTGraphics g = new SWTGraphics(gc);
figure.paint(g);

"Phil Williams" <a class="moz-txt-link-rfc2396E" href="mailto:phil.williams@toadmail.com">&lt;phil.williams@toadmail.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:c787he$4t8$1@eclipse.org">news:c787he$4t8$1@eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">I asked this in the past, but have gotten no responses, so let me
</pre>
</blockquote>
<pre wrap=""><!---->rephrase:
</pre>
<blockquote type="cite">
<pre wrap="">I would like to be able to create an action that can capture the diagram
in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
loss as to how to start.

Does anyone out there have any pointers or sample code to help me get
started?

Thanks in advance,
Phil
</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</body>
</html>

--------------010704040008050901050407--
Re: Creating an Image [message #130906 is a reply to message #130893] Wed, 05 May 2004 18:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This is a multi-part message in MIME format.

------=_NextPart_000_006D_01C432A2.9491F260
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Your action will need to know or get the viewer, and call =
viewer.getEditPartRegistry().get(model) which should return the part, =
from which you can get the figure.

"Phil Williams" <phil.williams@toadmail.com> wrote in message =
news:c7b6e4$l6s$1@eclipse.org...
Seems easy enough. The problem that I seem to be having is how to get =
a handle to the figure that I want to paint. I want to have an action =
that will save off an image. The action extends EditorPartAction and =
will be created on my Editor. My editor has a handle to the model class =
only. When getGraphicalViewer().setContents(model) is called is when =
the part corresponding to the model, and hence the figure is created =
(via my part factory). There does not seem to be a way to get the Part =
from within the action or the editor.

How is this accomplished?

Thanks again,
Phil

Randy Hudson wrote:

Image image =3D new Image(null, width, height);
GC gc =3D new GC(image);
SWTGraphics g =3D new SWTGraphics(gc);
figure.paint(g);

"Phil Williams" <phil.williams@toadmail.com> wrote in message
news:c787he$4t8$1@eclipse.org...
I asked this in the past, but have gotten no responses, so let me
rephrase:
I would like to be able to create an action that can capture the =
diagram
in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
loss as to how to start.

Does anyone out there have any pointers or sample code to help me get
started?

Thanks in advance,
Phil
=20


------=_NextPart_000_006D_01C432A2.9491F260
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Your action will need to know or get =
the viewer,=20
and call viewer.getEditPartRegistry().get(model) which should return the =
part,=20
from which you can get the figure.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Phil Williams" &lt;<A=20
=
href=3D"mailto:phil.williams@toadmail.com">phil.williams@toadmail.com</A>=
&gt;=20
wrote in message <A=20
=
href=3D"news:c7b6e4$l6s$1@eclipse.org">news:c7b6e4$l6s$1@eclipse.org</A>.=
...</DIV>Seems=20
easy enough.&nbsp; The problem that I seem to be having is how to get =
a handle=20
to the figure that I want to paint.&nbsp; I want to have an action =
that will=20
save off an image.&nbsp; The action extends EditorPartAction and will =
be=20
created on my Editor.&nbsp; My editor has a handle to the model class=20
only.&nbsp;&nbsp; When getGraphicalViewer().setContents(model) is =
called is=20
when the part corresponding to the model, and hence the figure is =
created (via=20
my part factory).&nbsp; There does not seem to be a way to get the =
Part from=20
within the action or the editor.<BR><BR>How is this=20
accomplished?<BR><BR>Thanks again,<BR>Phil<BR><BR>Randy Hudson =
wrote:<BR>
<BLOCKQUOTE cite=3Dmidc78stf$2jv$1@eclipse.org type=3D"cite"><PRE =
wrap=3D"">Image image =3D new Image(null, width, height);
GC gc =3D new GC(image);
SWTGraphics g =3D new SWTGraphics(gc);
figure.paint(g);

"Phil Williams" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:phil.williams@toadmail.com">&lt;phil.williams@toadmail.com=
&gt;</A> wrote in message
<A class=3Dmoz-txt-link-freetext =
href=3D"news:c787he$4t8$1@eclipse.org">news:c787he$4t8$1@eclipse.org</A>.=
...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">I asked this in the past, =
but have gotten no responses, so let me
</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->rephrase:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">I would like to be able to =
create an action that can capture the diagram
in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
loss as to how to start.

Does anyone out there have any pointers or sample code to help me get
started?

Thanks in advance,
Phil
</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_006D_01C432A2.9491F260--
Re: Creating an Image [message #130945 is a reply to message #130893] Wed, 05 May 2004 18:42 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Just a suggestion: you might want to capture just the printable layers, and
not all the layers. BTW, the overview does the exact same thing as you want
to do here: it gets the root figure and paints it on an image. So, you
might want to look at LogicEditor.OutlinePage.initializeOverview() if you
run into any more problems.


"Phil Williams" <phil.williams@toadmail.com> wrote in message
news:c7b6e4$l6s$1@eclipse.org...
Seems easy enough. The problem that I seem to be having is how to get a
handle to the figure that I want to paint. I want to have an action that
will save off an image. The action extends EditorPartAction and will be
created on my Editor. My editor has a handle to the model class only.
When getGraphicalViewer().setContents(model) is called is when the part
corresponding to the model, and hence the figure is created (via my part
factory). There does not seem to be a way to get the Part from within the
action or the editor.

How is this accomplished?

Thanks again,
Phil

Randy Hudson wrote:

Image image = new Image(null, width, height);
GC gc = new GC(image);
SWTGraphics g = new SWTGraphics(gc);
figure.paint(g);

"Phil Williams" <phil.williams@toadmail.com> wrote in message
news:c787he$4t8$1@eclipse.org...

I asked this in the past, but have gotten no responses, so let me

rephrase:

I would like to be able to create an action that can capture the diagram
in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
loss as to how to start.

Does anyone out there have any pointers or sample code to help me get
started?

Thanks in advance,
Phil
Re: Creating an Image [message #130996 is a reply to message #130945] Wed, 05 May 2004 18:36 Go to previous message
Eclipse UserFriend
Originally posted by: phil.williams.toadmail.com

Thanks for the pointer. I will take a look. Although, I now have the
nodes and connections painting to the image. :)

Thanks for all the help.

Phil


Pratik Shah wrote:

>Just a suggestion: you might want to capture just the printable layers, and
>not all the layers. BTW, the overview does the exact same thing as you want
>to do here: it gets the root figure and paints it on an image. So, you
>might want to look at LogicEditor.OutlinePage.initializeOverview() if you
>run into any more problems.
>
>
>"Phil Williams" <phil.williams@toadmail.com> wrote in message
>news:c7b6e4$l6s$1@eclipse.org...
>Seems easy enough. The problem that I seem to be having is how to get a
>handle to the figure that I want to paint. I want to have an action that
>will save off an image. The action extends EditorPartAction and will be
>created on my Editor. My editor has a handle to the model class only.
>When getGraphicalViewer().setContents(model) is called is when the part
>corresponding to the model, and hence the figure is created (via my part
>factory). There does not seem to be a way to get the Part from within the
>action or the editor.
>
>How is this accomplished?
>
>Thanks again,
>Phil
>
>Randy Hudson wrote:
>
>Image image = new Image(null, width, height);
>GC gc = new GC(image);
>SWTGraphics g = new SWTGraphics(gc);
>figure.paint(g);
>
>"Phil Williams" <phil.williams@toadmail.com> wrote in message
>news:c787he$4t8$1@eclipse.org...
>
>I asked this in the past, but have gotten no responses, so let me
>
>rephrase:
>
>I would like to be able to create an action that can capture the diagram
>in a GEF editor to an image file (JPG, PNG, BMP, whatever). I am at a
>loss as to how to start.
>
>Does anyone out there have any pointers or sample code to help me get
>started?
>
>Thanks in advance,
>Phil
>
>
>
>
>
>
>
>
Previous Topic:Save As and PageBookView
Next Topic:Adding a model
Goto Forum:
  


Current Time: Fri Apr 26 06:20:22 GMT 2024

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

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

Back to the top