/* (non-Javadoc)
* @see com.jMT.input.gestureAction.IGestureAction#processGesture(com.jMT.input.inputAnalyzers.GestureEvent)
*/
public boolean processGestureEvent(MTGestureEvent g) {
if (g instanceof ScaleEvent){
ScaleEvent scaleEvent = (ScaleEvent)g;
if (target == null)
target = scaleEvent.getTargetComponent();
switch (scaleEvent.getId()) {
case MTGestureEvent.GESTURE_DETECTED:
if (target instanceof MTComponent){
((MTComponent)target).sendToFront();
/*
Animation[] animations = AnimationManager.getInstance().getAnimationsForTarget(target);
for (int i = 0; i < animations.length; i++) {
Animation animation = animations[i];
animation.stop();
}
*/
}
break;
case MTGestureEvent.GESTURE_UPDATED:
if (this.hasScaleLimit){
if (target instanceof MTComponent) {
MTComponent comp = (MTComponent) target;
//FIXME actually we should use globalmatrix but performance is better for localMatrix..
Vector3D currentScale = comp.getLocalMatrix().getScale();
// if (currentScale.x != currentScale.y){
// System.out.println("non uniform scale!");
// }
//We only check X because only uniform scales (x=y factor) should be used!
if (currentScale.x * scaleEvent.getScaleFactorX() > this.maxScale){
// System.out.println("Scale MAX Limit Hit!");
//We should set to min scale, but we choose performance over accuracy
//float factor = (1f/currentScale.x) * maxScale;
//target.scaleGlobal(factor, factor, scaleEvent.getScaleFactorZ(), scaleEvent.getScalingPoint());
}else if (currentScale.x * scaleEvent.getScaleFactorX() < this.minScale){
// System.out.println("Scale MIN Limit Hit!");
//We should set to min scale, but we choose performance over accuracy
//float factor = (1f/currentScale.x) * minScale;
//target.scaleGlobal(factor, factor, scaleEvent.getScaleFactorZ(), scaleEvent.getScalingPoint());
}else{
target.scaleGlobal(
scaleEvent.getScaleFactorX(),
scaleEvent.getScaleFactorY(),
scaleEvent.getScaleFactorZ(),
scaleEvent.getScalingPoint());
}
}
}else{
target.scaleGlobal(
scaleEvent.getScaleFactorX(),
scaleEvent.getScaleFactorY(),
scaleEvent.getScaleFactorZ(),
scaleEvent.getScalingPoint());
}
break;
case MTGestureEvent.GESTURE_ENDED:
break;
default: