Class J3DGraphics2D


public abstract class J3DGraphics2D extends Graphics2D
The J3DGraphics2D class extends Graphics2D to provide 2D rendering into a Canvas3D. It is an abstract base class that is further extended by a non-public Java 3D implementation class. This class allows Java 2D rendering to be mixed with Java 3D rendering in the same Canvas3D, subject to the same restrictions as imposed for 3D immediate-mode rendering: In mixed-mode rendering, all Java 2D requests must be done from one of the Canvas3D callback methods; in pure-immediate mode, the Java 3D renderer must be stopped for the Canvas3D being rendered into.

An application obtains a J3D 2D graphics context object from the Canvas3D object that the application wishes to render into by using the getGraphics2D method. A new J3DGraphics2D object is created if one does not already exist.

Note that the drawing methods in this class, including those inherited from Graphics2D, are not necessarily executed immediately. They may be buffered up for future execution. Applications must call the flush(boolean) method to ensure that the rendering actually happens. The flush method is implicitly called in the following cases:

  • The Canvas3D.swap method calls flush(true)
  • The Java 3D renderer calls flush(true) prior to swapping the buffer for a double buffered on-screen Canvas3D
  • The Java 3D renderer calls flush(true) prior to copying into the off-screen buffer of an off-screen Canvas3D
  • The Java 3D renderer calls flush(false) after calling the preRender, renderField, postRender, and postSwap Canvas3D callback methods.

A single-buffered, pure-immediate mode application must explicitly call flush to ensure that the graphics will be rendered to the Canvas3D.

Since:
Java 3D 1.2
See Also: