GLCanvas and getGraphics() override

Hello,

I am working on an application that would use custom Graphics2D class to draw on JOGL’s GLCanvas. To make this work, I need to make sure that every time something is getting drawn on the GLCanvas, it’s going to be using CustomGraphics2D class and not SunGraphics2D. Unfortunately the fact that jogl.GLCanvas is final doesn’t allow for overriding getGraphics() method and when something like RepaintArea.java doing:
Graphics g = comp.getGraphics()
where comp is jogl.GLCanvas, it returns SunGraphics2D object. And then I end up using this wrong graphics object to draw on GLCanvas which naturally doesn’t work.

Any ideas on how to work around this problem would be greatly appreciated.

-Oleg Pariser@JPL Multimission Image Processing Lab

The best way for you to make this work at this point is to check out the CVS sources and modify them as you need to. Within a few months there will be some substantial API changes in the JOGL source tree to implement the JSR-231 (Java bindings for OpenGL JSR). Included among these will be a non-final GLCanvas. However I would not recommend you wait for this, but just modify GLCanvas as necessary.