Class ImageCaptureCanvas3D
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Canvas
-
- org.jogamp.java3d.Canvas3D
-
- jahuwaldt.j3d.ImageCaptureCanvas3D
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
BGFGCanvas3D
public class ImageCaptureCanvas3D extends org.jogamp.java3d.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 University 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.
Modified by: Joseph A.Huwaldt
- Version:
- June 4, 2023
- Author:
- Justin Couch
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ImageCaptureCanvas3D(java.awt.GraphicsConfiguration gc)
Create a new canvas given the graphics configuration that runs as an on screen 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 org.jogamp.java3d.Canvas3D
addNotify, getCenterEyeInImagePlate, getDoubleBufferAvailable, getDoubleBufferEnable, getGraphics2D, getGraphicsContext3D, getImagePlateToVworld, getInverseVworldProjection, getLeftEyeInImagePlate, getLeftManualEyeInImagePlate, getLocationOnScreen, getMonoscopicViewPolicy, getOffScreenBuffer, getOffScreenLocation, getOffScreenLocation, getPhysicalHeight, getPhysicalWidth, getPixelHeight, getPixelLocationFromImagePlate, getPixelLocationInImagePlate, getPixelLocationInImagePlate, getPixelWidth, getRightEyeInImagePlate, getRightManualEyeInImagePlate, getSceneAntialiasingAvailable, getScreen3D, getStereoAvailable, getStereoEnable, getView, getVworldProjection, getVworldToImagePlate, isOffScreen, isRendererRunning, isShadingLanguageSupported, 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, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
-
-
-
-
Constructor Detail
-
ImageCaptureCanvas3D
public ImageCaptureCanvas3D(java.awt.GraphicsConfiguration gc)
Create a new canvas given the graphics configuration that runs as an on screen canvas.- Parameters:
gc
- The graphics configuration for this canvas. May not be null.
-
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
- The graphics configuration to use for the canvas. May not be null.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.- Overrides:
postSwap
in classorg.jogamp.java3d.Canvas3D
-
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.
-
-