de.javagl.swogl.interaction
Class ScalingBehavior

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

public class ScalingBehavior
extends java.lang.Object

This class allows scaling 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 MouseMotionListener by calling the main public methods accordingly:

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


Constructor Summary
ScalingBehavior(de.javagl.swogl.SwoglContainer swoglContainer)
          Creates a new ScalingBehavior for the given SwoglContainer.
 
Method Summary
 void doScaling(java.awt.Point point)
          Scale the current SwoglComponent.
 void setScalingSpeed(float scalingSpeed)
          Set the scaling speed factor.
 void setUniformScaling(boolean uniformScaling)
          Set whether the scaling should be uniform.
 void startScaling(java.awt.Point point)
          Start scaling the current SwoglComponent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScalingBehavior

public ScalingBehavior(de.javagl.swogl.SwoglContainer swoglContainer)
Creates a new ScalingBehavior for the given SwoglContainer. The scaling speed will be 1.0 and the scaling will be non-uniform.

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

startScaling

public void startScaling(java.awt.Point point)
Start scaling the current SwoglComponent. If a SwoglComponent is found inside the SwoglContainer at the given point, then subsequent calls to doScaling(Point) will scale the SwoglComponent.

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

doScaling

public void doScaling(java.awt.Point point)
Scale the current SwoglComponent. If no SwoglComponent was hit by the previous call to startScaling(Point), then this method does not have any effect. Otherwise, this method will scale 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

setScalingSpeed

public void setScalingSpeed(float scalingSpeed)
Set the scaling speed factor. This factor will be used to convert mouse movement (in pixels) into scaling factors (in percent)

Parameters:
scalingSpeed - The scaling speed factor

setUniformScaling

public void setUniformScaling(boolean uniformScaling)
Set whether the scaling should be uniform. When the scaling is uniform, the actual scaling will be the maximum of the scalings implied by the movement in x- and y-direction.

Parameters:
uniformScaling - Whether the scaling should be uniform