FXCanvas3DImage

com.interactivemesh.j3d.community.gui
Class FXCanvas3DImage

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.interactivemesh.j3d.community.gui.FXCanvas3DImage
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.AncestorListener

public class FXCanvas3DImage
extends javax.swing.JPanel
implements javax.swing.event.AncestorListener

This class provides Java 3D rendering into a BufferedImage object which can be drawn within a JavaFX Scene.

The orientation of the image data is "y-up" !

Since:
Java 3D 1.5
See Also:
FXCanvas3DImageRepainter, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces 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.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
FXCanvas3DImage()
          Constructs and initializes a new FXCanvas3DImage object.
FXCanvas3DImage(javax.media.j3d.GraphicsConfigTemplate3D template)
          Constructs and initializes a new FXCanvas3DImage object, using the specified template.
FXCanvas3DImage(javax.media.j3d.GraphicsConfigTemplate3D template, java.awt.GraphicsDevice device)
          Constructs and initializes a new FXCanvas3DImage object, using the specified template and graphics device.
FXCanvas3DImage(java.awt.GraphicsDevice device)
          Constructs and initializes a new FXCanvas3DImage object, using the specified graphics device.
 
Method Summary
 void ancestorAdded(javax.swing.event.AncestorEvent event)
          
 void ancestorMoved(javax.swing.event.AncestorEvent event)
          
 void ancestorRemoved(javax.swing.event.AncestorEvent event)
          
 void disableWakeupOnAWTEvents(long eventMasks)
          Disables calling event process-methods on the underlying heavyweight canvas for the specified AWT event masks.
 void enableWakeupOnAWTEvents(long eventMasks)
          Sets the AWT event masks for which this FXCanvas3DImage object will call the corresponding process-methods on the underlying heavyweight canvas.
 java.awt.image.BufferedImage getCanvas3DImage()
          Returns the BufferedImage object that contains the 3D rendering.
 javax.media.j3d.Canvas3D getOffscreenCanvas3D()
          Returns the off-screen heavyweight canvas of this lightweight component.
 void imageDrawn()
          Notifies the waiting J3D-Renderer thread.
protected  void processComponentEvent(java.awt.event.ComponentEvent e)
          Redirects event to canvas and to superclass.
protected  void processFocusEvent(java.awt.event.FocusEvent e)
          Redirects event to canvas and to superclass.
protected  void processKeyEvent(java.awt.event.KeyEvent e)
          Redirects event to canvas and to superclass.
protected  void processMouseEvent(java.awt.event.MouseEvent e)
          Redirects event to canvas and to superclass.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent e)
          Redirects event to canvas and to superclass.
protected  void processMouseWheelEvent(java.awt.event.MouseWheelEvent e)
          Redirects event to canvas and to superclass.
 void setBounds(int x, int y, int width, int height)
          
 void setRepainter(FXCanvas3DImageRepainter painter)
          Sets the FXCanvas3DImageRepainter object for this FXCanvas3DImage.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FXCanvas3DImage

public FXCanvas3DImage()
Constructs and initializes a new FXCanvas3DImage object. The screen device is obtained from GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(), which might not be the one you should use if you are in a multiscreen environment. The FXCanvas3DImage is constructed using the following default parameters:

double buffer enable : false
stereo enable : false


FXCanvas3DImage

public FXCanvas3DImage(java.awt.GraphicsDevice device)
Constructs and initializes a new FXCanvas3DImage object, using the specified graphics device.

Parameters:
device - the screen graphics device that will be used to construct a GraphicsConfiguration.

FXCanvas3DImage

public FXCanvas3DImage(javax.media.j3d.GraphicsConfigTemplate3D template)
Constructs and initializes a new FXCanvas3DImage object, using the specified template. The screen device is obtained from GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(), which might not be the one you should use if you are in a multiscreen environment.

Parameters:
template - The template that will be used to construct a GraphicsConfiguration. The stereo and doublebuffer properties are forced to UNNECESSARY.

FXCanvas3DImage

public FXCanvas3DImage(javax.media.j3d.GraphicsConfigTemplate3D template,
                       java.awt.GraphicsDevice device)
Constructs and initializes a new FXCanvas3DImage object, using the specified template and graphics device.

