Example usage for java.awt.event MouseEvent getModifiers

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

Introduction

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

Prototype

@Deprecated(since = "9")
public int getModifiers() 

Source Link

Document

Returns the modifier mask for this event.

Usage

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseClicked(MouseEvent e) {
    if (e.getSource() instanceof ChartPanel && ((e.getButton() == MouseEvent.BUTTON2)
            || (e.getButton() == MouseEvent.BUTTON1) && ((e.getModifiers() & InputEvent.CTRL_MASK) != 0))) {
        CenterZoomNumberAxis czna = (CenterZoomNumberAxis) _cp.getChart().getXYPlot().getDomainAxis();
        NumberAxis range = (NumberAxis) _cp.getChart().getXYPlot().getRangeAxis();
        Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
        double y1 = czna.getLowerBound();
        double y2 = czna.getUpperBound();
        double x1 = screenDataArea.getX();
        double x2 = x1 + screenDataArea.getWidth();
        double transformedx = (((y2 - y1) / (x2 - x1)) * (e.getX() - x1)) + y1;
        MRMDialog mrmd = (MRMDialog) MRMAncestor();
        PeaksTableModel model = (PeaksTableModel) mrmd.peaksTable.getModel();
        MRMTransition mrt = mrmd.transitionOnPlot;
        mrt.setCalcXatMaxYAllDaughters(transformedx);
        mrt.setCalcMaxYAllDaughters(/* w  w  w  .j  a v  a  2  s  .  c o  m*/
                range.getLowerBound() + 0.95 * (range.getUpperBound() - range.getLowerBound()));
        model.setValueAt(new Float(mrt.getCalcXatMaxYAllDaughters()), mrt.getTableRow(),
                MRMDialog.peaksData.MidTime.colno);
        for (MRMDaughter d : mrt.getDaughters().values()) {
            model.setValueAt(new Float(mrt.getCalcXatMaxYAllDaughters()), d.getElutionDataTableRow(),
                    MRMDialog.peaksData.MidTime.colno);
        }
        mrmd.updateChartsAndFields(false);
    }
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        _cp.mouseClicked(e);
    } else {
        _cp.mouseClicked(e);
    }
}

From source file:graph.eventhandlers.MyEditingGraphMousePlugin.java

/**
 * overrided to be more flexible, and pass events with key combinations. The
 * default responds to both ButtonOne and ButtonOne+Shift
 */// w w w  .  ja  va  2s. c om
@Override
public boolean checkModifiers(MouseEvent e) {
    return (e.getModifiers() & modifiers) != 0;
}

From source file:ListProperties.java

public void mouseClicked(MouseEvent mouseEvent) {
    TableColumnModel columnModel = table.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(mouseEvent.getX());
    int column = table.convertColumnIndexToModel(viewColumn);
    if (mouseEvent.getClickCount() == 1 && column != -1) {
        System.out.println("Sorting ...");
        int shiftPressed = (mouseEvent.getModifiers() & InputEvent.SHIFT_MASK);
        boolean ascending = (shiftPressed == 0);
        sorter.sortByColumn(column, ascending);
    }/*  w ww.j  av a2 s  . c  o  m*/
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java

public void onMouseClicked(MouseEvent e) {

    // find peak under mouse
    if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1
            && (e.getModifiers() & MOD_MASK) == e.BUTTON3_MASK) {
        // open popup
        createPopupMenu().show(theChartPanel, e.getX(), e.getY());
    }//  w  w  w  .j a  va  2  s .c  o m
}

From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java

public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row,
        int column) {
    ActionIconAndNameHolder in = (ActionIconAndNameHolder) value;
    action = in.getAction();//from ww  w . j  a  va 2s. com

    final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value,
            isSelected, true, row, column);
    component.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if (actionRegion == null) {
                    component_mousePressed(e);
                } else {
                    if (actionRegion.contains(e.getPoint())) {
                        component_mousePressed(e);
                    } else {
                        if (e.getClickCount() >= 2) {
                            Toolkit.getDefaultToolkit().getSystemEventQueue()
                                    .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(),
                                            e.getModifiers(), component.getX() + e.getX(),
                                            component.getY() + e.getY(), e.getClickCount(), false));
                        }
                    }
                }
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                Toolkit.getDefaultToolkit().getSystemEventQueue()
                        .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(),
                                component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(),
                                true));
            }
        }
    });

    return component;
}

