de.fhg.igd.earth.view.behavior
Class SphereBehavior

java.lang.Object
  extended byjavax.media.j3d.SceneGraphObject
      extended byjavax.media.j3d.Node
          extended byjavax.media.j3d.Leaf
              extended byjavax.media.j3d.Behavior
                  extended bycom.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
                      extended byde.fhg.igd.earth.view.behavior.VPMouseBehavior
                          extended byde.fhg.igd.earth.view.behavior.SphereBehavior
All Implemented Interfaces:
EventListener, MouseListener, MouseMotionListener

public class SphereBehavior
extends VPMouseBehavior

Moves the View around a point of interest. Includes rotation, translation and zoom actions. This behavior must be added to the ViewingPlatform using the addViewPlatformBehavior method.

Since:
Java 3D 1.2.1 Title : Earth Copyright : Copyright (c) 2001 Organisation : IGD FhG
Version:
: 1.0
Author:
: Werner Beutel

Field Summary
private  javax.media.j3d.Canvas3D canvas
           
private  javax.vecmath.Vector3d centerVector
           
private  double deltaRadius
           
static int DISABLE_ROTATE
          Constructor flag to disable rotate
static int DISABLE_TRANSLATE
          Constructor flag to disable translate
static int DISABLE_ZOOM
          Constructor flag to disable zoom
private  double distanceFromCenter
           
private  javax.vecmath.Vector3d distanceVector
           
private  javax.vecmath.Point3d eyePos
           
private  int leftButton
           
private  double MAX_ANGLE
           
private  double maxRadius
           
private  int middleButton
           
private  double minRadius
           
private  int mouseX
           
private  int mouseY
           
private  double pitchAngle
           
private  javax.media.j3d.Transform3D pitchTransform
           
private  SphereProjector projector_
           
static int REVERSE_ROTATE
          Constructor flag to reverse the rotate behavior
static int REVERSE_TRANSLATE
          Constructor flag to reverse the translate behavior
static int REVERSE_ZOOM
          Constructor flag to reverse the zoom behavior
private  boolean reverseRotate
           
private  boolean reverseTrans
           
private  boolean reverseZoom
           
private  int rightButton
           
private  double rollAngle
           
private  javax.media.j3d.Transform3D rollTransform
           
static int ROTATE
          Used to set the fuction for a mouse button to Rotate
private  boolean rotateEnabled
           
private  javax.media.j3d.Transform3D rotateTransform
           
private  javax.vecmath.Point3d rotationCenter
           
private  double rx_factor
           
private  double ry_factor
           
private  double rz_factor
           
(package private) static double StartDistanceFromCenter
           
static int STOP_ZOOM
          Constructor flag that indicates zoom should stop when it reaches the minimum Sphere radius set by setMinRadius().
private  boolean stopZoom
           
private  javax.media.j3d.Transform3D temp1
           
private  javax.media.j3d.Transform3D temp2
           
static int TRANSLATE
          Used to set the function for a mouse button to Translate
private  boolean translateEnabled
           
private  javax.media.j3d.Transform3D translation
           
private  javax.vecmath.Vector3d transVector
           
private  javax.media.j3d.Transform3D velocityTransform
           
private  javax.vecmath.Vector3d viewUp
           
private  double x_factor
           
private  double xtrans
           
private  double y_factor
           
private  double yawAngle
           
private  javax.media.j3d.Transform3D yawTransform
           
private  double ytrans
           
private  double z_factor
           
static int ZOOM
          Used to set the function for a mouse button to Zoom
private  double ZOOM_FACTOR
           
private  boolean zoomEnabled
           
 
Fields inherited from class de.fhg.igd.earth.view.behavior.VPMouseBehavior
bpDrag, bpPress, bpRelease, ef, motion, mouseCriterion, mouseEvents, mouseq, targetTransform
 
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
homeTransform, targetTG, vp
 
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Fields inherited from class javax.media.j3d.SceneGraphObject
 
Constructor Summary
SphereBehavior(javax.media.j3d.Canvas3D c, int flags, SphereProjector projector)
          Creates a new SphereBehavior
SphereBehavior(javax.media.j3d.Canvas3D c, SphereProjector projector)
          Creates a new SphereBehavior
 
Method Summary
 double getMinRadius()
          Returns the minimum Sphere radius.
 boolean getRotateEnable()
          Retrieves the state of rotate enabled
 void getRotationCenter(javax.vecmath.Point3d center)
          Places the value of the center around which the View rotates into the Point3d.
 boolean getTranslateEnable()
          Retrieves the state of translate enabled
 double getXFactor()
          Returns the x-axis movement multiplier
 double getYFactor()
          Returns the y-axis movement multiplier
 double getZFactor()
          Returns the z-axis movement multiplier
 boolean getZoomEnable()
          Retrieves the state of zoom enabled
 void initialize()
          Initializes the behavior.
(package private)  void integrateTransforms()
          Called once per frame (if the view is moving) to calculate the new view platform transform
