j3d.org Code

org.j3d.renderer.java3d.ui
Class ImageCaptureCanvas3D

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended byjavax.media.j3d.Canvas3D
              extended byorg.j3d.renderer.java3d.ui.ImageCaptureCanvas3D
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ImageCaptureCanvas3D
extends javax.media.j3d.Canvas3D

A version of the standard Java3D Canvas3D class that allows you to capture the contents and write out the image information.

The canvas uses a callback mechanism to capture an image and notify the observer of the image data.

The original code for this was written by Peter Z. Kunszt of John Hopkins Uni and posted to the Java 3D interest list. This version has been modified to make it more reusable and flexible. The image can be used to pass to a printer or written to a file for example.

When the observer is notified, this class does not provide any separation of the notification from the rendering thread. A call to the observer will prevent the renderer from starting the next frame. If you are intending to save a lot of images, you should implement some form of buffering system to take the conversion process into a separate thread otherwise on-screen performance will be severely impacted.

Version:
$Revision: 1.1 $ $Date: 2003/09/22 19:58:07 $
Author:
Justin Couch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.media.j3d.Canvas3D
FIELD_ALL, FIELD_LEFT, FIELD_RIGHT
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ImageCaptureCanvas3D(java.awt.GraphicsConfiguration gc)
          Create a new canvas given the graphics configuration that runs as an onscreen canvas.
ImageCaptureCanvas3D(java.awt.GraphicsConfiguration gc, boolean offScreen)
          Create a new canvas that allows capture and may operate either on screen or off-screen.
 
Method Summary
 void addCaptureObserver(CapturedImageObserver obs)
          Add an observer to this canvas to listen for images.
 void postSwap()
          Process code after we have swapped the image to the foreground.
 void removeCaptureObserver(CapturedImageObserver obs)
          Remove a registered observer from this canvas.
 
Methods inherited from class javax.media.j3d.Canvas3D
addNotify, getBounds, getBounds, getCenterEyeInImagePlate, getDoubleBufferAvailable, getDoubleBufferEnable, getGraphics2D, getGraphicsContext3D, getHeight, getImagePlateToVworld, getInverseVworldProjection, getLeftEyeInImagePlate, getLeftManualEyeInImagePlate, getLocation, getLocation, getLocationOnScreen, getMonoscopicViewPolicy, getOffScreenBuffer, getOffScreenLocation, getOffScreenLocation, getPhysicalHeight, getPhysicalWidth, getPixelLocationFromImagePlate, getPixelLocationInImagePlate, getPixelLocationInImagePlate, getRightEyeInImagePlate, getRightManualEyeInImagePlate, getSceneAntialiasingAvailable, getScreen3D, getSize, getSize, getStereoAvailable, getStereoEnable, getView, getVworldProjection, getVworldToImagePlate, getWidth, getX, getY, isOffScreen, isRendererRunning, paint, postRender, preRender, queryProperties, removeNotify, renderField, renderOffScreenBuffer, setDoubleBufferEnable, setLeftManualEyeInImagePlate, setMonoscopicViewPolicy, setOffScreenBuffer, setOffScreenLocation, setOffScreenLocation, setRightManualEyeInImagePlate, setStereoEnable, startRenderer, stopRenderer, swap, waitForOffScreenRendering
 
Methods inherited from class java.awt.Canvas
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImageCaptureCanvas3D

public ImageCaptureCanvas3D(java.awt.GraphicsConfiguration gc)
Create a new canvas given the graphics configuration that runs as an onscreen canvas.

Parameters:
gc - The graphics configuration for this canvas

ImageCaptureCanvas3D

public ImageCaptureCanvas3D(java.awt.GraphicsConfiguration gc,
                            boolean offScreen)
Create a new canvas that allows capture and may operate either on screen or off-screen.

Parameters:
gc - Thr graphics configuration to use for the canvas
offScreen - True if this is to operate in an offscreen mode
Method Detail

postSwap

public void postSwap()
Process code after we have swapped the image to the foreground. Overrides the standard implementation to fetch the image to call to the observers if needed.


addCaptureObserver

public void addCaptureObserver(CapturedImageObserver obs)
Add an observer to this canvas to listen for images. Each instance can only be registered once.

Parameters:
obs - The observer to be registered

removeCaptureObserver

public void removeCaptureObserver(CapturedImageObserver obs)
Remove a registered observer from this canvas. If the reference is null or cannot be found registered here it will silently ignore the request.

Parameters:
obs - The observer to be removed

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org