<HTML><HEAD><TITLE>AW: [Gvsig_english] Eclipse RCP with gvSIG</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6000.17095" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText46460>
<DIV><FONT face="Times New Roman" color=#000000 size=3>Hello,</FONT></DIV>
<DIV>Very interesting, thanks.</DIV>
<DIV>So you are very close to having a gvSIG layer in Eclipse, aren't you?</DIV>
<DIV>You can instantiate a layer by code and add it: map_control.getMapContext().getLayers().add(...)</DIV>
<DIV>Have you done that?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV><FONT face="Courier New" size=2><FONT face="Times New Roman" size=3>Juan Lucas Domínguez Rubio<BR></FONT>---</FONT></DIV></DIV>
<DIV id=idSignature22519>
<DIV><FONT face="Courier New" size=2><FONT face="Courier New" size=2><FONT face="Courier New" size=2>Prodevelop SL, Valencia (España)</FONT></DIV>
<DIV>
<DIV><FONT face="Courier New" size=2>Tlf.: 96.351.06.12 -- Fax: 96.351.09.68<BR></FONT><A href="http://www.prodevelop.es/"><FONT face="Courier New" size=2>http://www.prodevelop.es</FONT></A><BR><FONT face="Courier New" size=2>---</FONT></DIV></FONT></DIV></FONT></DIV>
<DIV><BR>
<HR>
<FONT face=Tahoma size=2><B>De:</B> gvsig_internacional-bounces@listserv.gva.es en nombre de Neumann, Tobias<BR><B>Enviado el:</B> vie 08/04/2011 14:41<BR><B>Para:</B> Users and Developers mailing list<BR><B>Asunto:</B> RE: [Gvsig_english] Eclipse RCP with gvSIG<BR></FONT><BR></DIV>
<DIV>
<DIV id=idOWAReplyText36497>
<DIV><FONT face=Arial color=#000000 size=2>Dear Juan,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I think we have found a really easy way to use the AWT-components in SWT and Eclipse. The solution is the "albireo"-project. It provides a SwingControl which enables you to use the AWT-components very easy. Here is my implementation which seems to work fine:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>public class View extends ViewPart{</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>private MapControl mapControl = null;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>private SwingControl swingControl = null;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>public void createPartControl(final Composite parent){</FONT></DIV>
<DIV><FONT face=Arial size=2> swingControl = new SwingControl(parent, SWT.NONE){</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> @Override</FONT></DIV>
<DIV><FONT face=Arial size=2> protected JComponent createSwingControl(){</FONT></DIV>
<DIV><FONT face=Arial size=2> View.this.mapControl = new MapControl();</FONT></DIV>
<DIV><FONT face=Arial size=2> return View.this.mapControl;</FONT></DIV>
<DIV><FONT face=Arial size=2> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> @Override</FONT></DIV>
<DIV><FONT face=Arial size=2> public Composite getLayoutAncestor(){</FONT></DIV>
<DIV><FONT face=Arial size=2> return parent;</FONT></DIV>
<DIV><FONT face=Arial size=2> }</FONT></DIV>
<DIV><FONT face=Arial size=2> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> @Override</FONT></DIV>
<DIV><FONT face=Arial size=2> public void dispose(){</FONT></DIV>
<DIV><FONT face=Arial size=2> if(View.this.swingControl != null){</FONT></DIV>
<DIV><FONT face=Arial size=2> swingControl.dispose();</FONT></DIV>
<DIV><FONT face=Arial size=2> {</FONT></DIV>
<DIV><FONT face=Arial size=2> {</FONT></DIV>
<DIV><FONT face=Arial size=2>}</FONT></DIV>
<DIV><FONT face=Arial color=#000000 size=2></FONT> </DIV></DIV>
<DIV>Maybe this could be the solution :-)</DIV>
<DIV> </DIV>
<DIV>Cheers</DIV>
<DIV>Tobias<BR></DIV>
<DIV>
<HR>
</DIV>
<DIV><FONT face=Tahoma size=2><B>From:</B> gvsig_internacional-bounces@listserv.gva.es on behalf of Juan Lucas Dominguez Rubio<BR><B>Sent:</B> Fri 08.04.2011 13:58<BR><B>To:</B> Users and Developers mailing list; Users and Developers mailing list<BR><B>Subject:</B> Re: [Gvsig_english] Eclipse RCP with gvSIG<BR></FONT><BR></DIV>
<DIV>
<DIV id=idOWAReplyText36307>
<DIV><FONT face="Times New Roman" color=#000000 size=3>Hello, Tobias.</FONT></DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3>I have realized that there is a big difference between the JVM I used in the mobile devices and the JVM you are going to use: in my case, the AWT classes simply were not available, but in your case the classes will be available but will not integrate easily in the Eclipse SWT context.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3>So one possible way to integrate gvSIG in the Eclipse RCP application is drawing the map in a AWT image (for example BufferedImage) and then convert the image into a SWT image (I'm sure this is easy and fast) and paste it in you Eclipse SWT canvas. In this way you will probably be able to re-use the gvSIG libraries easily.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3>Just an idea...</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3>Regards,</FONT></DIV>
<DIV><FONT face="Courier New" size=2><FONT face="Times New Roman" size=3>Juan Lucas Domínguez Rubio<BR></FONT>---</FONT></DIV></DIV>
<DIV id=idSignature78117>
<DIV><FONT face="Courier New" size=2><FONT face="Courier New" size=2><FONT face="Courier New" size=2>Prodevelop SL, Valencia (España)</FONT></DIV>
<DIV>
<DIV><FONT face="Courier New" size=2>Tlf.: 96.351.06.12 -- Fax: 96.351.09.68<BR></FONT><A href="http://www.prodevelop.es/"><FONT face="Courier New" size=2>http://www.prodevelop.es</FONT></A><BR><FONT face="Courier New" size=2>---</FONT></DIV></FONT></DIV></FONT></DIV>
<DIV><BR>
<HR>
<FONT face=Tahoma size=2><B>De:</B> gvsig_internacional-bounces@listserv.gva.es en nombre de Neumann, Tobias<BR><B>Enviado el:</B> jue 07/04/2011 12:53<BR><B>Para:</B> Users and Developers mailing list<BR><B>Asunto:</B> AW: [Gvsig_english] Eclipse RCP with gvSIG<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Hola César y Juan! :-)</FONT> </P>
<P><FONT size=2>Thanks a lot for your thoughts and experiences. I believe the combination of gvSIG and RCP will matter a couple of hours of work for me :o)</FONT></P>
<P><FONT size=2>I am just starting up with gvSIG and will investigate what will be necessary to satisfy our needs. Unfortunately we do not have the choice to match our requirements without Eclipse RCP. I will tell you about my improvements.</FONT></P>
<P><FONT size=2>With best regards</FONT> <BR><FONT size=2>Tobias</FONT> </P><BR><BR>
<P><FONT size=2>-----Ursprüngliche Nachricht-----</FONT> <BR><FONT size=2>Von: gvsig_internacional-bounces@listserv.gva.es im Auftrag von Juan Lucas Domínguez Rubio</FONT> <BR><FONT size=2>Gesendet: Do 07.04.2011 12:01</FONT> <BR><FONT size=2>An: Users and Developers mailing list</FONT> <BR><FONT size=2>Betreff: Re: [Gvsig_english] Eclipse RCP with gvSIG</FONT> <BR><FONT size=2> </FONT> <BR><FONT size=2>Hello, Tobias:</FONT> </P>
<P><FONT size=2>I don't have much experience in 'improper' integration between gvSIG and Eclipse SWT (I mean, things like embedding AWT controls in a SWT context or using some kind of library wrapping), but I have done some tests regarding gvSIG libraries in a SWT context.</FONT></P>
<P><FONT size=2>As you perhaps know, the application gvSIG Mobile is using a simplified version of gvSIG 1.X mapping libraries.</FONT> </P>
<P><FONT size=2>I wrote a little 'unofficial' version of gvSIG Mobile for Linux devices (such as the Openmoko phone or the Nokia N810 tablet) with less functionalities than the 'official' gvSIG Mobile but including some other new features.</FONT></P>
<P><FONT size=2>At that time, I found no JVM for those devices that could use the AWT classes (used by gvSIG and gvSIG Mobile). Instead, the Eclipse SWT library was working fine on them, so I changed the gvSIG mapping libraries to make them graphic context independent, and then reimplemented the needed classes to use Eclipse SWT classes. Essentially, I did this:</FONT></P>
<P><FONT size=2>- Take the mapping library of gvSIG 1.X (libFMap) and replace all the occurrences of the classes Graphics2D and Image (this includes all the BufferedImage), with some Java interfaces created by you. So, for ecample in the FLyrVect class, instead of:</FONT></P>
<P><FONT size=2>public void draw(Graphics g, ViewPort vp) throws FMapDriverException { ... }</FONT> </P>
<P><FONT size=2>you will have:</FONT> </P>
<P><FONT size=2>public void draw(IGraphics g, ViewPort vp) throws FMapDriverException { ... }</FONT> <BR><FONT size=2>(IGraphics is a new Java interface)</FONT> </P>
<P><FONT size=2>Before doing this, I removed a lot of drivers from libFMap which were not interesting. I also applied this transformation to the WMS driver and added it to my workspace.</FONT></P>
<P><FONT size=2>- create a new Java project with those Java interfaces (the new libFMap will depend on this project)</FONT> </P>
<P><FONT size=2>- create another Java project containing an implementation of those Java interfaces. Here is where you would use the SWT library to implement all the needed methods (such as drawing a line, creating an image, pasting an image on a graphic context, etc.)</FONT></P>
<P><FONT size=2>- then, at the beginning of the application, you create a SWT-based factory that is able to instantiate all those SWT-based graphic resources and methods, and use it across the application.</FONT></P>
<P><FONT size=2>There are a lot of other important things I had to do from scratch, for example the table of contents (TOC) and of course all the GUI (dialogs). I also split the libFMap project in different parts (libGeom, libRender, etc). This was the resulting workspace:</FONT></P>
<P><FONT size=2><A href="https://svn.prodevelop.es/public/labs/gvsigmobileonopenmoko/trunk/">https://svn.prodevelop.es/public/labs/gvsigmobileonopenmoko/trunk/</A></FONT> </P>
<P><FONT size=2>and these are a couple screenshots of the aplication:</FONT> </P>
<P><FONT size=2><A href="http://gvsigmobileonopenmoko.files.wordpress.com/2009/04/carta_2007.jpg">http://gvsigmobileonopenmoko.files.wordpress.com/2009/04/carta_2007.jpg</A></FONT> <BR><FONT size=2>(WMS layer + 2 little shapefiles)</FONT> </P>
<P><FONT size=2><A href="http://gvsigmobileonopenmoko.files.wordpress.com/2009/07/nokia_31468.jpg">http://gvsigmobileonopenmoko.files.wordpress.com/2009/07/nokia_31468.jpg</A></FONT> <BR><FONT size=2>(ArcIMS layer)</FONT> </P>
<P><FONT size=2>I have never done it myself, but I presume in the Eclipse RCP-based applications you eventually will have to use the SWT graphic classes I used, especially:</FONT></P>
<P><FONT size=2>org.eclipse.swt.graphics.GC</FONT> <BR><FONT size=2>org.eclipse.swt.graphics.Image</FONT> </P>
<P><FONT size=2>So that would be one way to properly integrate gvSIG in the Eclipse RCP platform.</FONT> </P>
<P><FONT size=2>After my little experience, I think that the Eclipse SWT graphic context is less powerful and slower than the AWT Graphics2D class. I did not investigate it deeply but I think AWT has better access to the device's graphic hardware capabilities and therefore drawing is faster and more flexible.</FONT></P><BR>
<P><FONT size=2>Regards,</FONT> </P>
<P><FONT size=2>Juan Lucas Domínguez Rubio</FONT> <BR><FONT size=2><A href="http://gvsigmobileonopenmoko.wordpress.com/">http://gvsigmobileonopenmoko.wordpress.com</A></FONT> <BR><FONT size=2><A href="http://foss4gis.blogspot.com/">http://foss4gis.blogspot.com</A></FONT> </P>
<P><FONT size=2>--- On Wed, 4/6/11, Neumann, Tobias <tobias.neumann@berner-mattner.com> wrote:</FONT> </P>
<P><FONT size=2>From: Neumann, Tobias <tobias.neumann@berner-mattner.com></FONT> <BR><FONT size=2>Subject: [Gvsig_english] Eclipse RCP with gvSIG</FONT> <BR><FONT size=2>To: gvsig_internacional@listserv.gva.es</FONT> <BR><FONT size=2>Date: Wednesday, April 6, 2011, 7:35 AM</FONT> </P><BR><BR><BR>
<P><FONT size=2></FONT><BR><FONT size=2> </FONT> <BR><FONT size=2>Eclipse RCP with gvSIG</FONT> <BR><FONT size=2>Hello,</FONT> </P><BR><BR>
<P><FONT size=2>I am interested in your experiences with the gvSIG software embedded in Eclipse RCP. I want to start up a project using these technologies. Anyone did this before? Are there some points I have to focus on?</FONT></P><BR><BR>
<P><FONT size=2>Thank you very much!</FONT> </P><BR><BR>
<P><FONT size=2>Best regards,</FONT> </P>
<P><FONT size=2>Tobias</FONT> </P><BR><BR><BR><BR><BR><BR>
<P><FONT size=2>Tobias Neumann, M.Sc. in Geogr.</FONT> </P>
<P><FONT size=2>Softwareingenieur</FONT> </P><BR><BR>
<P><FONT size=2>Tel: +49 89 608090-276</FONT> </P>
<P><FONT size=2>Fax: +49 89 6098182</FONT> </P>
<P><FONT size=2>E-Mail: Tobias.Neumann@berner-mattner.com</FONT> </P>
<P><FONT size=2>Web: www.berner-mattner.com</FONT> </P><BR><BR>
<P><FONT size=2>Berner & Mattner Systemtechnik GmbH</FONT> </P>
<P><FONT size=2>Erwin-von-Kreibig-Str. 3</FONT> </P>
<P><FONT size=2>D-80807 München</FONT> </P><BR><BR>
<P><FONT size=2>Geschäftsführer: Hans Berner, Dr. Klaus Eder, Dr. Jan-Oliver Wenzel</FONT> </P>
<P><FONT size=2>Registernummer: HR B 83252 beim Amtsgericht München</FONT> </P>
<P><FONT size=2>Sitz der Gesellschaft: München</FONT> </P><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<P><FONT size=2></FONT></P>
<P><FONT size=2>-----Inline Attachment Follows-----</FONT> </P>
<P><FONT size=2>_______________________________________________</FONT> <BR><FONT size=2>Gvsig_internacional mailing list</FONT> <BR><FONT size=2>Gvsig_internacional@listserv.gva.es</FONT> <BR><FONT size=2><A href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</A></FONT> </P></DIV></DIV></DIV></BODY></HTML>