Search in sources :

Example 6 with AWTEvent

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

Example 7 with AWTEvent

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

Example 8 with AWTEvent

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

Example 9 with AWTEvent

use of java.awt.AWTEvent in project vcell by virtualcell.

the class DocumentEditor method initialize.

/**
 * Initialize the class.
 */
private void initialize() {
    try {
        setLayout(new BorderLayout());
        getToolkit().addAWTEventListener(new AWTEventListener() {

            public void eventDispatched(AWTEvent event) {
                try {
                    switch(event.getID()) {
                        case KeyEvent.KEY_RELEASED:
                            documentEditor_eventDispatched(event);
                            break;
                        case MouseEvent.MOUSE_RELEASED:
                            documentEditor_eventDispatched(event);
                            break;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                // consume any exception ... don't screw up the swing event queue.
                }
            }
        }, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
        documentEditorTree = new javax.swing.JTree() {

            @Override
            public boolean isPathEditable(TreePath path) {
                Object object = path.getLastPathComponent();
                return (object instanceof BioModelNode) && (((BioModelNode) object).getUserObject() instanceof SimulationContext);
            }
        };
        documentEditorTree.setEditable(true);
        documentEditorTree.setLargeModel(true);
        documentEditorTreeCellEditor = new DocumentEditorTreeCellEditor(documentEditorTree);
        documentEditorTree.setCellEditor(documentEditorTreeCellEditor);
        documentEditorTree.setName("bioModelEditorTree");
        ToolTipManager.sharedInstance().registerComponent(documentEditorTree);
        int rowHeight = documentEditorTree.getRowHeight();
        if (rowHeight < 10) {
            rowHeight = 20;
        }
        documentEditorTree.setRowHeight(rowHeight + 2);
        documentEditorTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        JSplitPane leftSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        databaseWindowPanel = new DatabaseWindowPanel(false, false);
        leftBottomTabbedPane = new JTabbedPaneEnhanced();
        leftBottomTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        leftBottomTabbedPane.addTab("VCell DB", databaseWindowPanel);
        JScrollPane treePanel = new javax.swing.JScrollPane(documentEditorTree);
        leftSplitPane.setTopComponent(treePanel);
        leftBottomTabbedPane.setMinimumSize(new java.awt.Dimension(198, 148));
        leftSplitPane.setBottomComponent(leftBottomTabbedPane);
        leftSplitPane.setResizeWeight(0.5);
        leftSplitPane.setDividerLocation(300);
        leftSplitPane.setDividerSize(8);
        leftSplitPane.setOneTouchExpandable(true);
        rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        rightSplitPane.setResizeWeight(0.7);
        rightSplitPane.setDividerLocation(400);
        rightSplitPane.setDividerSize(8);
        rightSplitPane.setOneTouchExpandable(true);
        rightBottomEmptyPanel = new JPanel(new GridBagLayout());
        rightBottomEmptyPanel.setBackground(Color.white);
        rightBottomEmptyPanel.setName("ObjectProperties");
        treeNodeDescriptionLabel = new JLabel(generalTreeNodeDescription);
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.insets = new Insets(10, 10, 4, 4);
        gbc.gridy = 0;
        gbc.weighty = 1.0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.PAGE_START;
        rightBottomEmptyPanel.add(treeNodeDescriptionLabel, gbc);
        rightBottomEmptyAnnotationsPanel = new JPanel(new GridBagLayout());
        rightBottomEmptyAnnotationsPanel.setBackground(Color.white);
        rightBottomEmptyAnnotationsPanel.setName("Annotations");
        treeNodeDescriptionLabel2 = new JLabel(generalTreeNodeDescription2);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.insets = new Insets(10, 10, 4, 4);
        gbc.gridy = 0;
        gbc.weighty = 1.0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.PAGE_START;
        rightBottomEmptyAnnotationsPanel.add(treeNodeDescriptionLabel2, gbc);
        issuePanel = new IssuePanel();
        rightBottomTabbedPane = new JTabbedPaneEnhanced();
        rightBottomTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        rightBottomEmptyPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
        rightBottomEmptyAnnotationsPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
        issuePanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
        rightBottomTabbedPane.addTab(TAB_TITLE_OBJECT_PROPERTIES, rightBottomEmptyPanel);
        rightBottomTabbedPane.addTab(TAB_TITLE_ANNOTATIONS, rightBottomEmptyAnnotationsPanel);
        rightBottomTabbedPane.addTab(TAB_TITLE_PROBLEMS, issuePanel);
        rightBottomTabbedPane.setMinimumSize(new java.awt.Dimension(198, 148));
        rightSplitPane.setBottomComponent(rightBottomTabbedPane);
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        splitPane.setDividerLocation(270);
        splitPane.setOneTouchExpandable(true);
        splitPane.setResizeWeight(0.3);
        splitPane.setDividerSize(8);
        splitPane.setLeftComponent(leftSplitPane);
        splitPane.setRightComponent(rightSplitPane);
        add(splitPane, BorderLayout.CENTER);
        issueManager.addIssueEventListener(eventHandler);
        selectionManager.addPropertyChangeListener(eventHandler);
        databaseWindowPanel.setSelectionManager(selectionManager);
        documentEditorTree.addTreeSelectionListener(eventHandler);
        documentEditorTree.addMouseListener(eventHandler);
        bioModelMetaDataPanel = new BioModelMetaDataPanel();
        bioModelMetaDataPanel.setSelectionManager(selectionManager);
        mathModelMetaDataPanel = new MathModelMetaDataPanel();
        mathModelMetaDataPanel.setSelectionManager(selectionManager);
        geometryMetaDataPanel = new GeometryMetaDataPanel();
        geometryMetaDataPanel.setSelectionManager(selectionManager);
        issuePanel.setSelectionManager(selectionManager);
        issuePanel.setIssueManager(issueManager);
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) AWTEventListener(java.awt.event.AWTEventListener) GeometryMetaDataPanel(cbit.vcell.desktop.GeometryMetaDataPanel) BioModelNode(cbit.vcell.desktop.BioModelNode) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) BorderLayout(java.awt.BorderLayout) MathModelMetaDataPanel(cbit.vcell.desktop.MathModelMetaDataPanel) AWTEvent(java.awt.AWTEvent) JScrollPane(javax.swing.JScrollPane) BioModelMetaDataPanel(cbit.vcell.desktop.BioModelMetaDataPanel) JLabel(javax.swing.JLabel) JTree(javax.swing.JTree) SimulationContext(cbit.vcell.mapping.SimulationContext) Point(java.awt.Point) TreePath(javax.swing.tree.TreePath) DatabaseWindowPanel(cbit.vcell.client.desktop.DatabaseWindowPanel) JSplitPane(javax.swing.JSplitPane)

Example 10 with AWTEvent

use of java.awt.AWTEvent in project SnapKit by reportmill.

the class SwingEvent method getTypeImpl.

/**
 * Computes the event type from EventObject.
 */
protected Type getTypeImpl() {
    Object event = getEvent();
    int id = event instanceof AWTEvent ? ((AWTEvent) event).getID() : 0;
    switch(id) {
        case ActionEvent.ACTION_PERFORMED:
            return Type.Action;
        case MouseEvent.MOUSE_PRESSED:
            return Type.MousePress;
        case MouseEvent.MOUSE_DRAGGED:
            return Type.MouseDrag;
        case MouseEvent.MOUSE_RELEASED:
            return Type.MouseRelease;
        case MouseEvent.MOUSE_ENTERED:
            return Type.MouseEnter;
        case MouseEvent.MOUSE_MOVED:
            return Type.MouseMove;
        case MouseEvent.MOUSE_EXITED:
            return Type.MouseExit;
        case MouseEvent.MOUSE_WHEEL:
            return Type.Scroll;
        case KeyEvent.KEY_PRESSED:
            return Type.KeyPress;
        case KeyEvent.KEY_RELEASED:
            return Type.KeyRelease;
        case KeyEvent.KEY_TYPED:
            return Type.KeyType;
        case WindowEvent.WINDOW_ACTIVATED:
            return Type.WinActivate;
        case WindowEvent.WINDOW_CLOSING:
            return Type.WinClose;
        case WindowEvent.WINDOW_DEACTIVATED:
            return Type.WinDeactivate;
        case WindowEvent.WINDOW_OPENED:
            return Type.WinOpen;
    }
    if (event instanceof DropTargetDropEvent)
        return Type.DragDrop;
    if (event instanceof DragGestureEvent)
        return Type.DragGesture;
    return null;
}
Also used : AWTEvent(java.awt.AWTEvent) Point(java.awt.Point)

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