Parameters:
template - The template that will be used to construct a GraphicsConfiguration. The stereo and doublebuffer properties are forced to UNNECESSARY.
device - the screen graphics device that will be used to construct a GraphicsConfiguration in conjunction with the template.
Method Detail

setRepainter

public void setRepainter(FXCanvas3DImageRepainter painter)
Sets the FXCanvas3DImageRepainter object for this FXCanvas3DImage.

Parameters:
painter - JavaFX class instance

getCanvas3DImage

public java.awt.image.BufferedImage getCanvas3DImage()
Returns the BufferedImage object that contains the 3D rendering. The image data will be updated per rendering loop.

Returns:
the image of the 3D rendering
See Also:
#copyOffScreenBuffer()

imageDrawn

public void imageDrawn()
Notifies the waiting J3D-Renderer thread. To be called from the JavaFX painting loop when the repainting of the image is done.

Since:
2.0

ancestorAdded

public void ancestorAdded(javax.swing.event.AncestorEvent event)

Specified by:
ancestorAdded in interface javax.swing.event.AncestorListener
Parameters:
event -

ancestorMoved

public void ancestorMoved(javax.swing.event.AncestorEvent event)

Specified by:
ancestorMoved in interface javax.swing.event.AncestorListener
Parameters:
event -

ancestorRemoved

public void ancestorRemoved(javax.swing.event.AncestorEvent event)

Specified by:
ancestorRemoved in interface javax.swing.event.AncestorListener
Parameters:
event -

getOffscreenCanvas3D

public javax.media.j3d.Canvas3D getOffscreenCanvas3D()
Returns the off-screen heavyweight canvas of this lightweight component.

Returns:
the heavyweight canvas that lies in the deepness of this Component.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)

Overrides:
setBounds in class java.awt.Component
Parameters:
x -
y -
width -
height -

enableWakeupOnAWTEvents

public void enableWakeupOnAWTEvents(long eventMasks)
Sets the AWT event masks for which this FXCanvas3DImage object will call the corresponding process-methods on the underlying heavyweight canvas.

This is required only when Java 3D WakeupOnAWTEvents are specified in subclasses of Behavior.

No event mask is set per default.

Parameters:
eventMasks - ored AWT event masks: AWTEvent.COMPONENT_EVENT_MASK, AWTEvent.FOCUS_EVENT_MASK, AWTEvent.KEY_EVENT_MASK, AWTEvent.MOUSE_EVENT_MASK, AWTEvent.MOUSE_MOTION_EVENT_MASK, AWTEvent.MOUSE_WHEEL_EVENT_MASK.
Since:
1.1

disableWakeupOnAWTEvents

public void disableWakeupOnAWTEvents(long eventMasks)
Disables calling event process-methods on the underlying heavyweight canvas for the specified AWT event masks.

Parameters:
eventMasks - ored AWT event masks: AWTEvent.COMPONENT_EVENT_MASK, AWTEvent.FOCUS_EVENT_MASK, AWTEvent.KEY_EVENT_MASK, AWTEvent.MOUSE_EVENT_MASK, AWTEvent.MOUSE_MOTION_EVENT_MASK, AWTEvent.MOUSE_WHEEL_EVENT_MASK
Since:
1.1

processComponentEvent

protected void processComponentEvent(java.awt.event.ComponentEvent e)
Redirects event to canvas and to superclass.

Overrides:
processComponentEvent in class java.awt.Component
Parameters:
e -

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent e)
Redirects event to canvas and to superclass.

Overrides:
processFocusEvent in class java.awt.Component
Parameters:
e -

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent e)
Redirects event to canvas and to superclass.

Overrides:
processKeyEvent in class javax.swing.JComponent
Parameters:
e -

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Redirects event to canvas and to superclass.

Overrides:
processMouseEvent in class javax.swing.JComponent
Parameters:
e -

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e)
Redirects event to canvas and to superclass.

Overrides:
processMouseMotionEvent in class javax.swing.JComponent
Parameters:
e -

processMouseWheelEvent

protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent e)
Redirects event to canvas and to superclass.

Overrides:
processMouseWheelEvent in class java.awt.Component
Parameters:
e -

FXCanvas3DImage