FreeHEP API
Version current

org.freehep.graphics3d
Class RotationSelectionPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.freehep.swing.graphics.GraphicalSelectionPanel
                      extended byorg.freehep.graphics3d.RotationSelectionPanel
All Implemented Interfaces:
Accessible, EventListener, ImageObserver, KeyListener, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class RotationSelectionPanel
extends GraphicalSelectionPanel

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: RotationSelectionPanel.java,v 1.11 2002/12/13 17:40:48 duns Exp $
Author:
Mark Donszelmann
See Also:
Serialized Form
Source Code:
RotationSelectionPanel.java

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.freehep.swing.graphics.GraphicalSelectionPanel
actionMap, defaultModeAction, nextAction, previousAction, selectionActions, thickStroke, thinStroke
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
RotationSelectionPanel()
          Creates an ArcBall of default (0.8) size.
RotationSelectionPanel(double size)
          Creates an ArcBall of given size.
 
Method Summary
 double getBallSize()
           
 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 mouseDragged(MouseEvent event)
          Left mouse button will update the (matrix) state of the ArcBall, and show the dragged (constraint) path.
 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 paintComponent(Graphics g)
           
 void setOtherAxis(int index, Vector3 axis)
          Sets one of the user axes.
 Matrix4 toMatrix()
           
 Quaternion toQuaternion()
           
 
Methods inherited from class org.freehep.swing.graphics.GraphicalSelectionPanel
addActionEntry, addActionEntry, addGraphicalSelectionListener, cancelPopupProcessing, fireGraphicalSelectionMade, getBorder, getPopupMenu, isProcessingPopup, makeSelectionEvent, mouseClicked, mouseEntered, mouseExited, removeGraphicalSelectionListener, resetSelection, setBorder, setBounds, setSelectionActionsEnabled, testPopupTrigger
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

RotationSelectionPanel

public RotationSelectionPanel()
Creates an ArcBall of default (0.8) size.


RotationSelectionPanel

public RotationSelectionPanel(double size)
Creates an ArcBall of given size.

Method Detail

setOtherAxis

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

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

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
Overrides:
mousePressed in class GraphicalSelectionPanel
Parameters:
event - MouseEvent describing action

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
Overrides:
mouseReleased in class GraphicalSelectionPanel
Parameters:
event - MouseEvent describing action

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
Overrides:
mouseDragged in class GraphicalSelectionPanel
Parameters:
event - MouseEvent describing action

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
Overrides:
mouseMoved in class GraphicalSelectionPanel
Parameters:
event - MouseEvent describing action

keyPressed

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

Specified by:
keyPressed in interface KeyListener
Overrides:
keyPressed in class GraphicalSelectionPanel
Parameters:
event - KeyEvent describing key which has been pressed.

keyReleased

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

Specified by:
keyReleased in interface KeyListener
Overrides:
keyReleased in class GraphicalSelectionPanel
Parameters:
event - KeyEvent describing the key which has been released

keyTyped

public void keyTyped(KeyEvent event)
Ignored

Specified by:
keyTyped in interface KeyListener
Overrides:
keyTyped in class GraphicalSelectionPanel
Parameters:
event - KeyEvent describing key which has been typed.

getBallSize

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

paintComponent

public void paintComponent(Graphics g)

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.