From source file:org.adempiere.apps.graph.PerformanceIndicator.java

/**
 * Notifies all listeners that have registered interest for
 * notification on this event type.  The event instance 
 * is lazily created using the <code>event</code> 
 * parameter.//ww  w.j  a va  2 s .c  o  m
 *
 * @param event  the <code>ActionEvent</code> object
 * @see EventListenerList
 */
protected void fireActionPerformed(MouseEvent event) {
    // Guaranteed to return a non-null array
    ActionListener[] listeners = getActionListeners();
    ActionEvent e = null;
    // Process the listeners first to last
    for (int i = 0; i < listeners.length; i++) {
        //   Lazily create the event:
        if (e == null)
            e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "pi", event.getWhen(),
                    event.getModifiers());
        listeners[i].actionPerformed(e);
    }
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java

public void onMousePressed(MouseEvent e) {
    was_moving = is_moving;//w  ww  .  j a v a2 s  . c  o m
    if (e.getButton() == e.BUTTON1 && theChartPanel.getScreenDataArea().contains(e.getPoint())) {
        mouse_start_point = e.getPoint();
        if ((e.getModifiers() & MOD_MASK) == e.SHIFT_MASK)
            onActivateMoving();
    } else
        mouse_start_point = null;
}

From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java

private void dispacciaEventoDrag(Component com, MouseEvent e, Point point, boolean draggedEvent) {
    Point componentPoint = SwingUtilities.convertPoint(component, e.getPoint(), com);
    if (com != null) {
        if (com instanceof JTree) {
            TreePath treePath = ((JTree) com).getPathForLocation(componentPoint.x, componentPoint.y);
            if (treePath == null || draggedEvent) {
                component.updateUI();/*from   w  w  w .  j a v a2 s .  c  o m*/
                return;
            }
        }
        if ((!(com instanceof JScrollBar) && (tmp12 instanceof JScrollBar))) {
            jLayeredPane.moveToFront(component);
            component.updateUI();
            return;
        }

        com.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x,
                componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
        jLayeredPane.moveToFront(component);
        component.updateUI();

    }
    jLayeredPane.moveToFront(component);
    component.updateUI();
}

From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java

private void dispacciaEvento(Component com, MouseEvent e, Point point, boolean draggedEvent) {
    if (com == null) {
        com = SwingUtilities.getDeepestComponentAt(pannelloPrincipale, point.x, point.y);
    }//from  w  w  w  . j  a  va  2 s.  com
    Point componentPoint = SwingUtilities.convertPoint(component, e.getPoint(), com);
    if (com != null) {
        if (com instanceof JTree) {
            TreePath treePath = ((JTree) com).getPathForLocation(componentPoint.x, componentPoint.y);
            if (treePath == null || draggedEvent) {
                jLayeredPane.moveToFront(component);
                component.updateUI();
                if (e.getButton() == MouseEvent.BUTTON3) {
                    return;
                }
            }
        }
        com.dispatchEvent(new MouseEvent(com, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x,
                componentPoint.y, e.getClickCount(), e.isPopupTrigger()));

        jLayeredPane.moveToFront(component);
        component.updateUI();

    }
    jLayeredPane.moveToFront(component);
    component.updateUI();

}

From source file:components.GlassPaneDemo.java

private void redispatchMouseEvent(MouseEvent e, boolean repaint) {
    Point glassPanePoint = e.getPoint();
    Container container = contentPane;
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);
    if (containerPoint.y < 0) { //we're not in the content pane
        if (containerPoint.y + menuBar.getHeight() >= 0) {
            //The mouse event is over the menu bar.
            //Could handle specially.
        } else {/*  w w  w. ja v  a2s  .co m*/
            //The mouse event is over non-system window 
            //decorations, such as the ones provided by
            //the Java look and feel.
            //Could handle specially.
        }
    } else {
        //The mouse event is probably over the content pane.
        //Find out exactly which component it's over.  
        Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x,
                containerPoint.y);

        if ((component != null) && (component.equals(liveButton))) {
            //Forward events over the check box.
            Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component);
            component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(),
                    componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
        }
    }

    //Update the glass pane if requested.
    if (repaint) {
        glassPane.setPoint(glassPanePoint);
        glassPane.repaint();
    }
}