com.jmex.awt.swingui
Class JMEDesktop

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.TriMesh
              extended by com.jme.scene.shape.Quad
                  extended by com.jmex.awt.swingui.JMEDesktop
All Implemented Interfaces:
Savable, java.io.Serializable

public class JMEDesktop
extends Quad

A quad that displays a JDesktopPane as texture. It also converts jME mouse and keyboard events to Swing events. The latter does work for ortho mode only. There are some issues with using multiple of this desktops.

Notes

See Also:
ImageGraphics, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.TriMesh
TriMesh.Mode
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
 
Fields inherited from class com.jme.scene.TriMesh
indexBuffer, mode, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
JMEDesktop(java.lang.String name)
          Create a quad with a Swing-Texture.
JMEDesktop(java.lang.String name, int width, int height, boolean mipMapping, InputHandler inputHandlerParent)
          Create a quad with a Swing-Texture.
JMEDesktop(java.lang.String name, int width, int height, InputHandler inputHandlerParent)
          Create a quad with a Swing-Texture.
 
Method Summary
 java.awt.Component componentAt(int x, int y)
          Find a component at specified desktop position.
 void convert(int x, int y, Vector2f store)
          Convert mouse coordinates from jME screen to JMEDesktop coordinates (Swing).
 void dispose()
          Call this method of the desktop is no longer needed.
 void draw(Renderer r)
          draw calls super to set the render state then passes itself to the renderer.
 com.jmex.awt.swingui.JMEDesktop.ButtonAction getButtonUpdateAction(int swingButtonIndex)
           
 JMEDragAndDrop getDragAndDropSupport()
           
 java.awt.Component getFocusOwner()
           
 InputHandler getInputHandler()
          Allows to disable input for the whole desktop and to add custom input actions.
 javax.swing.JDesktopPane getJDesktop()
           
 InputAction getKeyUpdateAction()
           
 java.awt.Component getModalComponent()
           
 com.jmex.awt.swingui.JMEDesktop.WheelUpdateAction getWheelUpdateAction()
           
 com.jmex.awt.swingui.JMEDesktop.XUpdateAction getXUpdateAction()
           
 com.jmex.awt.swingui.JMEDesktop.YUpdateAction getYUpdateAction()
           
 boolean isShowingJFrame()
           
 boolean isSynchronizingThreadsOnUpdate()
           
 void onButton(int swingButton, boolean pressed, int x, int y)
           
 void onKey(char character, int keyCode, boolean pressed)
           
 void onMove(int xDelta, int yDelta, int newX, int newY)
           
 void onWheel(int wheelDelta, int x, int y)
           
 void resize(float width, float height)
          Deprecated. 
 void setDragAndDropSupport(JMEDragAndDrop dragAndDropSupport)
           
 void setFocusOwner(java.awt.Component comp)
           
 void setModalComponent(java.awt.Component value)
          Filter the swing event to allow events to the specified component and its children only.
protected  void setParent(Node parent)
          Called by Node.attachChild(Spatial) and Node.detachChild(Spatial) - don't call directly.
 void setShowingJFrame(boolean showingJFrame)
          Deprecated. for debuggin only
 void setSynchronizingThreadsOnUpdate(boolean synchronizingThreadsOnUpdate)
          Choose if update and swing thread should be synchronized (avoids flickering, eats some performance)
 void setup(int width, int height, boolean mipMapping, InputHandler inputHandlerParent)
          Set up the desktop quad - may be called only once.
protected  void setupDefaultInputBindings()
           
 
Methods inherited from class com.jme.scene.shape.Quad
getCenter, getHeight, getWidth, initialize, updateGeometry
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, findCollisions, findTriangleCollision, findTrianglePick, getIndexBuffer, getMaxIndex, getMeshAsTriangles, getMeshAsTrianglesVertices, getMode, getTriangle, getTriangle, getTriangleCount, getTriangleIndices, getVertIndex, hasCollision, hasTriangleCollision, randomPointOnTriangles, read, recalcTriangleQuantity, reconstruct, setIndexBuffer, setMode, setTriangleQuantity, write
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, applyRenderState, checkTextureCoordinates, clearTextureBuffers, copyTextureCoordinates, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Constructor Detail

JMEDesktop

public JMEDesktop(java.lang.String name)
Create a quad with a Swing-Texture. Creates the quad and the JFrame but do not setup the rest. Call setup(int, int, boolean, InputHandler) to finish setup.

Parameters:
name - name of this desktop

JMEDesktop

public JMEDesktop(java.lang.String name,
                  int width,
                  int height,
                  InputHandler inputHandlerParent)
Create a quad with a Swing-Texture. Note that for the texture a width and height that is a power of 2 is used if the graphics card does not support the specified size for textures. E.g. this results in a 1024x512 texture for a 640x480 desktop (consider using a 512x480 desktop in that case).

Parameters:
name - name of the spatial
width - desktop width
height - desktop height
inputHandlerParent - InputHandler where the InputHandler of this desktop should be added as subhandler, may be null to provide custom input handling or later adding of InputHandler(s)
See Also:
getInputHandler()

JMEDesktop

public JMEDesktop(java.lang.String name,
                  int width,
                  int height,
                  boolean mipMapping,
                  InputHandler inputHandlerParent)
Create a quad with a Swing-Texture. Note that for the texture a width and height that is a power of 2 is used if the graphics card does not support the specified size for textures or mipMapping is true. E.g. this results in a 1024x512 texture for a 640x480 desktop (consider using a 512x480 desktop in that case).

Parameters:
name - name of the spatial
width - desktop width
height - desktop hieght
mipMapping - true to compute mipmaps for the desktop (not recommended), false for creating a single image texture
inputHandlerParent - InputHandler where the InputHandler of this desktop should be added as subhandler, may be null to provide custom input handling or later adding of InputHandler(s)
See Also:
getInputHandler()
Method Detail

getDragAndDropSupport

public JMEDragAndDrop getDragAndDropSupport()
Returns:
JMEDragAndDrop used for this desktop

setDragAndDropSupport

public void setDragAndDropSupport(JMEDragAndDrop dragAndDropSupport)
Parameters:
dragAndDropSupport - JMEDragAndDrop to be used for this desktop
See Also:
JMEDragAndDrop.setDesktop(JMEDesktop)

isShowingJFrame

public boolean isShowingJFrame()
Returns:
true if frame is displayed
See Also:
setShowingJFrame(boolean)

setShowingJFrame

public void setShowingJFrame(boolean showingJFrame)
Deprecated. for debuggin only

Parameters:
showingJFrame - true to display the desktop in a JFrame instead on this quad.

getInputHandler

public InputHandler getInputHandler()
Allows to disable input for the whole desktop and to add custom input actions.

Returns:
this desktops input hander for input bindings
See Also:
getXUpdateAction(), getYUpdateAction(), getWheelUpdateAction(), getButtonUpdateAction(int), getKeyUpdateAction()

setup

public void setup(int width,
                  int height,
                  boolean mipMapping,
                  InputHandler inputHandlerParent)
Set up the desktop quad - may be called only once. Note that for the texture a width and height that is a power of 2 is used if the graphics card does not support the specified size for textures or mipMapping is true. E.g. this results in a 1024x512 texture for a 640x480 desktop (consider using a 512x480 desktop in that case).

Parameters:
width - desktop width
height - desktop hieght
mipMapping - true to compute mipmaps for the desktop (not recommended), false for creating a single image texture
inputHandlerParent - InputHandler where the InputHandler of this desktop should be added as subhandler, may be null to provide custom input handling or later adding of InputHandler(s)
See Also:
getInputHandler()

setupDefaultInputBindings

protected void setupDefaultInputBindings()

onKey

public void onKey(char character,
                  int keyCode,
                  boolean pressed)

onButton

public void onButton(int swingButton,
                     boolean pressed,
                     int x,
                     int y)

onWheel

