syn3d.ui.java3d
Class Frame3DJava3D

java.lang.Object
  extended by syn3d.ui.Transformator
      extended by syn3d.ui.Frame3DBase
          extended by syn3d.ui.java3d.Frame3DJava3D
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

public class Frame3DJava3D
extends Frame3DBase

Class description ...

Author:
Claude CAZENAVE

Field Summary
protected  int accumulator
           
protected  Canvas3D canvas
           
protected  javax.swing.JFrame frame
           
protected  int lastMouseX
           
protected  int lastMouseY
           
protected  java.util.ArrayList lastPickSelection
           
protected  SceneNodeJava3D scene
           
protected  Transform3D tempTransform
           
protected  Transform3D transform
           
protected  View view
           
protected  Viewer viewer
           
protected  ViewingPlatform viewingPlatform
           
protected  java.util.Timer zoomAccumulator
           
 
Fields inherited from class syn3d.ui.Frame3DBase
height, peerComponent, peerWindow, pluginManager, popup, screenSize, title, width, x, y
 
Fields inherited from class syn3d.ui.Transformator
drotX, drotY, eyeDistance, perspective, pos2DX, pos2DY, rot, scaleFactor, trans, transFactorX, transFactorY, vtrans, wsize, zoom, zoomFactor
 
Constructor Summary
Frame3DJava3D(SceneNodeJava3D scene, java.lang.String t, int x, int y, int width, int height, PluginManager pm)
           
 
Method Summary
 void applyTransform()
          Hook for subclasses, to apply the current transformation to a relevant object This method is called internally when a change occurs.
protected  void createPeer(java.lang.Object owner)
           
 SceneNode getScene()
           
protected  float getSceneSize()
          Used for auto-zooming to englobe the scene
 View getView()
           
 Viewer getViewer()
           
static void main(java.lang.String[] args)
          Main function to test navigation
 ActiveNode pick(int posX, int posY)
          Selects a single pick at the given position.
 void rotate2D(int newX, int newY, boolean inverse)
          Does a rotation of the scene according to moves in a 2D coordinate system.
 void setPerspective(boolean p)
           
 java.util.ArrayList toggleAllPicks(int posX, int posY)
          Adds or removes all picks between the given position and the last position, to the selected objects.
 java.util.ArrayList toggleSinglePick(int posX, int posY)
          Adds or removes a single pick at the given position to the selected objects.
 void translate2D(int newX, int newY)
          Does a translation of the scene according to moves in a 2D coordinate system.
 void zoom(int zoomIncrement)
          Zooms in or out of the scene according to the increment.
 void zoom2D(int newX, int newY)
          Uses the 2D increments in position to compute a zoom factor, then zooms the scene accordingly.
 
Methods inherited from class syn3d.ui.Frame3DBase
autoZoom, getPeerWindow, getPopup, getTitle, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, setPopup, setTitle
 
Methods inherited from class syn3d.ui.Transformator
changeProjection, getEyeDistance, getPos2DX, getPos2DY, getRot, getScaleFactor, getTrans, getTransFactorX, getTranslationFactorY, getWSize, getZoom, getZoomFactor, init2DPosition, isPerspective, reset, rotate2D, setEyeDistance, setPos2DX, setPos2DY, setRot, setScaleFactor, setTrans, setTransFactorX, setTranslationFactorY, setWSize, setZoom, setZoomFactor, updateTranslateMatrix, updateZoomMatrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

protected javax.swing.JFrame frame

view

protected View view

viewer

protected Viewer viewer

viewingPlatform

protected ViewingPlatform viewingPlatform

canvas

protected Canvas3D canvas

scene

protected SceneNodeJava3D scene

lastPickSelection

protected java.util.ArrayList lastPickSelection

lastMouseX

protected int lastMouseX

lastMouseY

protected int lastMouseY

transform

protected Transform3D transform

tempTransform

protected Transform3D tempTransform

zoomAccumulator

protected java.util.Timer zoomAccumulator

accumulator

protected int accumulator
Constructor Detail

Frame3DJava3D

