Example usage for java.awt.event MouseEvent getX

List of usage examples for java.awt.event MouseEvent getX

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getX.

Prototype

public int getX() 

Source Link

Document

Returns the horizontal x position of the event relative to the source component.

Usage

From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java

/**
 * The mousePressed method of the MouseListener interface.
 * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
 * //  ww w  .j  av  a 2 s  .  com
 * @param event The event which triggered this action.
 */
public void mousePressed(MouseEvent event) {
    E edge = this.getPickSupport().getEdge(this.getGraphLayout(), event.getX(), event.getY());
    V vertex = this.getPickSupport().getVertex(this.getGraphLayout(), event.getX(), event.getY());
    if (edge != null && vertex == null) {
        this.fireGraphMouseEdgePressedEvent(edge, event);
    }
}

From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java

/**
 * The mouseReleased method of the MouseListener interface.
 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
 * /* www  . j  av a2s. c  o  m*/
 * @param event The event which triggered this action.
 */
public void mouseReleased(MouseEvent event) {
    E edge = this.getPickSupport().getEdge(this.getGraphLayout(), event.getX(), event.getY());
    V vertex = this.getPickSupport().getVertex(this.getGraphLayout(), event.getX(), event.getY());
    if (edge != null && vertex == null) {
        this.fireGraphMouseEdgeReleasedEvent(edge, event);
    }
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

private void procPressed(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;
    XWindow.sprite.hot.x = x;/*w w w.ja v a  2 s .  c om*/
    XWindow.sprite.hot.y = y;
    int mod = e.getModifiers();
    if (mod == 0) {
        mod |= InputEvent.BUTTON1_MASK;
    } // ?????

    int state = 0;
    int detail = 1;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        detail = 1;
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        detail = 2;
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        detail = 3;
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;

    Event.filters[Event.MotionNotify] = Event.PointerMotionMask | Event.ButtonMotionMask
            | ((Event.Button1Mask >> 1) << detail);

    event.mkButtonPress(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1);

    try {
        if (XWindow.grab == null) {
            if (XWindow.checkDeviceGrabs(event, 0, 1)) {
                return;
            }
        }
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
    }
    //    if((mod & InputEvent.SHIFT_MASK)!=0) state|=1;
    //    if((mod & InputEvent.CTRL_MASK)!=0) state|=4;
    // alt -> state|=8;

    XWindow.sprite.hot.state = state;
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseMoved(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;//w w  w  .  ja v  a  2s. c  om
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;

    px = x;
    py = y;

    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = state;

    event.mkMotionNotify(0, window.screen.rootId, window.id, 0, x, y, x - window.x, y - window.y, state, 1);

    try {
        if (!XWindow.checkMotion(event, window)) {
            return;
        }
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

private void procReleased(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;/*  www .  j  a  v a2 s  .c  om*/
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    int detail = 0;

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
        detail = 1;
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
        detail = 2;
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
        detail = 3;
    }
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = 0; // ?????
    Event.filters[Event.MotionNotify] = Event.PointerMotionMask/*|
                                                               ((Event.Button1Mask>>1)<<detail)*/;
    event.mkButtonRelease(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, true, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
    XWindow.grab = null;
}

From source file:mulavito.gui.control.AbstractPopupMousePlugin.java

/**
 * Reduced functionality of super class method and extended by own
 * content-aware editing.//from w w w .  j av  a2  s . co m
 */
@SuppressWarnings("unchecked")
@Override
protected final void handlePopup(final MouseEvent e) {
    if (checkModifiers(e)) {
        final LV vv = (LV) e.getSource();
        final Layout<V, E> layout = vv.getGraphLayout();
        final L graph = (L) layout.getGraph();
        final Point p = e.getPoint();

        final List<V> sel_vertices = getSelectedVertices();
        final List<E> sel_edges = getSelectedEdges();

        GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
            E edge = pickSupport.getEdge(layout, p.getX(), p.getY());

            if (vertex != null && !sel_vertices.contains(vertex))
                sel_vertices.add(vertex);
            if (edge != null && !sel_edges.contains(edge))
                sel_edges.add(edge);
        }

        popup.removeAll();
        if (sel_vertices.size() > 0)
            createVertexMenuEntries(p, graph, vv, sel_vertices);
        else if (sel_edges.size() > 0)
            createEdgeMenuEntries(p, graph, vv, sel_edges);
        else
            createGeneralMenuEntries(p, graph, vv);

        if (popup.getComponentCount() > 0)
            popup.show(vv, e.getX(), e.getY());
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

private void procPressed(MouseEvent e) {
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;
    oldWindowx = window.x;// ww w  .j a  v  a 2s  .c om
    oldWindowy = window.y;
    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;
    int mod = e.getModifiers();
    if (mod == 0) {
        mod |= InputEvent.BUTTON1_MASK;
    } // ?????

    int state = 0;
    int detail = 1;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        detail = 1;
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        detail = 2;
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        detail = 3;
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;

    Event.filters[Event.MotionNotify] = Event.PointerMotionMask | Event.ButtonMotionMask
            | ((Event.Button1Mask >> 1) << detail);

    event.mkButtonPress(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1);

    try {
        if (XWindow.grab == null) {
            if (XWindow.checkDeviceGrabs(event, 0, 1)) {
                return;
            }
        }
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
    }
    //    if((mod & InputEvent.SHIFT_MASK)!=0) state|=1;
    //    if((mod & InputEvent.CTRL_MASK)!=0) state|=4;
    // alt -> state|=8;

    XWindow.sprite.hot.state = state;
}

From source file:brainflow.app.toplevel.BrainFlow.java

private void showActionMenu(MouseEvent e) {
    Component c = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
    java.util.List<Action> actionList = new ArrayList<Action>();
    while (true) {
        if (c instanceof IActionProvider) {
            IActionProvider provider = (IActionProvider) c;
            provider.addActions(e, actionList);
        } else if (c instanceof JComponent) {
            JComponent jc = (JComponent) c;

            Object provider = jc.getClientProperty(IActionProvider.KEY);
            if (provider != null) {
                ((IActionProvider) provider).addActions(e, actionList);
            }//  ww w .  j a va 2  s.  c o  m
        }

        Component p = c.getParent();
        if (p != null) {
            c = p;
        } else {
            break;
        }

    }

    if (actionList.size() > 0) {
        createPopup(actionList).setVisible(true);
    }

}

From source file:com.mirth.connect.client.ui.DashboardPanel.java

/**
 * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the
 * rows if no row was selected.//from w  w  w  .j a  v  a2s .co  m
 */
private void checkSelectionAndPopupMenu(MouseEvent event) {
    TreePath path = dashboardTable.getPathForLocation(event.getX(), event.getY());

    /*
     * On mouse events we don't need to update the dashboard panel plugins. They will already
     * have been updated because of the ListSelectionEvent, and multiple mouse events will enter
     * here (as many as three, one pressed and two released) so we would basically be doing four
     * times the work.
     */
    if (path == null) {
        deselectRows(false);
    } else {
        updatePopupMenu(false);
    }

    if (event.isPopupTrigger()) {
        TreeSelectionModel selectionModel = dashboardTable.getTreeSelectionModel();

        if (!selectionModel.isPathSelected(path)) {
            deselectRows(false);
            selectionModel.addSelectionPath(path);
        }

        parent.dashboardPopupMenu.show(event.getComponent(), event.getX(), event.getY());
    }
}

From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java

/**
 * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the
 * rows if no row was selected./*from   w ww  .j  a va2  s  . co  m*/
 */
private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) {
    int row = eventTable.rowAtPoint(new Point(evt.getX(), evt.getY()));
    if (row == -1) {
        deselectRows();
    }

    if (evt.isPopupTrigger()) {
        if (row != -1) {
            eventTable.setRowSelectionInterval(row, row);
        }
        parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}