public SwingScilabCanvasImpl(GLCapabilities cap) { if (enableGLCanvas) { Debug.DEBUG(this.getClass().getSimpleName(), "Using GLCanvas for OpenGL implementation."); realGLCanvas = new GLCanvas(cap); realGLCanvas.addMouseMotionListener( new MouseMotionListener() { public void mouseDragged(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } public void mouseMoved(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } }); realGLCanvas.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } public void mouseEntered(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } public void mouseExited(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } public void mousePressed(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } public void mouseReleased(MouseEvent arg0) { arg0.setSource(realGLCanvas.getParent()); realGLCanvas.getParent().dispatchEvent(arg0); } }); } else { Debug.DEBUG(this.getClass().getSimpleName(), "Using GLJPanel for OpenGL implementation."); realGLJPanel = new GLJPanel(cap); } }
/** Change Global property forceGLCanvas if no GLJPanel is available, GLCanvas is forced */ public static boolean switchToGLCanvas(boolean onOrOff) { Debug.DEBUG("SwingScilabCanvasImpl", "switchToGLCanvas " + onOrOff); if (!onOrOff && noGLJPanel) { InterpreterManagement.requestScilabExec( Messages.gettext( "disp(\"WARNING: Despite of our previous warning, you choose to use Scilab with advanced graphics capabilities. Type \"\"help usecanvas\"\" for more information.\")")); } enableGLCanvas = onOrOff; return enableGLCanvas; }
static { long lastTime = Calendar.getInstance().getTimeInMillis(); Debug.DEBUG("SwingScilabCanvasImpl", "======================================="); String OS_NAME = System.getProperty("os.name"); Debug.DEBUG("SwingScilabCanvasImpl", "os.name=" + OS_NAME); String OS_ARCH = System.getProperty("os.arch"); Debug.DEBUG("SwingScilabCanvasImpl", "os.arch=" + OS_ARCH); Debug.DEBUG("SwingScilabCanvasImpl", "======================================="); /* * Bug #7526: moved out of the try/catch block since it contains * no OpenGL calls. */ if (OS_NAME.contains("Windows") && OS_ARCH.equals("amd64")) { // bug 3919 : JOGL x64 doesn't like x64 remote desktop on Windows // @TODO : bug report to JOGL String REMOTEDESKTOP = System.getenv("SCILAB_MSTS_SESSION"); if (REMOTEDESKTOP != null) { if (REMOTEDESKTOP.equals("OK")) { noGLJPanel = true; } } if (noGLJPanel) { /** Inform the users */ InterpreterManagement.requestScilabExec( String.format( "disp(\"%s\"), disp(\"%s\")", String.format( Messages.gettext( "WARNING: Due to your configuration limitations, Scilab switched in a mode where mixing uicontrols and graphics is not available. Type %s for more information."), "\"\"help usecanvas\"\""), String.format( Messages.gettext("In some cases, %s fixes the issue"), "\"\"system_setproperty(''jogl.gljpanel.nohw'','''');\"\""))); } } /* * Bug #7526: this code block causes a crash on Windows and Intel Graphic HD cards * with graphics drivers older than 8.15.10.2279 and is therefore not executed if * Windows is the OS (the tests on driver and OpenGL versions are Linux-specific). * Consequently, updateMaxCanvasSize, which determines the canvas size, is not called * any more on Windows. However, it is still called when an actual graphics window is created * (by the renderer module's SciRenderer init method), which still allows getting the maximum * canvas dimensions, so this should not be an issue. */ if (!OS_NAME.contains("Windows")) { try { GLCanvas tmpCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault())); Frame tmpFrame = new Frame(); tmpFrame.add(tmpCanvas); tmpFrame.setVisible(true); tmpCanvas.getContext().makeCurrent(); GL gl = tmpCanvas.getGL(); String GL_VENDOR = gl.glGetString(GL.GL_VENDOR); Debug.DEBUG("SwingScilabCanvasImpl", "GL_VENDOR=" + GL_VENDOR); String GL_RENDERER = gl.glGetString(GL.GL_RENDERER); Debug.DEBUG("SwingScilabCanvasImpl", "GL_RENDERER=" + GL_RENDERER); String GL_VERSION = gl.glGetString(GL.GL_VERSION); Debug.DEBUG("SwingScilabCanvasImpl", "GL_VERSION=" + GL_VERSION); // Debug.DEBUG("SwingScilabCanvasImpl", "GL_EXTENSIONS="+gl.glGetString(GL.GL_EXTENSIONS)); Debug.DEBUG("SwingScilabCanvasImpl", "======================================="); // System.getProperties().list(System.err); // get maximum axes size // RenderingCapabilities.updateMaxCanvasSize(gl); tmpCanvas.getContext().release(); tmpFrame.remove(tmpCanvas); tmpFrame.setVisible(false); tmpFrame.dispose(); Debug.DEBUG( "SwingScilabCanvasImpl", "Testing time = " + (Calendar.getInstance().getTimeInMillis() - lastTime) + "ms"); noGLJPanel = false; // By default disable GLJPanel on Linux if (OS_NAME.contains("Linux")) { noGLJPanel = true; // Linux && NVIDIA if (GL_VENDOR.contains("NVIDIA")) { noGLJPanel = false; } // Linux && ATI if (GL_VENDOR.contains("ATI")) { StringTokenizer stSpace = new StringTokenizer(GL_VERSION, " "); StringTokenizer stDot = new StringTokenizer(stSpace.nextToken(), "."); int majorVersion = Integer.parseInt(stDot.nextToken()); int minorVersion = Integer.parseInt(stDot.nextToken()); int releaseVersion = Integer.parseInt(stDot.nextToken()); // Only OpenGL version newer than 2.1.7873 works // available through ATI 8.8 installer // and driver newer than 8.52.3 Debug.DEBUG( "SwingScilabCanvasImpl", "majorVersion = " + majorVersion + " minorVersion = " + minorVersion + " releaseVersion = " + releaseVersion); if (majorVersion > 2 || majorVersion == 2 && minorVersion > 1 || majorVersion == 2 && minorVersion == 1 && releaseVersion >= 7873) { noGLJPanel = false; } } } if (noGLJPanel) { /** Inform the users */ InterpreterManagement.requestScilabExec( String.format( "disp(\"%s\"), disp(\"%s\")", String.format( Messages.gettext( "WARNING: Due to your configuration limitations, Scilab switched in a mode where mixing uicontrols and graphics is not available. Type %s for more information."), "\"\"help usecanvas\"\""), String.format( Messages.gettext("In some cases, %s fixes the issue"), "\"\"system_setproperty(''jogl.gljpanel.nohw'','''');\"\""))); } } catch (GLException e) { noGLJPanel = true; /** Inform the users */ InterpreterManagement.requestScilabExec( String.format( "disp(\"%s\"), disp(\"%s\")", Messages.gettext( "Due to your video card drivers limitations, that are not able to manage OpenGL, Scilab will not be able to draw any graphics. Please update your driver."), String.format( Messages.gettext("In some cases, %s fixes the issue"), "\"\"system_setproperty(''jogl.gljpanel.nohw'','''');\"\""))); } catch (HeadlessException e) { // do not print anything on a CLI only environment noGLJPanel = true; } } }
public void setEnabled(boolean enable) { Debug.DEBUG(this.getClass().getSimpleName(), "setEnable : " + enable); getAsComponent().setEnabled(enable); }
public void doLayout() { Debug.DEBUG(this.getClass().getSimpleName(), "doLayout"); getAsComponent().doLayout(); }
public void setVisible(boolean arg0) { Debug.DEBUG(this.getClass().getSimpleName(), "setVisible : " + arg0); getAsComponent().setVisible(arg0); }
public boolean postEvent(Event arg0) { Debug.DEBUG(this.getClass().getSimpleName(), "postEvent(Event arg0)"); return getAsComponent().postEvent(arg0); }