public Frame3DJava3D(SceneNodeJava3D scene,
                     java.lang.String t,
                     int x,
                     int y,
                     int width,
                     int height,
                     PluginManager pm)
Parameters:
owner -
x -
y -
width -
height -
Method Detail

getScene

public SceneNode getScene()
Specified by:
getScene in class Frame3DBase

getViewer

public Viewer getViewer()
Returns:
Returns the viewer.

getView

public View getView()
Returns:
the view

createPeer

protected void createPeer(java.lang.Object owner)
Specified by:
createPeer in class Frame3DBase

setPerspective

public void setPerspective(boolean p)
Overrides:
setPerspective in class Transformator

rotate2D

public void rotate2D(int newX,
                     int newY,
                     boolean inverse)
Description copied from class: Transformator
Does a rotation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many rotate2D as required. Note that WSize should be set to the same value referential as the positions. This is typically a window dimension.

Overrides:
rotate2D in class Transformator
Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position
inverse - Inverse the direction of the rotation if true. This is used ROTATION_MODE viewing mode for the scene, in which case the scene rotates according to the mouse => in fact, the camera rotates in the opposite direction. => default is true

zoom

public void zoom(int zoomIncrement)
Description copied from class: Transformator
Zooms in or out of the scene according to the increment. This is an arbitrary algorithm to help create correct zoom factors. You could use setZoomFactor and then update the zoom matrix directly, with the same effect.
The added value of this function is to provide a relative and easy to manipulate way to zoom in or out, with increments like +1 or -1 for small zooms, and +10 and -10 for greater zooms, etc...
Note that WSize should be set correctly.

Overrides:
zoom in class Transformator
Parameters:
zoomIncrement - A value typically 1 or -1, but which can be greater for fast zooms. Positive values zoom in, negative values zoom out.

zoom2D

public void zoom2D(int newX,
                   int newY)
Description copied from class: Transformator
Uses the 2D increments in position to compute a zoom factor, then zooms the scene accordingly.

Overrides:
zoom2D in class Transformator
Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

translate2D

public void translate2D(int newX,
                        int newY)
Description copied from class: Transformator
Does a translation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many translate2D as required. Note that WSize should be set to the same value referential as the positions. This is typically a window dimension.

Overrides:
translate2D in class Transformator
Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

applyTransform

public void applyTransform()
Description copied from class: Transformator
Hook for subclasses, to apply the current transformation to a relevant object This method is called internally when a change occurs. It has been set public so it is possible to call it explicitely, but this should not be necessary. It does nothing by default, let subclasses do what they want.

Overrides:
applyTransform in class Transformator

toggleSinglePick

public java.util.ArrayList toggleSinglePick(int posX,
                                            int posY)
Adds or removes a single pick at the given position to the selected objects.

Parameters:
posX - the 2D X position where to do the picking
posY - the 2D Y position where to do the picking
Returns:
Returns the current selection, possibly an empy array
See Also:
ActiveNode.higlight(boolean,Object)

toggleAllPicks

public java.util.ArrayList toggleAllPicks(int posX,
                                          int posY)
Adds or removes all picks between the given position and the last position, to the selected objects.

Parameters:
posX - the 2D X position defining a region with the last position. All objects in this region should be picked.
posX - the 2D Y position defining a region with the last position. All objects in this region should be picked.
Returns:
Returns the current selection, possibly an empy array
See Also:
ActiveNode.higlight(boolean,Object)

pick

public ActiveNode pick(int posX,
                       int posY)
Selects a single pick at the given position.

Parameters:
posX - the 2D X position where to do the picking
posY - the 2D Y position where to do the picking
Returns:
Returns the picked node or possibly a null object if there was nothing to pick at this position
See Also:
ActiveNode.higlight(boolean,Object)

getSceneSize

protected float getSceneSize()
Description copied from class: Frame3DBase
Used for auto-zooming to englobe the scene

Overrides:
getSceneSize in class Frame3DBase
Returns:
<=0 if not supported, or the max distance from the origin for any point in the scene otherwise

main

public static void main(java.lang.String[] args)
Main function to test navigation

Parameters:
args -