(package private)  void jZoomSlider_mouseDragged(MouseEvent e)
           
(package private)  void jZoomSlider_mousePressed(MouseEvent e)
           
(package private)  void jZoomSlider_mouseReleased(MouseEvent e)
           
(package private)  void processMouseEvent(MouseEvent evt)
          Process the mouse events, this is called every time an event arrives
(package private)  boolean rotate(MouseEvent evt)
           
 void setFactor(double factor)
          Set the x-axis, y-axis and z-axis movement multipler with factor.
 void setMinRadius(double r)
          Sets the minimum radius for the SphereBehavior.
 void setRotateEnable(boolean enabled)
          Enables or disables rotation
 void setRotation(double x, double y, double z)
           
 void setRotationCenter(javax.vecmath.Point3d center)
          Sets the center around which the View rotates
 void setTranslateEnable(boolean enabled)
          Enables or disables translate
 void setViewingPlatform(com.sun.j3d.utils.universe.ViewingPlatform vp)
          Sets the ViewingPlatform of this behavior.
 void setXFactor(double xFactor)
          Set the x-axis movement multiplier
 void setYFactor(double yFactor)
          Set the y-axis movement multiplier
 void setZFactor(double zFactor)
          Set the z-axis movement multiplier
 void setZoomEnable(boolean enabled)
          Enables or disables zoom
private  void showPosition()
           
(package private)  boolean translate(MouseEvent evt)
           
(package private)  boolean zoom(MouseEvent evt)
           
 
Methods inherited from class de.fhg.igd.earth.view.behavior.VPMouseBehavior
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, processAWTEvents, processStimulus
 
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
getHomeTransform, getViewingPlatform, goHome, setHomeTransform
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn
 
Methods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

StartDistanceFromCenter

static final double StartDistanceFromCenter
See Also:
Constant Field Values

velocityTransform

private javax.media.j3d.Transform3D velocityTransform

yawTransform

private javax.media.j3d.Transform3D yawTransform

rollTransform

private javax.media.j3d.Transform3D rollTransform

pitchTransform

private javax.media.j3d.Transform3D pitchTransform

rotateTransform

private javax.media.j3d.Transform3D rotateTransform

temp1

private javax.media.j3d.Transform3D temp1

temp2

private javax.media.j3d.Transform3D temp2

translation

private javax.media.j3d.Transform3D translation

transVector

private javax.vecmath.Vector3d transVector

distanceVector

private javax.vecmath.Vector3d distanceVector

centerVector

private javax.vecmath.Vector3d centerVector

yawAngle

private double yawAngle

pitchAngle

private double pitchAngle

rollAngle

private double rollAngle

distanceFromCenter

private double distanceFromCenter

MAX_ANGLE

private double MAX_ANGLE

ZOOM_FACTOR

private double ZOOM_FACTOR

rotationCenter

private javax.vecmath.Point3d rotationCenter

viewUp

private javax.vecmath.Vector3d viewUp

eyePos

private javax.vecmath.Point3d eyePos

mouseX

private int mouseX

mouseY

private int mouseY

canvas

private javax.media.j3d.Canvas3D canvas

x_factor

private double x_factor

y_factor

private double y_factor

z_factor

private double z_factor

rx_factor

private double rx_factor

ry_factor

private double ry_factor

rz_factor

private double rz_factor

xtrans

private double xtrans

ytrans

private double ytrans

zoomEnabled

private boolean zoomEnabled

rotateEnabled

private boolean rotateEnabled

translateEnabled

private boolean translateEnabled

reverseRotate

private boolean reverseRotate

reverseTrans

private boolean reverseTrans

reverseZoom

private boolean reverseZoom

stopZoom

private boolean stopZoom

minRadius

private double minRadius

maxRadius

private double maxRadius

deltaRadius

private double deltaRadius

leftButton

private int leftButton

middleButton

private int middleButton

rightButton

private int rightButton

STOP_ZOOM

public static final int STOP_ZOOM
Constructor flag that indicates zoom should stop when it reaches the minimum Sphere radius set by setMinRadius(). The minimus radius default is 0.0.

See Also:
Constant Field Values

DISABLE_ROTATE

public static final int DISABLE_ROTATE
Constructor flag to disable rotate

See Also:
Constant Field Values

DISABLE_TRANSLATE

public static final int DISABLE_TRANSLATE
Constructor flag to disable translate

See Also:
Constant Field Values

DISABLE_ZOOM

public static final int DISABLE_ZOOM
Constructor flag to disable zoom

See Also:
Constant Field Values

REVERSE_ROTATE

public static final int REVERSE_ROTATE
Constructor flag to reverse the rotate behavior

See Also:
Constant Field Values

REVERSE_TRANSLATE

public static final int REVERSE_TRANSLATE
Constructor flag to reverse the translate behavior

See Also:
Constant Field Values

REVERSE_ZOOM

public static final int REVERSE_ZOOM
Constructor flag to reverse the zoom behavior

