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:base.BasePlayer.BedCanvas.java

@SuppressWarnings("unchecked")
public void mousePressed(MouseEvent event) {
    resize = false;/*from  w w  w.ja v a  2  s .  c om*/
    pressY = event.getY();
    mouseDrag = true;

    this.requestFocus();
    Main.drawCanvas.pressX = event.getX();

    Main.drawCanvas.tempDrag = Main.drawCanvas.pressX;
    switch (event.getModifiers()) {

    case InputEvent.BUTTON1_MASK: {

        //   if(this.settingsbutton > -1) {
        if (sidebar && this.hoverIndex < bedTrack.size()
                && this.sideMouseRect.intersects(bedTrack.get(this.hoverIndex).settingsButton)) {

            this.bedTrack.get(this.hoverIndex).getPopup().show(this, mouseX, mouseY);
            //settingsbutton = -1;
            break;
        }

        //}
        if (resizer) {
            preresize = mouseY;
            preresizer = this.trackDivider.get(this.resizeDivider) * this.getHeight();
            tempDivider = (ArrayList<Double>) trackDivider.clone();
        }

        break;
    }
    case InputEvent.BUTTON3_MASK: {

        this.zoomDrag = false;
        if (sidebar) {
            this.bedTrack.get(hoverIndex).getPopup().show(this, mouseX, mouseY);
        }

    }
    }

}

From source file:com.actelion.research.table.view.JVisualization.java

public void mousePressed(MouseEvent e) {
    mMouseX1 = mMouseX2 = e.getX();// w w  w  . j  a  va2s.  co m
    mMouseY1 = mMouseY2 = e.getY();
    mMouseIsDown = true;

    if (System.getProperty("touch") != null) {
        new Thread() {
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ie) {
                }

                if (Math.abs(mMouseX2 - mMouseX1) < 5 && Math.abs(mMouseY2 - mMouseY1) < 5 && mMouseIsDown) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            activateTouchFunction();
                        }
                    });
                }
            }
        }.start();
    }

    mRectangleSelecting = false;
    mLassoSelecting = false;
    if (!handlePopupTrigger(e) && (e.getModifiers() & InputEvent.BUTTON3_MASK) == 0) {
        mAddingToSelection = e.isShiftDown();
        if (e.isAltDown())
            mRectangleSelecting = true;
        else {
            mLassoSelecting = true;
            mLassoRegion = new Polygon();
            mLassoRegion.addPoint(mMouseX1, mMouseY1);
            mLassoRegion.addPoint(mMouseX1, mMouseY1);
        }
    }
}

From source file:org.forester.archaeopteryx.TreePanel.java

final void mouseClicked(final MouseEvent e) {
    if (getOptions().isShowOverview() && isOvOn() && isInOv()) {
        final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
        final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
        double x = (e.getX() - getVisibleRect().x - getOvXPosition() - getOvRectangle().getWidth() / 2.0)
                * w_ratio;// w  w  w  . ja  v a2s.c  o  m
        double y = (e.getY() - getVisibleRect().y - getOvYPosition() - getOvRectangle().getHeight() / 2.0)
                * h_ratio;
        if (x < 0) {
            x = 0;
        }
        if (y < 0) {
            y = 0;
        }
        final double max_x = getWidth() - getVisibleRect().width;
        final double max_y = getHeight() - getVisibleRect().height;
        if (x > max_x) {
            x = max_x;
        }
        if (y > max_y) {
            y = max_y;
        }
        getMainPanel().getCurrentScrollPane().getViewport()
                .setViewPosition(new Point(ForesterUtil.roundToInt(x), ForesterUtil.roundToInt(y)));
        setInOvRect(true);
        repaint();
    } else if (findNode(e.getX(), e.getY()) != null) {

        if ((_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_BRANCH_DATA)
                || (_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_DATA)) {
            _control_panel.setActionWhenNodeClicked(NodeClickAction.SHOW_DATA);
        }
        //System.out.println(_control_panel.getActionWhenNodeClicked());
        final PhylogenyNode node = findNode(e.getX(), e.getY());
        if (node != null) {
            if (!node.isRoot() && node.getParent().isCollapse()) {
                return;
            }
            _highlight_node = node;
            // Check if shift key is down
            if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) {
                // Yes, so add to _found_nodes
                if (getFoundNodes() == null) {
                    setFoundNodes(new HashSet<PhylogenyNode>());
                }
                getFoundNodes().add(node);
                // Check if control key is down
            } else if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
                // Yes, so pop-up menu
                displayNodePopupMenu(node, e.getX(), e.getY());
                // Handle unadorned click
            } else {
                // Check for right mouse button
                if (e.getModifiers() == 4) {
                    displayNodePopupMenu(node, e.getX(), e.getY());
                } else {
                    // if not in _found_nodes, clear _found_nodes

                    if (_control_panel.getActionWhenNodeClicked().equals(NodeClickAction.REROOT)) {
                        // no rerooting for nodes anymore
                    } else {
                        handleClickToAction(_control_panel.getActionWhenNodeClicked(), node);
                    }

                }
            }
        }
    }

    else if (findBranch(e.getX(), e.getY()) != null) {
        final PhylogenyNode node = findBranch(e.getX(), e.getY());
        // Check for right mouse button
        if (e.getModifiers() == 4) {
            displayBranchPopupMenu(node, e.getX(), e.getY());
        } else {
            if ((_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_BRANCH_DATA)
                    || (_control_panel.getActionWhenNodeClicked() == NodeClickAction.SHOW_DATA)) {
                _control_panel.setActionWhenNodeClicked(NodeClickAction.SHOW_BRANCH_DATA);
            }
            handleClickToAction(_control_panel.getActionWhenNodeClicked(), node);
        }
    }

    else {

        // no node was clicked
        _highlight_node = null;

    }
    repaint();
}

From source file:base.BasePlayer.Main.java

@Override
public void mousePressed(MouseEvent event) {
    //if(Logo.frame.isVisible()) {
    //   frame.requestFocus();
    //   }/*from w ww .j  a  va  2 s.c  o m*/
    //   Logo.frame.setVisible(false);
    mouseX = event.getX();

    if (event.getSource() == refDropdown) {
        switch (event.getModifiers()) {
        case InputEvent.BUTTON1_MASK: {
            if (Main.genomehash.size() == 0) {
                if (AddGenome.frame == null) {
                    AddGenome.createAndShowGUI();
                }
                AddGenome.frame.setTitle("Add new genome");
                AddGenome.annotation = false;
                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);

                AddGenome.frame.setState(JFrame.NORMAL);
            }
            rightclick = false;
            break;
        }
        case InputEvent.BUTTON3_MASK: {
            rightclick = true;
            break;
        }
        }
    } else if (event.getSource() == geneDropdown) {
        switch (event.getModifiers()) {
        case InputEvent.BUTTON1_MASK: {
            if (Main.genomehash.size() == 0) {
                if (AddGenome.frame == null) {
                    AddGenome.createAndShowGUI();
                }
                AddGenome.frame.setTitle("Add new genome");
                AddGenome.annotation = false;
                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);

                AddGenome.frame.setState(JFrame.NORMAL);
            }
            rightclick = false;
            break;
        }
        case InputEvent.BUTTON3_MASK: {
            rightclick = true;
            break;
        }
        }
    } else if (event.getSource() == chromlabel) {
        chromosomeDropdown.showPopup();

    }

    else if (event.getSource() == splitPaneDivider) {
        Main.vardivider = bedCanvas.nodeImage.getHeight() / (double) varPaneDivider.getY();

        //      Main.bedCanvas.resize = true;
    } else if (event.getSource() == varPaneDivider) {
        //      Main.bedCanvas.resize = true;         
        Main.vardivider = bedCanvas.nodeImage.getHeight() / (double) varPaneDivider.getY();

    } else if (event.getSource() == filemenu) {
        /*if(!filemenu.isSelected()){            
           filemenu.doClick();         
        }
        */
    } else if (event.getSource() == toolmenu) {
        /*if(!toolmenu.isSelected()){            
           toolmenu.doClick();         
        }*/

    } else if (drawCanvas.loadingtext.equals("note")) {
        Main.drawCanvas.loadingtext = "";
        Main.drawCanvas.ready("note");

    }

    else if (event.getSource() == drawScroll.getVerticalScrollBar()) {

        if (Main.glassPane.getCursor().getType() != Cursor.WAIT_CURSOR) {
            Main.glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
        Draw.setGlasspane(true);

    } else if (event.getSource() == searchField) {
        searchField.requestFocus();
        searchField.setForeground(Color.black);
        if (searchField.getText().contains("Search by")) {
            searchField.setText("");
        }

    } else if (event.getSource() == addGenome) {
        if (AddGenome.frame == null) {
            AddGenome.createAndShowGUI();
        }
        AddGenome.frame.setTitle("Add new genome");
        AddGenome.annotation = false;
        AddGenome.remove.setEnabled(false);
        AddGenome.download.setEnabled(false);
        AddGenome.frame.setVisible(true);
        AddGenome.frame.setLocation(
                frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                frame.getLocationOnScreen().y + frame.getHeight() / 6);
        AddGenome.frame.setState(JFrame.NORMAL);

    } else if (event.getComponent().getName() != null) {
        if (event.getComponent().getName().equals("frame0")) {
            return;
        }

        try {
            if (event.getComponent().getName().equals("add_annotation")) {
                if (AddGenome.frame == null) {
                    AddGenome.createAndShowGUI();
                }
                AddGenome.annotation = true;
                AddGenome.frame.setTitle("Add new annotation file for " + Main.selectedGenome);
                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);
                AddGenome.genomeName.setText(hoverGenome);
                return;
            }

            if (hoverAnnotation.length() > 0) {
                for (int j = 0; j < genomehash.get(hoverGenome).size(); j++) {
                    if (genomehash.get(hoverGenome).get(j).getName().contains(hoverAnnotation)) {
                        annotationfile = genomehash.get(hoverGenome).get(j).getName();
                        Main.annotation = j;
                        break;
                    }
                }

                defaultGenome = hoverGenome;

                setChromDrop(defaultGenome);
                getBands();
                if (genomehash.get(defaultGenome).size() > 0
                        && genomehash.get(defaultGenome).get(annotation) != null) {

                    changeAnnotation(annotation);

                }
                //drawCanvas.chrom = chromosomeDropdown.getItemAt(0);
                chromosomeDropdown.setSelectedIndex(0);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    Insets insets = getInsets();// ww  w.j a v a2 s. c o m
    int x = (int) ((e.getX() - insets.left) / getScaleX());
    int y = (int) ((e.getY() - insets.top) / getScaleY());

    ChartEntity entity = null;
    EntityCollection entities = null;
    if (getChartRenderingInfo() != null) {
        entities = getChartRenderingInfo().getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
            //                boolean isDirty = false;
            int seriesIndex = -1;
            if (selectedSeriesIndex >= 0) {
                //                   double xInChart = ChartMaskingUtilities.translateScreenX(x, 
                //                         getScreenDataArea(), getChart());
                //                   XYDataset dataset = getChart().getXYPlot().getDataset();
                //                   PatternDataset patternDataset = (PatternDataset) dataset;
                //                   int itemIndex = patternDataset.getItemFromX(selectedSeriesIndex, xInChart);
                //                   if (itemIndex < patternDataset.getItemCount(selectedSeriesIndex)) {
                //                      chartX = patternDataset.getXValue(selectedSeriesIndex, itemIndex);
                //                      chartY = patternDataset.getYValue(selectedSeriesIndex, itemIndex);
                //                      Point2D axisTrace = ChartMaskingUtilities.translateChartPoint(
                //                            new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart());
                //                      horizontalTraceLocation = (int) axisTrace.getX();
                //                      verticalTraceLocation = (int) axisTrace.getY();
                //                      seriesIndex = selectedSeriesIndex;
                //                      isDirty = true;
                //                   }
                seriesIndex = followDomainTrace(selectedSeriesIndex, x);
            } else if (getChart().getXYPlot().getSeriesCount() == 1) {
                //                   int seriesIndex0 = 0;
                //                   double xInChart = ChartMaskingUtilities.translateScreenX(x, 
                //                         getScreenDataArea(), getChart());
                //                   XYDataset dataset = getChart().getXYPlot().getDataset();
                //                   PatternDataset patternDataset = (PatternDataset) dataset;
                //                   int itemIndex = patternDataset.getItemFromX(seriesIndex0, xInChart);
                //                   if (itemIndex < patternDataset.getItemCount(seriesIndex0)) {
                //                      chartX = patternDataset.getXValue(seriesIndex0, itemIndex);
                //                      chartY = patternDataset.getYValue(seriesIndex0, itemIndex);
                //                      Point2D axisTrace = ChartMaskingUtilities.translateChartPoint(
                //                            new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart());
                //                      horizontalTraceLocation = (int) axisTrace.getX();
                //                      verticalTraceLocation = (int) axisTrace.getY();
                //                      seriesIndex = seriesIndex0;
                //                      isDirty = true;
                //                   }
                seriesIndex = followDomainTrace(0, x);
            } else if (entity instanceof XYItemEntity) {
                XYItemEntity xyEntity = (XYItemEntity) entity;
                XYDataset dataset = xyEntity.getDataset();
                int item = ((XYItemEntity) entity).getItem();
                seriesIndex = xyEntity.getSeriesIndex();
                double chartX = dataset.getXValue(seriesIndex, item);
                double chartY = dataset.getYValue(seriesIndex, item);
                Point2D screenPoint = ChartMaskingUtilities.translateChartPoint(
                        new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart());
                setChartX(chartX);
                setChartY(chartY);
                setSeriesIndex(seriesIndex);
                setItemIndex(item);
                if (dataset instanceof IXYErrorDataset) {
                    setChartError(((IXYErrorDataset) dataset).getYError(seriesIndex, item));

                }
                if (getHorizontalAxisTrace()) {
                    setHorizontalTraceLocation((int) screenPoint.getX());
                }
                if (getVerticalAxisTrace()) {
                    setVerticalTraceLocation((int) screenPoint.getY());
                }
                //                   isDirty = true;
            }
            if (seriesIndex >= 0) {
                Object[] listeners = getListeners(ChartMouseListener.class);
                if (getChart() != null) {
                    XYChartMouseEvent event = new XYChartMouseEvent(getChart(), e, entity);
                    event.setXY(getChartX(), getChartY());
                    event.setSeriesIndex(seriesIndex);
                    for (int i = listeners.length - 1; i >= 0; i -= 1) {
                        ((ChartMouseListener) listeners[i]).chartMouseMoved(event);
                    }
                }
            }

        }
    }

    //        if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) {
    if (isInternalLegendEnabled && isInternalLegendSelected) {
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        setCursor(Cursor.getPredefinedCursor(cursorType));
    } else if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) == 0) {
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        setCursor(Cursor.getPredefinedCursor(cursorType));
    } else if (getCursor() != defaultCursor) {
        setCursor(defaultCursor);
    }

    if (isInternalLegendEnabled && isInternalLegendSelected
            && findCursorOnSelectedItem(e.getX(), e.getY()) != Cursor.DEFAULT_CURSOR
            && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
        changeInternalLegend(e);
    } else if (getMaskDragIndicator() != Cursor.DEFAULT_CURSOR && this.getSelectedMask() != null
            && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
        changeSelectedMask(e);
    } else if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) {
        // Do masking service
        // if no initial masking point was set, ignore dragging...
        makeNewMask(e);
    } else {
        super.mouseDragged(e);
    }
}

