FreeHEP API
Version current

org.freehep.graphics3d
Class ArcBall

java.lang.Object
  extended byorg.freehep.graphics3d.ArcBall
All Implemented Interfaces:
EventListener, KeyListener, MouseListener, MouseMotionListener

public class ArcBall
extends Object
implements MouseMotionListener, MouseListener, KeyListener

Implements an ArcBall. The ball sits on top of the Canvas, allowing the user to grab it with the mouse and drag it to rotate the ball as well as the model shown on the canvas. The ongoing drag, as well as the outline of the ball is shown, while dragging. The resulting drag may also be shown by pressing Caps-Lock. Using the Ctrl, Shift or Ctrl+Shift keys will constrain the rotation to Camera, Body or User defined Axes. While moving the mouse and pressing the keys, the selected constraint axis will highlight. After pressing the mouse button (and a key), a rotation will start, constrained by the selected axis.

Original ArcBall C code from Ken Shoemake, Graphics Gems IV, 1993.

Version:
$Id: ArcBall.java,v 1.5 2002/12/13 17:40:47 duns Exp $
Author:
Mark Donszelmann
Source Code:
ArcBall.java

Constructor Summary
ArcBall(Component component)
          Creates an ArcBall of size 0.8 to be placed on the given component
ArcBall(Component component, double size)
          Creates an ArcBall of given size to be placed on the given component
 
Method Summary
 double getBallSize()
           
 Enumeration getDrawables(Matrix4 m)
           
 boolean isEnabled()
           
 void keyPressed(KeyEvent event)
          Handles the pressing of the Ctrl, Shift and Caps-Lock keys
 void keyReleased(KeyEvent event)
          Handles the release of the Ctrl, Shift and Caps-Lock keys
 void keyTyped(KeyEvent event)
          Ignored
 void mouseClicked(MouseEvent event)
          Ignored
 void mouseDragged(MouseEvent event)
          Left mouse button will update the (matrix) state of the ArcBall, and show the dragged (constraint) path.
 void mouseEntered(MouseEvent event)
          Grabs keyboard focus
 void mouseExited(MouseEvent event)
          Ignored
 void mouseMoved(MouseEvent event)
          Moving the mouse will highlight (if a key is pressed) one of the constraint axes.
 void mousePressed(MouseEvent event)
          Left mouse button will store start state of the drag, as well as showing the constraint axis if any.
 void mouseReleased(MouseEvent event)
          Left mouse button will store and if requested show the resulting dragged arc.
 void setEnabled(boolean on)
          enables or disables the arcball
 void setOtherAxis(int index, Vector3 axis)
          Sets one of the user axes.
 Matrix4 toMatrix()
           
 Quaternion toQuaternion()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArcBall

public ArcBall(Component component)
Creates an ArcBall of size 0.8 to be placed on the given component


ArcBall

public ArcBall(Component component,
               double size)
Creates an ArcBall of given size to be placed on the given component

Method Detail

setEnabled

public void setEnabled(boolean on)
enables or disables the arcball


isEnabled

public boolean isEnabled()
Returns:
true if arcball is enabled

setOtherAxis

public void setOtherAxis(int index,
                         Vector3 axis)
Sets one of the user axes.

Parameters:
index - in range 0..2
axis -

mouseClicked

public void mouseClicked(MouseEvent event)
Ignored

Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent event)
Grabs keyboard focus

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent event)
Ignored

Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent event)
Left mouse button will store start state of the drag, as well as showing the constraint axis if any.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent event)
Left mouse button will store and if requested show the resulting dragged arc.

Specified by:
mouseReleased in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent event)
Left mouse button will update the (matrix) state of the ArcBall, and show the dragged (constraint) path.

Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent event)
Moving the mouse will highlight (if a key is pressed) one of the constraint axes.

Specified by:
mouseMoved in interface MouseMotionListener

keyPressed

public void keyPressed(KeyEvent event)
Handles the pressing of the Ctrl, Shift and Caps-Lock keys

Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent event)
Handles the release of the Ctrl, Shift and Caps-Lock keys

Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent event)
Ignored

Specified by:
keyTyped in interface KeyListener

getBallSize

public double getBallSize()
Returns:
the size of the ArcBall.

getDrawables

public Enumeration getDrawables(Matrix4 m)
Returns:
an enumeration of drawables of the controller with all its (constraint) arcs.

toMatrix

public Matrix4 toMatrix()
Returns:
a matrix representation of the current quaternion

toQuaternion

public Quaternion toQuaternion()
Returns:
the current quaternion

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.