1

I'm using jzy3d/SWT with mapper and surface and this code to create the chart (container is a composite with gridLayout) :

Settings.getInstance().setHardwareAccelerated(true);
jzy3DChart = SWTChartComponentFactory.chart(container);
((CanvasNewtSWT)jzy3DChart.getCanvas()).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
jzy3DChart.black();
jzy3DChart.getScene().getGraph().add(surface);
ChartLauncher.openChart(jzy3DChart);

I get this rendering at initial creation : enter image description here

But when another part is selected, the newt window always stay on top (chart3 is 2D chart and should be on top) : enter image description here

I've tried to toggle newt window visibility using :

newtCanvasSWT.getNEWTChild().setVisible(false/true);

But doing so the newt window becomes independent and no longer embedded in its SWT container and can disappear under other controls when it should not.

enter image description here

What am I doing wrong ? How to set newt window not to be always on top ?

Edit :

Here is the workaround code I've used :

getSite().getPage().addPartListener(new IPartListener2() {
    @Override
    public void partHidden(IWorkbenchPartReference partRef) {
        // Dispose jsyz3d chart composite when this part is hidden
        if(partRef.getPart(false) == XYZChartEditor.this) {
            if(chart != null) {
                chart.dispose();
                chart = null;
            }
        }
    }
    @Override
    public void partVisible(IWorkbenchPartReference partRef) {
        // Refresh or rebuild chart when this part reappears
        if(partRef.getPart(false) == XYZChartEditor.this) {
            if(chart != null) {
                // Force chart parent composite to layout
                chartContainer.layout();
                return;
            }
            // Rebuild chart
            chart = SWTChartFactory.chart(chartContainer, Quality.Nicest());
            chart.getView().setViewPoint(xyzChartData.getViewPoint());   
            chart.getView().addViewPointChangedListener(XYZChartEditor.this);
            chart.black();
            ChartLauncher.openChart(chart);
            // Force chart parent composite to layout
            chartContainer.layout();
            boolean wasDirty = XYZChartEditor.this.isDirty();
            SelectionChangedEvent event = new SelectionChangedEvent(trialsListViewer, trialsListViewer.getSelection());
            XYZChartEditor.this.selectionChanged(event);
            if(!wasDirty) XYZChartEditor.this.setDirty(false);
            ((CanvasNewtSWT)chart.getCanvas()).addMouseListener(XYZChartEditor.this);       
            canvas = ((CanvasNewtSWT) chart.getCanvas());
            newtCanvasSWT = canvas.getCanvas();
            newtWindow = ((CanvasNewtSWT) chart.getCanvas()).getCanvas().getNEWTChild();
        }
    }
});
frank b.
  • 55
  • 10
  • I don't know whether Jzy3d or JOGL is to blame. Please contact Jzy3d maintainers and contributors on their users group and if the problem comes from JOGL, contact us on our official forum: http://forum.jogamp.org Which versions of Jzy3d and JOGL do you use? – gouessej Oct 18 '21 at 14:11
  • Get this problem with JOGL 2.3.2 and jzy3d 1.0.0 and 2.0.0. Thks for your reply. For now testing Orson Charts. – frank b. Oct 19 '21 at 06:44
  • With JOGL/ jzy3D, I finally dispose parent composite each time the view is hidden and re-build the chart when it is visible. This not the best way (time/perf consuming) but it is the only one I've found to solve the problem... – frank b. Oct 29 '21 at 09:02
  • Please can you post some source code in order to illustrate better your workaround for other people having the same problem? Thank you for the feedback :) – gouessej Oct 31 '21 at 08:57
  • 1
    @gouessej : i’ve added workaround code. – frank b. Nov 21 '21 at 09:41
  • @frankb you should try Jzy3D-2.0.1-SNAPSHOT. It uses JOGL 2.4 which works a bit better. If this still fail, you can avoid using Newt. If you are in SWT you can use the AWT/SWT bridge (see an example here https://github.com/jzy3d/jzy3d-api/blob/master/jzy3d-native-jogl-swt/src/main/java/org/jzy3d/demos/SurfaceDemoSWTAWTBridge.java). Last, you can use CPU rendering in Jzy3D if you still can't make this work (see EmulGL). – Martin Pernollet Mar 14 '22 at 09:16

0 Answers0