use of javax.media.j3d.WakeupCriterion in project ffx by mjschnie.
the class MouseRotate 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();
// Drag and Button 1 down
if ((id == MouseEvent.MOUSE_DRAGGED) && ((mevent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK) && transformGroup != null) {
x = ((MouseEvent) event[i]).getX();
y = ((MouseEvent) event[i]).getY();
int dx = x - x_last;
int dy = y - y_last;
if (!reset) {
x_angle = dy * y_factor;
y_angle = dx * x_factor;
transformX.rotX(x_angle);
transformY.rotY(y_angle);
transformGroup.getTransform(currXform);
currXform.get(mat);
currXform.setTranslation(zero3d);
if (ViewerTG != null) {
ViewerTG.getTransform(VPTG_T3D);
VPTG_T3D.setTranslation(zero3d);
VPTG_T3D.invert();
currXform.mul(VPTG_T3D, currXform);
}
if (invert) {
currXform.mul(currXform, transformX);
currXform.mul(currXform, transformY);
} else {
currXform.mul(transformX, currXform);
currXform.mul(transformY, currXform);
}
if (ViewerTG != null) {
VPTG_T3D.invert();
currXform.mul(VPTG_T3D, currXform);
}
translation.set(mat.m03, mat.m13, mat.m23);
currXform.setTranslation(translation);
transformGroup.setTransform(currXform);
transformChanged(currXform);
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.TRANSLATE, currXform);
}
} else {
reset = false;
}
x_last = x;
y_last = y;
} else 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 || postCriterion == null) {
wakeupOn(mouseCriterion);
} else {
postId(doneID);
wakeupOn(postCriterion);
}
}
use of javax.media.j3d.WakeupCriterion in project ffx by mjschnie.
the class PickMouseBehavior method processStimulus.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] evt = null;
int xpos = 0, ypos = 0;
while (criteria.hasMoreElements()) {
wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
evt = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
}
}
if (evt[0] instanceof MouseEvent) {
mevent = (MouseEvent) evt[0];
processMouseEvent((MouseEvent) evt[0]);
xpos = mevent.getPoint().x;
ypos = mevent.getPoint().y;
}
if (buttonPress) {
updateScene(xpos, ypos);
}
wakeupOn(wakeupCondition);
}
use of javax.media.j3d.WakeupCriterion in project ffx by mjschnie.
the class GraphicsEvents method initialize.
/**
* <p>
* initialize</p>
*/
public void initialize() {
WakeupCriterion[] behaviorPost = new WakeupCriterion[3];
behaviorPost[0] = new WakeupOnBehaviorPost(systemRotate, BEHAVIORDONEPOST);
behaviorPost[1] = new WakeupOnBehaviorPost(systemTranslate, BEHAVIORDONEPOST);
behaviorPost[2] = new WakeupOnBehaviorPost(globalZoom, BEHAVIORDONEPOST);
postCriterion = new WakeupOr(behaviorPost);
WakeupCriterion[] awtCriterion = new WakeupCriterion[2];
awtCriterion[0] = new WakeupOnAWTEvent(Event.MOUSE_DOWN);
awtCriterion[1] = new WakeupOnAWTEvent(Event.MOUSE_UP);
mouseCriterion = new WakeupOr(awtCriterion);
wakeupOn(mouseCriterion);
}
use of javax.media.j3d.WakeupCriterion in project ffx by mjschnie.
the class MouseProperties method processStimulus.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] event;
int id;
while (criteria.hasMoreElements()) {
wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
for (int i = 0; i < event.length; i++) {
processMouseEvent((MouseEvent) event[i]);
if (((buttonPress) && ((flags & MANUAL_WAKEUP) == 0)) || ((wakeUp) && ((flags & MANUAL_WAKEUP) != 0))) {
id = event[i].getID();
if ((id == MouseEvent.MOUSE_DRAGGED)) {
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
} else if (id == MouseEvent.MOUSE_PRESSED) {
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
}
}
}
}
}
wakeupOn(mouseCriterion);
}
use of javax.media.j3d.WakeupCriterion in project ffx by mjschnie.
the class GraphicsEvents method processStimulus.
// Most of the logic for mouse interaction with the Scenegraph is here.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
viewOrbitBehavior.setEnable(false);
AWTEvent[] awtEvents = null;
while (criteria.hasMoreElements()) {
WakeupCriterion wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
awtEvents = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
if (awtEvents == null) {
continue;
}
for (int i = 0; i < awtEvents.length; i++) {
MouseEvent mouseEvent = null;
if (awtEvents[i] instanceof MouseEvent) {
mouseEvent = (MouseEvent) awtEvents[i];
processMouseEvent(mouseEvent);
} else {
continue;
}
if (!axisSelected) {
// Wake Up System Translate Behavior
if (rightButton && buttonPress) {
systemTranslate.setMouseButton(MouseEvent.BUTTON3_DOWN_MASK);
if (systemTranslate()) {
wakeupOn(postCriterion);
return;
}
}
// Wake Up Left Button Mode
if (leftButton && buttonPress) {
LeftButtonMode leftButtonMode = graphics3D.getLeftButtonMode();
switch(leftButtonMode) {
case ROTATE:
if (systemRotate()) {
wakeupOn(postCriterion);
return;
}
break;
case TRANSLATE:
systemTranslate.setMouseButton(MouseEvent.BUTTON1_DOWN_MASK);
if (systemTranslate()) {
wakeupOn(postCriterion);
return;
}
break;
case ZOOM:
globalZoom.setMouseButton(MouseEvent.BUTTON1_DOWN_MASK);
if (globalZoom()) {
wakeupOn(postCriterion);
return;
}
}
}
// Wake up Global Zoom Behavior
if (middleButton && buttonPress) {
globalZoom.setMouseButton(MouseEvent.BUTTON2_DOWN_MASK);
if (globalZoom()) {
wakeupOn(postCriterion);
return;
}
}
} else {
viewOrbitBehavior.setEnable(true);
wakeupOn(mouseCriterion);
return;
}
}
}
}
wakeupOn(mouseCriterion);
}
Aggregations