use of javax.media.j3d.WakeupOnAWTEvent in project ffx by mjschnie.
the class MouseTranslate method processStimulus.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
while (criteria.hasMoreElements()) {
WakeupCriterion wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
AWTEvent[] event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
for (int i = 0; i < event.length; i++) {
MouseEvent mevent = (MouseEvent) event[i];
processMouseEvent(mevent);
int id = event[i].getID();
int mod = mevent.getModifiersEx();
boolean rightButton = ((mod & mouseButton) == mouseButton);
if (!rightButton) {
rightButton = ((mod & MouseEvent.SHIFT_DOWN_MASK) == MouseEvent.SHIFT_DOWN_MASK);
}
if ((id == MouseEvent.MOUSE_DRAGGED) && rightButton && transformGroup != null) {
x = ((MouseEvent) event[i]).getX();
y = ((MouseEvent) event[i]).getY();
int dx = x - x_last;
int dy = y - y_last;
if ((!reset) && ((Math.abs(dy) < 50) && (Math.abs(dx) < 50))) {
transformGroup.getTransform(currXform);
Transform3D VPTG_T3D = new Transform3D();
ViewerTG.getTransform(VPTG_T3D);
VPTG_T3D.setTranslation(zero3d);
VPTG_T3D.invert();
currXform.mul(VPTG_T3D, currXform);
translation.x = dx * x_factor;
translation.y = -dy * y_factor;
transformX.set(translation);
if (invert) {
currXform.mul(currXform, transformX);
} else {
currXform.mul(transformX, currXform);
}
VPTG_T3D.invert();
currXform.mul(VPTG_T3D, currXform);
transformGroup.setTransform(currXform);
transformChanged(currXform);
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.TRANSLATE, currXform);
}
} else {
reset = false;
}
x_last = x;
y_last = y;
}
if (id == MouseEvent.MOUSE_PRESSED) {
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
} else if (id == MouseEvent.MOUSE_RELEASED) {
setTransformGroup(null);
}
}
}
}
if (transformGroup != null) {
wakeupOn(mouseCriterion);
} else {
mouseButton = MouseEvent.BUTTON3_DOWN_MASK;
postId(doneID);
wakeupOn(postCriterion);
}
}
Aggregations