public void onWheel(int wheelDelta,
                    int x,
                    int y)

onMove

public void onMove(int xDelta,
                   int yDelta,
                   int newX,
                   int newY)

isSynchronizingThreadsOnUpdate

public boolean isSynchronizingThreadsOnUpdate()
Returns:
true if update and swing thread should be synchronized (avoids flickering, eats some performance)

setSynchronizingThreadsOnUpdate

public void setSynchronizingThreadsOnUpdate(boolean synchronizingThreadsOnUpdate)
Choose if update and swing thread should be synchronized (avoids flickering, eats some performance)

Parameters:
synchronizingThreadsOnUpdate - true to synchronize

getXUpdateAction

public com.jmex.awt.swingui.JMEDesktop.XUpdateAction getXUpdateAction()
Returns:
an action that should be invoked to generate an awt event when the mouse x-coordinate is changed

getYUpdateAction

public com.jmex.awt.swingui.JMEDesktop.YUpdateAction getYUpdateAction()
Returns:
an action that should be invoked to generate an awt event when the mouse y-coordinate is changed

getWheelUpdateAction

public com.jmex.awt.swingui.JMEDesktop.WheelUpdateAction getWheelUpdateAction()
Returns:
an action that should be invoked to generate an awt event when the mouse wheel position is changed

getButtonUpdateAction

public com.jmex.awt.swingui.JMEDesktop.ButtonAction getButtonUpdateAction(int swingButtonIndex)
Parameters:
swingButtonIndex - button index sent in generated swing event, InputHandler.BUTTON_ALL for using trigger index + 1
Returns:
an action that should be invoked to generate an awt event for a pressed/released mouse button

getKeyUpdateAction

public InputAction getKeyUpdateAction()
Returns:
an action that should be invoked to generate an awt event for a pressed/released key

setFocusOwner

public void setFocusOwner(java.awt.Component comp)

convert

public void convert(int x,
                    int y,
                    Vector2f store)
Convert mouse coordinates from jME screen to JMEDesktop coordinates (Swing).

Parameters:
x - jME x coordinate
y - jME y coordinate
store - resulting JDesktop coordinates

componentAt

public java.awt.Component componentAt(int x,
                                      int y)
Find a component at specified desktop position.

Parameters:
x - x coordinate in Swing coordinate space
y - y coordinate in Swing coordinate space
Returns:
the top most component at specified location, null if no child component is found at that location

draw

public void draw(Renderer r)
Description copied from class: TriMesh
draw calls super to set the render state then passes itself to the renderer. LOGIC: 1. If we're not RenderQueue calling draw goto 2, if we are, goto 3 2. If we are supposed to use queue, add to queue and RETURN, else 3 3. call super draw 4. tell renderer to draw me.

Overrides:
draw in class TriMesh
Parameters:
r - the renderer to display
See Also:
Spatial.draw(com.jme.renderer.Renderer)

getJDesktop

public javax.swing.JDesktopPane getJDesktop()

getFocusOwner

public java.awt.Component getFocusOwner()

getModalComponent

public java.awt.Component getModalComponent()
Returns:
current modal component
See Also:
setModalComponent(java.awt.Component)

setModalComponent

public void setModalComponent(java.awt.Component value)
Filter the swing event to allow events to the specified component and its children only. Note: this does not prevent shortcuts and mnemonics to work for the other components!

Parameters:
value - component that can be exclusively accessed (including children)

setParent

protected void setParent(Node parent)
Description copied from class: Spatial
Called by Node.attachChild(Spatial) and Node.detachChild(Spatial) - don't call directly. setParent sets the parent of this node.

Overrides:
setParent in class Spatial
Parameters:
parent - the parent of this node.

dispose

public void dispose()
Call this method of the desktop is no longer needed. Removes this from the scenegraph, later use is not possible any more.


resize

@Deprecated
public void resize(float width,
                              float height)
Deprecated. 

Resizing jMEDesktop is not supported.

Overrides:
resize in class Quad
Parameters:
width - -
height - -