[Gvsig_english] Eclipse RCP with gvSIG
Neumann, Tobias
tobias.neumann at berner-mattner.com
Fri Apr 8 14:41:47 CEST 2011
Dear Juan,
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:
public class View extends ViewPart{
private MapControl mapControl = null;
private SwingControl swingControl = null;
public void createPartControl(final Composite parent){
swingControl = new SwingControl(parent, SWT.NONE){
@Override
protected JComponent createSwingControl(){
View.this.mapControl = new MapControl();
return View.this.mapControl;
}
@Override
public Composite getLayoutAncestor(){
return parent;
}
}
@Override
public void dispose(){
if(View.this.swingControl != null){
swingControl.dispose();
{
{
}
Maybe this could be the solution :-)
Cheers
Tobias
________________________________
From: gvsig_internacional-bounces at listserv.gva.es on behalf of Juan Lucas Dominguez Rubio
Sent: Fri 08.04.2011 13:58
To: Users and Developers mailing list; Users and Developers mailing list
Subject: Re: [Gvsig_english] Eclipse RCP with gvSIG
Hello, Tobias.
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.
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.
Just an idea...
Regards,
Juan Lucas Domínguez Rubio
---
Prodevelop SL, Valencia (España)
Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
http://www.prodevelop.es <http://www.prodevelop.es/>
---
________________________________
De: gvsig_internacional-bounces at listserv.gva.es en nombre de Neumann, Tobias
Enviado el: jue 07/04/2011 12:53
Para: Users and Developers mailing list
Asunto: AW: [Gvsig_english] Eclipse RCP with gvSIG
Hola César y Juan! :-)
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)
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.
With best regards
Tobias
-----Ursprüngliche Nachricht-----
Von: gvsig_internacional-bounces at listserv.gva.es im Auftrag von Juan Lucas Domínguez Rubio
Gesendet: Do 07.04.2011 12:01
An: Users and Developers mailing list
Betreff: Re: [Gvsig_english] Eclipse RCP with gvSIG
Hello, Tobias:
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.
As you perhaps know, the application gvSIG Mobile is using a simplified version of gvSIG 1.X mapping libraries.
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.
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:
- 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:
public void draw(Graphics g, ViewPort vp) throws FMapDriverException { ... }
you will have:
public void draw(IGraphics g, ViewPort vp) throws FMapDriverException { ... }
(IGraphics is a new Java interface)
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.
- create a new Java project with those Java interfaces (the new libFMap will depend on this project)
- 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.)
- 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.
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:
https://svn.prodevelop.es/public/labs/gvsigmobileonopenmoko/trunk/
and these are a couple screenshots of the aplication:
http://gvsigmobileonopenmoko.files.wordpress.com/2009/04/carta_2007.jpg
(WMS layer + 2 little shapefiles)
http://gvsigmobileonopenmoko.files.wordpress.com/2009/07/nokia_31468.jpg
(ArcIMS layer)
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:
org.eclipse.swt.graphics.GC
org.eclipse.swt.graphics.Image
So that would be one way to properly integrate gvSIG in the Eclipse RCP platform.
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.
Regards,
Juan Lucas Domínguez Rubio
http://gvsigmobileonopenmoko.wordpress.com <http://gvsigmobileonopenmoko.wordpress.com/>
http://foss4gis.blogspot.com <http://foss4gis.blogspot.com/>
--- On Wed, 4/6/11, Neumann, Tobias <tobias.neumann at berner-mattner.com> wrote:
From: Neumann, Tobias <tobias.neumann at berner-mattner.com>
Subject: [Gvsig_english] Eclipse RCP with gvSIG
To: gvsig_internacional at listserv.gva.es
Date: Wednesday, April 6, 2011, 7:35 AM
Eclipse RCP with gvSIG
Hello,
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?
Thank you very much!
Best regards,
Tobias
Tobias Neumann, M.Sc. in Geogr.
Softwareingenieur
Tel: +49 89 608090-276
Fax: +49 89 6098182
E-Mail: Tobias.Neumann at berner-mattner.com
Web: www.berner-mattner.com
Berner & Mattner Systemtechnik GmbH
Erwin-von-Kreibig-Str. 3
D-80807 München
Geschäftsführer: Hans Berner, Dr. Klaus Eder, Dr. Jan-Oliver Wenzel
Registernummer: HR B 83252 beim Amtsgericht München
Sitz der Gesellschaft: München
-----Inline Attachment Follows-----
_______________________________________________
Gvsig_internacional mailing list
Gvsig_internacional at listserv.gva.es
http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 13823 bytes
Desc: not available
Url : http://listserv.gva.es/pipermail/gvsig_internacional/attachments/20110408/6c0466b7/attachment.bin
More information about the Gvsig_internacional
mailing list