de.javagl.swogl.interaction
Class RotatingBehavior

java.lang.Object
  extended by de.javagl.swogl.interaction.RotatingBehavior

public class RotatingBehavior
extends java.lang.Object

This class allows rotating the SwoglComponents of a SwoglContainer in space. It may be used for the cases where the SwoglContainer has no layout manager.

Usually this class will be controlled by a MouseListener, and MouseWheelListener by calling the main public methods accordingly:

However, different applications of these methods may be implemented by the client.


Constructor Summary
RotatingBehavior(de.javagl.swogl.SwoglContainer swoglContainer)
          Creates a new RotatingBehavior for the given SwoglContainer.
 
Method Summary
 void doRotation(java.awt.Point point)
          Rotate the current SwoglComponent.
 void setRotationSpeed(float rotationSpeed)
          Set the rotation speed factor for this behavior.
 void startRotation(java.awt.Point point)
          Start the rotation of a SwoglComponent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RotatingBehavior

public RotatingBehavior(de.javagl.swogl.SwoglContainer swoglContainer)
Creates a new RotatingBehavior for the given SwoglContainer. The rotation speed will be 0.5.

Parameters:
swoglContainer - The SwoglContainer this behavior operates on
Throws:
java.lang.NullPointerException - if the given SwoglContainer is null
Method Detail

startRotation

public void startRotation(java.awt.Point point)
Start the rotation of a SwoglComponent. If a SwoglComponent is found inside the SwoglContainer at the given point, then subsequent calls to doRotation(Point) will rotate the SwoglComponent.

Parameters:
point - The point where the rotation should start
Throws:
java.lang.NullPointerException - if the given point is null

doRotation

public void doRotation(java.awt.Point point)
Rotate the current SwoglComponent. If no SwoglComponent was hit by the previous call to startRotation(Point), then this method does not have any visible effect. Otherwise, this method will rotate the SwoglComponent depending on the difference between the given point and the previous point.

Parameters:
point - The current point
Throws:
java.lang.NullPointerException - if the given point is null

setRotationSpeed

public void setRotationSpeed(float rotationSpeed)
Set the rotation speed factor for this behavior. This is the factor that is used for converting a mouse movement (in pixels) into degrees for the rotation.

Parameters:
rotationSpeed - The rotation speed factor