Package javax.media.j3d
Class J3DGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
javax.media.j3d.J3DGraphics2D
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 callsflush(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:
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
clearRect
(int x, int y, int width, int height) This method is not supported.final Graphics
create()
This method is not supported.final Graphics
create
(int x, int y, int width, int height) This method is not supported.abstract void
drawAndFlushImage
(BufferedImage img, int x, int y, ImageObserver observer) Draws the specified image and flushes the buffer.abstract void
flush
(boolean wait) Flushes all previously executed rendering operations to the drawing buffer for this 2D graphics object.final Color
This method is not supported.final void
setBackground
(Color color) This method is not supported.Methods inherited from class java.awt.Graphics2D
addRenderingHints, clip, draw, draw3DRect, drawGlyphVector, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawString, drawString, drawString, drawString, fill, fill3DRect, getComposite, getDeviceConfiguration, getFontRenderContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setComposite, setPaint, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate
Methods inherited from class java.awt.Graphics
clipRect, copyArea, dispose, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getColor, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, toString
-
Method Details
-
create
This method is not supported. The only way to obtain a J3DGraphics2D is from the associated Canvas3D.- Specified by:
create
in classGraphics
- Throws:
UnsupportedOperationException
- this method is not supported- See Also:
-
create
This method is not supported. The only way to obtain a J3DGraphics2D is from the associated Canvas3D.- Overrides:
create
in classGraphics
- Throws:
UnsupportedOperationException
- this method is not supported- See Also:
-
setBackground
This method is not supported. Clearing a Canvas3D is done implicitly via a Background node in the scene graph or explicitly via the clear method in a 3D graphics context.- Specified by:
setBackground
in classGraphics2D
- Throws:
UnsupportedOperationException
- this method is not supported- See Also:
-
getBackground
This method is not supported. Clearing a Canvas3D is done implicitly via a Background node in the scene graph or explicitly via the clear method in a 3D graphics context.- Specified by:
getBackground
in classGraphics2D
- Throws:
UnsupportedOperationException
- this method is not supported- See Also:
-
clearRect
public final void clearRect(int x, int y, int width, int height) This method is not supported. Clearing a Canvas3D is done implicitly via a Background node in the scene graph or explicitly via the clear method in a 3D graphics context.- Specified by:
clearRect
in classGraphics
- Throws:
UnsupportedOperationException
- this method is not supported- See Also:
-
flush
public abstract void flush(boolean wait) Flushes all previously executed rendering operations to the drawing buffer for this 2D graphics object.- Parameters:
wait
- flag indicating whether or not to wait for the rendering to be complete before returning from this call.
-
drawAndFlushImage
Draws the specified image and flushes the buffer. This is functionally equivalent to callingdrawImage(...)
followed byflush(false)
, but can avoid the cost of making an extra copy of the image in some cases. Anything previously drawn to this J3DGraphics2D will be flushed before the image is drawn.- Parameters:
img
- The image to drawx
- The x location to draw aty
- The y location to draw atobserver
- The ImageObserver- Since:
- Java 3D 1.3
-