From source file:org.bitbucket.mlopatkin.android.logviewer.widgets.UiHelper.java

public static void addDoubleClickAction(JComponent component, final Action action) {
    component.addMouseListener(new MouseAdapter() {
        @Override/* w  w w  . ja  va  2 s  .  c  o  m*/
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == DOUBLE_CLICK_COUNT && e.getButton() == MouseEvent.BUTTON1) {
                action.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED,
                        (String) action.getValue(Action.ACTION_COMMAND_KEY), e.getWhen(), e.getModifiers()));
            }
        }
    });
}

From source file:org.kineticsystem.commons.data.view.actions.MoveBackMouseAction.java

/**
 * This method is called when the user press a mouse button on the button
 * connected to this action./*from  ww w . j  a v a2 s  .com*/
 * @param event The mouse event.
 */
public void mousePressed(MouseEvent event) {

    if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {

        mover = new Accelerator() {

            public void execute() {

                if (navigator.isMoveBackEnabled()) {
                    try {
                        EventQueue.invokeAndWait(new Runnable() {
                            public void run() {
                                navigator.moveBack();
                            }
                        });
                    } catch (Exception ex) {
                        logger.info(ex);
                    }
                } else {
                    interrupt();
                }
            }
        };
        mover.setPriority(Thread.NORM_PRIORITY);
        mover.start();
    }
}

