Example usage for java.awt.event MouseEvent getButton

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

Introduction

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

Prototype

public int getButton() 

Source Link

Document

Returns which, if any, of the mouse buttons has changed state.

Usage

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

public void mousePressed(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        if (this.coElutionRegion == null) {
            shifted = true;//from w w w  .  j  a va 2  s .c  o m
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null) {
                this.coElutionStart = getPointInRectangle(e.getX(), e.getY(), screenDataArea);
            } else {
                this.coElutionStart = null;
            }
        }
    } else {
        _cp.mousePressed(e);
    }
}

From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java

public void mousePressed(MouseEvent e) {
    // Left mouse button only
    if (e.getButton() != MouseEvent.BUTTON1)
        return;/* w  w  w. j av  a 2  s  .c o m*/

    eventHandler.talkButtonPressed(Constants.DEVICE_MOUSE);
    talkButtonPressed = true;
}

From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java

public void mouseReleased(MouseEvent e) {
    // Left mouse button only
    if (e.getButton() != MouseEvent.BUTTON1)
        return;// w w w.  j a va2s.c  o  m

    if (talkButtonPressed) {
        eventHandler.talkButtonReleased(Constants.DEVICE_MOUSE);
        talkButtonPressed = false;
    }
}

From source file:org.ujmp.jung.JungVisualizationViewer.java

public final void mouseClicked(MouseEvent e) {
    switch (e.getButton()) {
    case MouseEvent.BUTTON1:
        break;/*from ww w . jav  a  2  s  . com*/
    case MouseEvent.BUTTON2:
        break;
    case MouseEvent.BUTTON3:
        JPopupMenu popup = null;
        popup = new JungGraphActions(this);
        popup.show(e.getComponent(), e.getX(), e.getY());
        break;
    }
}

From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java

@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) {
        return;//w w w.j  a v  a2s . co  m
    }
    //testLog.append("Mouse pressed: " + e.getX() + ", " + e.getY() + "\n");
    startX = e.getX();
    startY = e.getY();
    endX = e.getX();
    endY = e.getY();

    //      if (selectRectangle != null)
    //      {
    //         Graphics2D g2 = (Graphics2D) this.getGraphics();
    //         drawSelectRectangle(g2);
    //         this.selectRectangle = new Rectangle2D.Double(e.getX(), e.getY(), 0, 0);
    //      }
    this.isNewRectangle = true;
    this.x = e.getX();
    this.y = e.getY();
    this.width = 0;
    this.height = 0;
    repaint();
}

From source file:ru.codemine.pos.ui.windows.document.startbalances.StartBalancesListWindow.java

@Override
public void setupActionListeners() {
    setNewActionListener(newSb);//from w w w.ja  v  a2 s .  c o  m
    setEditActionListener(editSb);
    setDeleteActionListener(deleteSb);
    setProcessActionListener(processSb);
    setUnprocessActionListener(unprocessSb);
    setRefreshActionListener(refreshSbList);

    storeChooseBox.addActionListener(changeStoreSb);

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            int row = table.rowAtPoint(p);
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                menuItemEdit.doClick();
            }
        }
    });

    actionListenersInit = true;
}

From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) {
        return;//from  ww w  . j av  a2  s . c  om
    }
    endX = e.getX();
    endY = e.getY();
    Graphics2D g2 = (Graphics2D) this.getGraphics();
    //      drawSelectRectangle(g2);
    double xmin = Math.min(startX, endX);
    double ymin = Math.min(startY, endY);
    double xmax = Math.max(startX, endX);
    double ymax = Math.max(startY, endY);
    //      this.selectRectangle = new Rectangle2D.Double(
    //            xmin, ymin,
    //            xmax - xmin, ymax - ymin);
    this.x = xmin;
    this.y = ymin;
    this.width = xmax - xmin;
    this.height = ymax - ymin;
    //      drawSelectRectangle(g2);
    //      g2.dispose();

    this.isNewRectangle = false;
    repaint();
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java

@Override
public void mouseReleased(final MouseEvent event) {
    if (event.getButton() != MouseEvent.BUTTON1)
        return;/*  w  w w .  j  a v a  2s  . c  o  m*/
    event.consume();

    if (m_edit && m_lineEditor != null) {
        final GM_Curve curve = m_lineEditor.finish();
        if (curve != null)
            finishLine(curve);
    }
}

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

public void mouseDragged(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        if (this.coElutionStart == null) {
            return;
        }//from   ww  w. j av a  2s  .  c  o  m
        Graphics2D g2 = (Graphics2D) _cp.getGraphics();
        if (this.coElutionRegion != null)
            drawCoElutionRegion(g2);
        if (e.getX() < this.coElutionStart.getX())
            return;
        // Erase the previous zoom rectangle (if any)...
        Rectangle2D scaledDataArea = _cp.getScreenDataArea((int) this.coElutionStart.getX(),
                (int) this.coElutionStart.getY());

        // selected rectangle shouldn't extend outside the data area...
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        /*
                    this.coElutionRegion = new Rectangle2D.Double(
                this.coElutionStart.getX(), this.coElutionStart.getY(),
                xmax - this.coElutionStart.getX(), ymax - this.coElutionStart.getY());
        */
        this.coElutionRegion = new Rectangle2D.Double(this.coElutionStart.getX(), scaledDataArea.getMinY(),
                Math.abs(e.getX() - coElutionStart.getX()), scaledDataArea.getHeight());

        // Draw the new zoom rectangle...
        drawCoElutionRegion(g2);

        g2.dispose();

    } else {
        _cp.mouseDragged(e);
    }
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java

@Override
public void mouseClicked(final MouseEvent event) {
    if (event.getButton() != MouseEvent.BUTTON1)
        return;//from   w  w w  . j  a  v a2 s.  c  o  m
    if (event.getClickCount() < 2)
        return;
    event.consume();

    if (m_edit && event.isShiftDown()) {
        // TODO: insert points into current line
    }

    if (m_lineBuilder != null) {
        try {
            final GM_Curve curve = (GM_Curve) m_lineBuilder.finish();
            finishLine(curve);
        } catch (final Exception e) {
            e.printStackTrace();
            reinit();
        }
    }
}