Search in sources :

Example 1 with LeftButtonMode

use of ffx.ui.GraphicsCanvas.LeftButtonMode 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);
}
Also used : MouseEvent(java.awt.event.MouseEvent) AWTEvent(java.awt.AWTEvent) WakeupOnAWTEvent(javax.media.j3d.WakeupOnAWTEvent) WakeupOnAWTEvent(javax.media.j3d.WakeupOnAWTEvent) LeftButtonMode(ffx.ui.GraphicsCanvas.LeftButtonMode) WakeupCriterion(javax.media.j3d.WakeupCriterion)

Aggregations

LeftButtonMode (ffx.ui.GraphicsCanvas.LeftButtonMode)1 AWTEvent (java.awt.AWTEvent)1 MouseEvent (java.awt.event.MouseEvent)1 WakeupCriterion (javax.media.j3d.WakeupCriterion)1 WakeupOnAWTEvent (javax.media.j3d.WakeupOnAWTEvent)1