Search in sources :

Example 16 with AWTEvent

use of java.awt.AWTEvent in project JMRI by JMRI.

the class Apps3 method splash.

protected static void splash(boolean show, boolean debug) {
    if (debugListener == null && debug) {
        // set a global listener for debug options
        debugFired = false;
        debugListener = new AWTEventListener() {

            @Override
            @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "debugmsg write is semi-global")
            public void eventDispatched(AWTEvent e) {
                if (!debugFired) {
                    /*We set the debugmsg flag on the first instance of the user pressing any button
                         and the if the debugFired hasn't been set, this allows us to ensure that we don't
                         miss the user pressing F8, while we are checking*/
                    debugmsg = true;
                    if (e.getID() == KeyEvent.KEY_PRESSED && e instanceof KeyEvent && ((KeyEvent) e).getKeyCode() == 119) {
                        startupDebug();
                    } else {
                        debugmsg = false;
                    }
                }
            }
        };
        Toolkit.getDefaultToolkit().addAWTEventListener(debugListener, AWTEvent.KEY_EVENT_MASK);
    }
    // bring up splash window for startup
    if (sp == null) {
        sp = new SplashWindow((debug) ? splashDebugMsg() : null);
    }
    sp.setVisible(show);
    if (!show) {
        sp.dispose();
        Toolkit.getDefaultToolkit().removeAWTEventListener(debugListener);
        debugListener = null;
        sp = null;
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) AWTEventListener(java.awt.event.AWTEventListener) SplashWindow(apps.SplashWindow) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) AWTEvent(java.awt.AWTEvent)

Example 17 with AWTEvent

use of java.awt.AWTEvent in project sling by apache.

the class RequestAnalyzerWebConsole method dispose.

void dispose() {
    if (this.frame != null) {
        MainFrame frame = this.frame;
        this.frame = null;
        AWTEvent e = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
    }
}
Also used : WindowEvent(java.awt.event.WindowEvent) AWTEvent(java.awt.AWTEvent) MainFrame(org.apache.sling.reqanalyzer.impl.gui.MainFrame)

Example 18 with AWTEvent

use of java.awt.AWTEvent in project jdk8u_jdk by JetBrains.

the class JFileChooser method fireActionPerformed.

/**
     * Notifies all listeners that have registered interest for
     * notification on this event type. The event instance
     * is lazily created using the <code>command</code> parameter.
     *
     * @see EventListenerList
     */
protected void fireActionPerformed(String command) {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    long mostRecentEventTime = EventQueue.getMostRecentEventTime();
    int modifiers = 0;
    AWTEvent currentEvent = EventQueue.getCurrentEvent();
    if (currentEvent instanceof InputEvent) {
        modifiers = ((InputEvent) currentEvent).getModifiers();
    } else if (currentEvent instanceof ActionEvent) {
        modifiers = ((ActionEvent) currentEvent).getModifiers();
    }
    ActionEvent e = null;
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            // Lazily create the event:
            if (e == null) {
                e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, command, mostRecentEventTime, modifiers);
            }
            ((ActionListener) listeners[i + 1]).actionPerformed(e);
        }
    }
}
Also used : AWTEvent(java.awt.AWTEvent)

Example 19 with AWTEvent

use of java.awt.AWTEvent 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)

Example 20 with AWTEvent

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

Aggregations

AWTEvent (java.awt.AWTEvent)25 MouseEvent (java.awt.event.MouseEvent)8 WakeupCriterion (javax.media.j3d.WakeupCriterion)8 WakeupOnAWTEvent (javax.media.j3d.WakeupOnAWTEvent)8 AWTEventListener (java.awt.event.AWTEventListener)6 ActionEvent (java.awt.event.ActionEvent)5 Component (java.awt.Component)4 InputEvent (java.awt.event.InputEvent)4 ActionListener (java.awt.event.ActionListener)3 ActiveEvent (java.awt.ActiveEvent)2 EventQueue (java.awt.EventQueue)2 Point (java.awt.Point)2 Transform3D (javax.media.j3d.Transform3D)2 JButton (javax.swing.JButton)2 SplashWindow (apps.SplashWindow)1 DatabaseWindowPanel (cbit.vcell.client.desktop.DatabaseWindowPanel)1 BioModelMetaDataPanel (cbit.vcell.desktop.BioModelMetaDataPanel)1 BioModelNode (cbit.vcell.desktop.BioModelNode)1 GeometryMetaDataPanel (cbit.vcell.desktop.GeometryMetaDataPanel)1 MathModelMetaDataPanel (cbit.vcell.desktop.MathModelMetaDataPanel)1