Example of chart in RCP view part

360 views
Skip to first unread message

Mike Cassells

unread,
Jul 15, 2013, 12:01:19 AM7/15/13
to jz...@googlegroups.com
Hi,
Great charting API, it does a lot of what I need.  I am having general newbie struggles with getting a chart to render in a Eclipse RCP view part of a plugin/bundle which is within a part stack.

Can anyone suggest a link to some basic complete example code that, given a Chart constructed with "awt" windowing toolkit, will do the necessary to show the chart  and give me mouse control over it. 

I'm trying to get it working within  the context of the Vogella RCP tutorial, which creates view part code such as:

public class TodoDetailsPart {
    @PostConstruct
    public void createControls(Composite parent) {

        Chart chart = new SurfaceChart().getChart();
        // do stuff to show it and control it on the 'parent' Composite
    }
}

Constructing the chart and getting it to display in the JZY3D demos' ecosystem works fine, but all the snippets I've found, when mashed together give me various problems, most notably "Invalid thread access".  I think I'm close but as a last resort I hoping for a working example I could be pointed to and build upon.

Just as an aside, I've packaged the JZY3D dependencies into a plugin project of it's own which is a dependency to my plugin.  I found that for it to resolve the native DLLs for JOGL I needed to create a "plugin from external JARS",and explicitly specified "unzip the JAR files into the project".  If I left the JARs zipped JOGL wouldn't delve into the JARs to find the DLLs, giving exception "java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path" even with the argument "jogamp.gluegen.UseTempJarCache=true"

Cheers, Mike.

Martin Pernollet

unread,
Jul 16, 2013, 5:10:08 AM7/16/13
to Jzy3d



2013/7/15 Mike Cassells <bigchief.sc...@gmail.com>

Hi,
Great charting API, it does a lot of what I need.  I am having general newbie struggles with getting a chart to render in a Eclipse RCP view part of a plugin/bundle which is within a part stack.

Can anyone suggest a link to some basic complete example code that, given a Chart constructed with "awt" windowing toolkit, will do the necessary to show the chart  and give me mouse control over it. 

I'm trying to get it working within  the context of the Vogella RCP tutorial, which creates view part code such as:

public class TodoDetailsPart {
    @PostConstruct
    public void createControls(Composite parent) {

        Chart chart = new SurfaceChart().getChart();
        // do stuff to show it and control it on the 'parent' Composite
    }
}

Constructing the chart and getting it to display in the JZY3D demos' ecosystem works fine, but all the snippets I've found, when mashed together give me various problems, most notably "Invalid thread access".  I think I'm close but as a last resort I hoping for a working example I could be pointed to and build upon.

Ouch, did not know this problem.
Can you send me a sample code so that I can have a look?
 
Just as an aside, I've packaged the JZY3D dependencies into a plugin project of it's own which is a dependency to my plugin.  I found that for it to resolve the native DLLs for JOGL I needed to create a "plugin from external JARS",and explicitly specified "unzip the JAR files into the project".  If I left the JARs zipped JOGL wouldn't delve into the JARs to find the DLLs, giving exception "java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path" even with the argument "jogamp.gluegen.UseTempJarCache=true"

What version of jzy3d are you using?
With 0.9, you should use jogl2, and should not unzip de native from the jar containing them.

 
Cheers, Mike.

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Jzy3d.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jzy3d+un...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 

Mike Cassells

unread,
Jul 23, 2013, 11:36:27 PM7/23/13
to jz...@googlegroups.com
Sorry for the delayed response, a week-long internet outage proves Telstra is trying to drag Australia back into the 3rd world. :-)


Ouch, did not know this problem.
Can you send me a sample code so that I can have a look?

I managed to get it working quite reliably with the following simple code in my 'part' class ... HeightMapChart is returning an "awt" Chart, full mouse control is provided, everything I need:


    @PostConstruct
    public void createControls(Composite parent) {
        Chart chart = new HeightMapChart().getChart();
        Bridge.adapt(parent, (java.awt.Component) chart.getCanvas());
        chart.addController(new CameraMouseController());
    }

Am I likely to be missing something that may cause grief further down the road?

What version of jzy3d are you using?
With 0.9, you should use jogl2, and should not unzip de native from the jar containing them.

This is still somewhat of an issue, though my solution given above kind of suffices.  I'm using the JOGL libraries provided in "Jzy3d 0.9 Dependencies.zip" which would imply JOGL2 rc10.  This comes from the JZY3D download page that also provide the org.jzy3d-0.9-src.jar I am using.  I expect the failure to able to dive into unzipped JARs of a dependant bundle to find the DLLs has something to do with OSGi (Equinox) specialised classloaders getting in the way, perhaps.  I'm still very new to Eclipse RCP and OSGi.

Perhaps the following may be useful to someone with a similar use case to me, ie. JZY3D in Eclipse RCP E4:  I do NOT import the swt.jat, swt-debug.jar provided by JZY3D.  Instead I use the org.eclipse.swt bundle provided by Eclipse RCP E4.  Also, I declare this bundle as a dependency to my own bundle that encapsulates the JZY3D libraries (the unzipped one as discussed above) so as to support the JZY3D libraries and declare it to be exported so that it can support SWT in the application's graphical display parts.  This avoided classloaders throwing a wobbly when finding SWT types twice.




Martin Pernollet

unread,
Jul 24, 2013, 11:54:50 AM7/24/13
to Jzy3d
Hi Mike,

Thanks for sharing your solution!

Just to complement what you say about swt.jar & swt-debug.jar : as explained on the troubleshooting page [1] having SWT jars in classpath yields to frozen charts when run from eclipse under macos 10.8. 
For this reason, SWT is now an external dependency in a maven module named jzy3d-swt. Having a dependency on jzy3d-master will let you have swt, whereas a dependency on jzy3d-api will let you work without duplicated SWT jars.

Cheers,
Martin
Reply all
Reply to author
Forward
0 new messages