use of javax.media.j3d.WakeupOnAWTEvent 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.WakeupOnAWTEvent 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);
}
use of javax.media.j3d.WakeupOnAWTEvent in project ffx by mjschnie.
the class MouseSelection 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)) {
if (!reset) {
transformChanged(currXform);
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.SELECTION, currXform);
}
} else {
reset = false;
}
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
}
if (id == MouseEvent.MOUSE_PRESSED) {
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
}
}
}
}
}
wakeupOn(mouseCriterion);
}
use of javax.media.j3d.WakeupOnAWTEvent in project ffx by mjschnie.
the class MouseZoom method processStimulus.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
AWTEvent[] event;
boolean done = false;
while (criteria.hasMoreElements()) {
WakeupCriterion wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
for (int i = 0; i < event.length; i++) {
processMouseEvent((MouseEvent) event[i]);
int id = event[i].getID();
MouseEvent mevent = (MouseEvent) event[i];
int mod = mevent.getModifiersEx();
boolean middleButton = ((mod & mouseButton) == mouseButton);
if (!middleButton) {
middleButton = ((mod & MouseEvent.ALT_DOWN_MASK) == MouseEvent.ALT_DOWN_MASK);
}
if ((id == MouseEvent.MOUSE_DRAGGED) && middleButton) {
y = ((MouseEvent) event[i]).getY();
int dy = y - y_last;
if (!reset) {
transformGroup.getTransform(currXform);
double z = (-1.0) * dy * z_factor;
double scale = currXform.getScale() + z;
if (scale > 0) {
currXform.setScale(scale);
transformGroup.setTransform(currXform);
transformChanged(currXform);
}
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.ZOOM, 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) {
done = true;
}
}
}
}
if (!done) {
wakeupOn(mouseCriterion);
} else {
reset = true;
mouseButton = MouseEvent.BUTTON2_DOWN_MASK;
postId(doneID);
wakeupOn(postCriterion);
}
}
use of javax.media.j3d.WakeupOnAWTEvent in project ffx by mjschnie.
the class MouseOrbit method processStimulus.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] event;
int id;
int dx, dy;
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 = ((MouseEvent) event[i]).getX();
y = ((MouseEvent) event[i]).getY();
dx = x - x_last;
dy = y - y_last;
if (!reset) {
Transform3D tempT3D = new Transform3D();
Transform3D orbitT3D = new Transform3D();
tempT3D.rotX(-dy * y_factor);
orbitT3D.mul(tempT3D);
tempT3D.rotY(-dx * x_factor);
orbitT3D.mul(tempT3D);
Transform3D tg_ghost_T3D = new Transform3D();
tg_ghost.getTransform(tg_ghost_T3D);
Vector3f tg_ghost_vec3f = new Vector3f();
tg_ghost_T3D.get(tg_ghost_vec3f);
Matrix4d tg_ghost_mat4d = new Matrix4d();
tg_ghost_T3D.get(tg_ghost_mat4d);
Transform3D VPTG_ghost_T3D_inverted = new Transform3D();
Transform3D VPTG_ghost_T3D_noninverted = new Transform3D();
// (super.ViewerTG).getTransform(VPTG_ghost_T3D_inverted);
ViewerTG.getTransform(VPTG_ghost_T3D_inverted);
// (super.ViewerTG).getTransform(VPTG_ghost_T3D_noninverted);
ViewerTG.getTransform(VPTG_ghost_T3D_noninverted);
VPTG_ghost_T3D_inverted.setTranslation(new Vector3d(0.0, 0.0, 0.0));
VPTG_ghost_T3D_noninverted.setTranslation(new Vector3d(0.0, 0.0, 0.0));
VPTG_ghost_T3D_inverted.invert();
tg_ghost_T3D.mul(VPTG_ghost_T3D_inverted, tg_ghost_T3D);
tg_ghost_T3D.setTranslation(new Vector3d(0.0, 0.0, 0.0));
if (invert) {
tg_ghost_T3D.mul(tg_ghost_T3D, orbitT3D);
} else {
tg_ghost_T3D.mul(orbitT3D, tg_ghost_T3D);
}
tg_ghost_T3D.mul(VPTG_ghost_T3D_noninverted, tg_ghost_T3D);
tg_ghost_T3D.setTranslation(tg_ghost_vec3f);
tg_ghost.setTransform(tg_ghost_T3D);
VPTG_ghost_T3D = new Transform3D();
// (super.ViewerTG).getTransform(VPTG_ghost_T3D);
ViewerTG.getTransform(VPTG_ghost_T3D);
Vector3f VPTG_ghost_vec3f = new Vector3f();
VPTG_ghost_T3D.get(VPTG_ghost_vec3f);
Vector3f temp_vec3f = new Vector3f();
temp_vec3f.x = VPTG_ghost_vec3f.x - tg_ghost_vec3f.x;
temp_vec3f.y = VPTG_ghost_vec3f.y - tg_ghost_vec3f.y;
temp_vec3f.z = VPTG_ghost_vec3f.z - tg_ghost_vec3f.z;
VPTG_ghost_T3D.setTranslation(temp_vec3f);
VPTG_ghost_T3D.mul(VPTG_ghost_T3D_inverted, VPTG_ghost_T3D);
if (invert) {
VPTG_ghost_T3D.mul(VPTG_ghost_T3D, orbitT3D);
} else {
VPTG_ghost_T3D.mul(orbitT3D, VPTG_ghost_T3D);
}
VPTG_ghost_T3D.mul(VPTG_ghost_T3D_noninverted, VPTG_ghost_T3D);
VPTG_ghost_T3D.get(temp_vec3f);
temp_vec3f.x = temp_vec3f.x + tg_ghost_vec3f.x;
temp_vec3f.y = temp_vec3f.y + tg_ghost_vec3f.y;
temp_vec3f.z = temp_vec3f.z + tg_ghost_vec3f.z;
VPTG_ghost_T3D.setTranslation(temp_vec3f);
// (super.ViewerTG).setTransform(VPTG_ghost_T3D);
ViewerTG.setTransform(VPTG_ghost_T3D);
transformChanged(currXform);
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.ORBIT, 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();
}
}
}
}
}
wakeupOn(mouseCriterion);
}
Aggregations