From source file:org.kineticsystem.commons.data.view.actions.MoveBackMouseAction.java

/** 
 * This method is called when the user release a mouse button.
 * @param event The mouse event.// ww w  .  ja v a 2s  .c  o m
 */
public void mouseReleased(MouseEvent event) {

    if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
        mover.interrupt();
        mover = null;
    }
}

From source file:org.kineticsystem.commons.data.view.actions.MoveForwardMouseAction.java

/**
 * This method is called when the user press a mouse button on the button
 * connected to this action./*w  w w  .  j a  v  a 2 s.  co  m*/
 * @param event The mouse event.
 */
public void mousePressed(MouseEvent event) {

    if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {

        mover = new Accelerator() {

            public void execute() {

                if (navigator.isMoveForwardEnabled()) {
                    try {
                        EventQueue.invokeAndWait(new Runnable() {
                            public void run() {
                                navigator.moveNext();
                            }
                        });
                    } catch (Exception ex) {
                        logger.info(ex);
                    }
                } else {
                    interrupt();
                }
            }
        };
        mover.setPriority(Thread.NORM_PRIORITY);
        mover.start();
    }
}

From source file:org.mbari.aved.ui.classifier.knowledgebase.ConceptTree.java

/**
 * Sets up the various listeners needed for GUI interaction with this
 * <code>ConceptTree</code>.
 *//* w ww  . j  av  a  2s . com*/
protected void setupListeners() {

    // Add context popup menu and right mouse button selection
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {

            // Selected item before showing popup menu
            if (event.getModifiers() == MouseEvent.BUTTON3_MASK) {
                int row = getRowForLocation(event.getX(), event.getY());

                setSelectionRow(row);
            }
        }
    });

    // Toggle expand/collapse on ENTER
    addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.VK_ENTER) {
                int row = getSelectionRows()[0];

                if (isCollapsed(row)) {
                    expandRow(row);
                } else {
                    collapseRow(row);
                }
            }
        }
    });
}