See Also:
Constant Field Values

ROTATE

public static final int ROTATE
Used to set the fuction for a mouse button to Rotate

See Also:
Constant Field Values

TRANSLATE

public static final int TRANSLATE
Used to set the function for a mouse button to Translate

See Also:
Constant Field Values

ZOOM

public static final int ZOOM
Used to set the function for a mouse button to Zoom

See Also:
Constant Field Values

projector_

private SphereProjector projector_
Constructor Detail

SphereBehavior

public SphereBehavior(javax.media.j3d.Canvas3D c,
                      SphereProjector projector)
Creates a new SphereBehavior

Parameters:
c - The Canvas3D to add the behavior to

SphereBehavior

public SphereBehavior(javax.media.j3d.Canvas3D c,
                      int flags,
                      SphereProjector projector)
Creates a new SphereBehavior

Parameters:
c - The Canvas3D to add the behavior to
flags - The option flags
Method Detail

jZoomSlider_mousePressed

void jZoomSlider_mousePressed(MouseEvent e)

jZoomSlider_mouseDragged

void jZoomSlider_mouseDragged(MouseEvent e)

jZoomSlider_mouseReleased

void jZoomSlider_mouseReleased(MouseEvent e)

initialize

public void initialize()
Initializes the behavior. NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.

Overrides:
initialize in class VPMouseBehavior

processMouseEvent

void processMouseEvent(MouseEvent evt)
Description copied from class: VPMouseBehavior
Process the mouse events, this is called every time an event arrives

Specified by:
processMouseEvent in class VPMouseBehavior

showPosition

private void showPosition()

integrateTransforms

void integrateTransforms()
Description copied from class: VPMouseBehavior
Called once per frame (if the view is moving) to calculate the new view platform transform

Specified by:
integrateTransforms in class VPMouseBehavior

setRotation

public void setRotation(double x,
                        double y,
                        double z)

setRotationCenter

public void setRotationCenter(javax.vecmath.Point3d center)
Sets the center around which the View rotates

Parameters:
center - The Point3d to set the center of rotation to

getRotationCenter

public void getRotationCenter(javax.vecmath.Point3d center)
Places the value of the center around which the View rotates into the Point3d.

Parameters:
center - The Point3d

setFactor

public void setFactor(double factor)
Set the x-axis, y-axis and z-axis movement multipler with factor.

Parameters:
factor - The movement multiplier

setXFactor

public void setXFactor(double xFactor)
Set the x-axis movement multiplier

Parameters:
xFactor - The movement multiplier for the x-axis

setYFactor

public void setYFactor(double yFactor)
Set the y-axis movement multiplier

Parameters:
yFactor - The movement multiplier for the y-axis

setZFactor

public void setZFactor(double zFactor)
Set the z-axis movement multiplier

Parameters:
zFactor - The movement multiplier for the z-axis

getXFactor

public double getXFactor()
Returns the x-axis movement multiplier

Returns:
The movement multiplier for the x-axis

getYFactor

public double getYFactor()
Returns the y-axis movement multiplier

Returns:
The movement multiplier for the y-axis

getZFactor

public double getZFactor()
Returns the z-axis movement multiplier

Returns:
The movement multiplier for the z-axis

setViewingPlatform

public void setViewingPlatform(com.sun.j3d.utils.universe.ViewingPlatform vp)
Sets the ViewingPlatform of this behavior. This method is called by the ViewingPlatform

Parameters:
vp - The ViewingPlatform

setRotateEnable

public void setRotateEnable(boolean enabled)
Enables or disables rotation

Parameters:
enabled - true or false to enable or disable rotate

setZoomEnable

public void setZoomEnable(boolean enabled)
Enables or disables zoom

Parameters:
enabled - true or false to enable or disable zoom

setTranslateEnable

public void setTranslateEnable(boolean enabled)
Enables or disables translate

Parameters:
enabled - true or false to enable or disable translate

getRotateEnable

public boolean getRotateEnable()
Retrieves the state of rotate enabled

Returns:
the rotate enable state

getZoomEnable

public boolean getZoomEnable()
Retrieves the state of zoom enabled

Returns:
the zoom enable state

getTranslateEnable

public boolean getTranslateEnable()
Retrieves the state of translate enabled

Returns:
the translate enable state

rotate

boolean rotate(MouseEvent evt)

zoom

boolean zoom(MouseEvent evt)

translate

boolean translate(MouseEvent evt)

setMinRadius

public void setMinRadius(double r)
Sets the minimum radius for the SphereBehavior. The zoom will stop at this distance from the center of rotation. The default is 0.0. The minimum will have no affect if the STOP_ZOOM constructor flag is not set.

Parameters:
r - the minimum radius
Throws:
IllegalArgumentException - if the radius is less than 0.0

getMinRadius

public double getMinRadius()
Returns the minimum Sphere radius. The zoom will stop at this distance from the center of rotation if the STOP_ZOOM constructor flag is set.

Returns:
the minimum radius


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.