Example usage for java.awt.event InputEvent BUTTON3_MASK

List of usage examples for java.awt.event InputEvent BUTTON3_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent BUTTON3_MASK.

Prototype

int BUTTON3_MASK

To view the source code for java.awt.event InputEvent BUTTON3_MASK.

Click Source Link

Document

The Mouse Button3 modifier constant.

Usage

From source file:ExText.java

/**
 * Process a new wakeup. Interpret mouse button presses, releases, and mouse
 * drags./*from  w  w w  . j  av  a2 s  .  com*/
 * 
 * @param criteria
 *            The wakeup criteria causing the behavior wakeup.
 */
public void processStimulus(Enumeration criteria) {
    WakeupCriterion wakeup = null;
    AWTEvent[] event = null;
    int whichButton = BUTTONNONE;

    // Process all pending wakeups
    while (criteria.hasMoreElements()) {
        wakeup = (WakeupCriterion) criteria.nextElement();
        if (wakeup instanceof WakeupOnAWTEvent) {
            event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();

            // Process all pending events
            for (int i = 0; i < event.length; i++) {
                if (event[i].getID() != MouseEvent.MOUSE_PRESSED
                        && event[i].getID() != MouseEvent.MOUSE_RELEASED
                        && event[i].getID() != MouseEvent.MOUSE_DRAGGED)
                    // Ignore uninteresting mouse events
                    continue;

                //
                // Regretably, Java event handling (or perhaps
                // underlying OS event handling) doesn't always
                // catch button bounces (redundant presses and
                // releases), or order events so that the last
                // drag event is delivered before a release.
                // This means we can get stray events that we
                // filter out here.
                //
                if (event[i].getID() == MouseEvent.MOUSE_PRESSED && buttonPressed != BUTTONNONE)
                    // Ignore additional button presses until a release
                    continue;

                if (event[i].getID() == MouseEvent.MOUSE_RELEASED && buttonPressed == BUTTONNONE)
                    // Ignore additional button releases until a press
                    continue;

                if (event[i].getID() == MouseEvent.MOUSE_DRAGGED && buttonPressed == BUTTONNONE)
                    // Ignore drags until a press
                    continue;

                MouseEvent mev = (MouseEvent) event[i];
                int modifiers = mev.getModifiers();

                //
                // Unfortunately, the underlying event handling
                // doesn't do a "grab" operation when a mouse button
                // is pressed. This means that once a button is
                // pressed, if another mouse button or a keyboard
                // modifier key is pressed, the delivered mouse event
                // will show that a different button is being held
                // down. For instance:
                //
                // Action Event
                //  Button 1 press Button 1 press
                //  Drag with button 1 down Button 1 drag
                //  ALT press -
                //  Drag with ALT & button 1 down Button 2 drag
                //  Button 1 release Button 2 release
                //
                // The upshot is that we can get a button press
                // without a matching release, and the button
                // associated with a drag can change mid-drag.
                //
                // To fix this, we watch for an initial button
                // press, and thenceforth consider that button
                // to be the one held down, even if additional
                // buttons get pressed, and despite what is
                // reported in the event. Only when a button is
                // released, do we end such a grab.
                //

                if (buttonPressed == BUTTONNONE) {
                    // No button is pressed yet, figure out which
                    // button is down now and how to direct events
                    if (((modifiers & InputEvent.BUTTON3_MASK) != 0)
                            || (((modifiers & InputEvent.BUTTON1_MASK) != 0)
                                    && ((modifiers & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK))) {
                        // Button 3 activity (META or CTRL down)
                        whichButton = BUTTON3;
                    } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
                        // Button 2 activity (ALT down)
                        whichButton = BUTTON2;
                    } else {
                        // Button 1 activity (no modifiers down)
                        whichButton = BUTTON1;
                    }

                    // If the event is to press a button, then
                    // record that that button is now down
                    if (event[i].getID() == MouseEvent.MOUSE_PRESSED)
                        buttonPressed = whichButton;
                } else {
                    // Otherwise a button was pressed earlier and
                    // hasn't been released yet. Assign all further
                    // events to it, even if ALT, META, CTRL, or
                    // another button has been pressed as well.
                    whichButton = buttonPressed;
                }

                // Distribute the event
                switch (whichButton) {
                case BUTTON1:
                    onButton1(mev);
                    break;
                case BUTTON2:
                    onButton2(mev);
                    break;
                case BUTTON3:
                    onButton3(mev);
                    break;
                default:
                    break;
                }

                // If the event is to release a button, then
                // record that that button is now up
                if (event[i].getID() == MouseEvent.MOUSE_RELEASED)
                    buttonPressed = BUTTONNONE;
            }
            continue;
        }

        if (wakeup instanceof WakeupOnElapsedFrames) {
            onElapsedFrames((WakeupOnElapsedFrames) wakeup);
            continue;
        }
    }

    // Reschedule us for another wakeup
    wakeupOn(mouseCriterion);
}

From source file:base.BasePlayer.ClusterTable.java

public void mouseClicked(MouseEvent event) {
    switch (event.getModifiers()) {
    case InputEvent.BUTTON1_MASK: {
        if (!this.isEnabled()) {
            break;
        }/*from  w w w.ja va 2 s  . c  om*/
        if (this.headerHover == -1) {
            if (event.getClickCount() == 2) {
                FileRead.novars = true;

                if (hoverSample > -1) {
                    Main.drawCanvas.drawVariables.visiblestart = (short) (hoverSample);
                    Main.drawCanvas.drawVariables.visiblesamples = (short) (1);
                    Main.drawCanvas.resizeCanvas(Main.drawScroll.getViewport().getWidth(),
                            (int) (Main.samples * Main.drawCanvas.drawVariables.sampleHeight));
                    Draw.setScrollbar((int) (hoverSample * Main.drawCanvas.drawVariables.sampleHeight));
                }
                FileRead.search = true;
                if (hoverVar != null) {

                    VarNode searchHead = hoverVar;

                    while (searchHead.getPrev() != null) {
                        if (searchHead.getPrev().getPosition() == 0) {
                            searchHead.getPrev().putNext(searchHead);
                        }
                        searchHead = searchHead.getPrev();

                    }

                    FileRead.head = searchHead;
                    searchHead = null;
                    Main.drawCanvas.current = hoverVar;

                    if (hoverVar.getExons() != null) {
                        Main.drawCanvas.gotoPos(hoverVar.getExons().get(0).getTranscript().getChrom(),
                                hoverVar.getPosition() + 1 - 50, hoverVar.getPosition() + 1 + 50);
                    } else {
                        if (hoverVar.getTranscripts() != null) {
                            Main.drawCanvas.gotoPos(hoverVar.getTranscripts().get(0).getChrom(),
                                    hoverVar.getPosition() + 1 - 50, hoverVar.getPosition() + 1 + 50);
                        }
                    }
                } else if (hoverNode != null) {
                    VarNode searchHead = hoverNode.varnodes.get(0);
                    if (hoverNode.varnodes.get(0).getTranscripts() != null) {
                        if (!chrom.equals(hoverNode.varnodes.get(0).getTranscripts().get(0).getChrom())) {
                            chrom = hoverNode.varnodes.get(0).getTranscripts().get(0).getChrom();
                        }
                    } else {
                        if (!chrom.equals(hoverNode.varnodes.get(0).getExons().get(0).transcript.getChrom())) {
                            chrom = hoverNode.varnodes.get(0).getExons().get(0).transcript.getChrom();
                        }
                    }
                    while (searchHead.getPrev() != null) {
                        if (searchHead.getPrev().getPosition() == 0) {
                            searchHead.getPrev().putNext(searchHead);
                        }
                        searchHead = searchHead.getPrev();
                    }

                    FileRead.head = searchHead;
                    searchHead = null;
                    Main.drawCanvas.current = hoverNode.varnodes.get(0);
                    Main.drawCanvas.gotoPos(chrom, hoverNode.varnodes.get(0).getPosition(),
                            hoverNode.varnodes.get(0).getPosition() + hoverNode.width);
                }

                break;
            } else if (event.getClickCount() == 1) {

                if (hoverVar != null && (selectedVar == null || !selectedVar.equals(hoverVar))) {

                    selectedVar = hoverVar;
                    selectedString = hoverString;

                    if (selectedVar.isRscode() != null) {
                        hoverString[4] = selectedVar.rscode;
                    }
                    repaint();

                    this.setPreferredSize(new Dimension(this.getWidth(),
                            (this.getTableSize() + 2 + samplecount + Integer.parseInt(selectedString[1]))
                                    * rowHeight));

                    this.revalidate();

                } else if (hoverVar != null && selectedVar.equals(hoverVar)) {

                    if (hoverSample == -1) {

                        selectedVar = null;

                        repaint();
                        this.setPreferredSize(new Dimension(this.getWidth(),
                                (this.getTableSize() + 2 + samplecount) * rowHeight));

                        this.revalidate();
                    }
                } else {

                    if (hoverVar != null && selectedNode != null && hoverNode.equals(selectedNode)) {

                        selectedString = hoverString;

                        samplecount = 0;
                        repaint();

                    } else {

                        if (hoverSample == -1) {

                            if (hoverNode != null) {

                                if (selectedNode != null && selectedNode.equals(hoverNode)) {

                                    selectedString = null;
                                    selectedNode = null;
                                    hoverVar = null;
                                    selectedVar = null;
                                    aminoarray.clear();
                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2) * rowHeight + 10));

                                    this.revalidate();

                                    repaint();
                                    break;
                                }

                                selectedNode = hoverNode;
                                selectedString = hoverString;
                                //   samplecount = selectedNode.mutations;
                                samplecount = selectedNode.varnodes.size();

                                this.setPreferredSize(new Dimension(this.getWidth(),
                                        (this.getTableSize() + 2 + samplecount) * rowHeight + 10));
                                this.revalidate();
                                getAminos(selectedNode);
                                repaint();

                            }
                        }

                    }
                }
            }
        }
        break;

    }
    case InputEvent.BUTTON3_MASK: {

        selectedNode = null;
        selectedVar = null;
        repaint();
    }
    }
}

From source file:base.BasePlayer.AminoTable.java

@Override
public void mouseClicked(MouseEvent event) {
    switch (event.getModifiers()) {
    case InputEvent.BUTTON1_MASK: {

        if (!this.isEnabled()) {
            break;
        }/*from  w w w.  java 2s  . c  o  m*/
        if (this.headerHover == -1) {
            if (event.getClickCount() == 2) {
                if (Draw.variantcalculator) {
                    return;
                }
                FileRead.novars = true;

                if (hoverSample > -1) {
                    Main.drawCanvas.drawVariables.visiblestart = (short) (hoverSample);
                    Main.drawCanvas.drawVariables.visiblesamples = (short) (1);
                    Main.drawCanvas.resizeCanvas(Main.drawScroll.getViewport().getWidth(),
                            (int) (Main.samples * Main.drawCanvas.drawVariables.sampleHeight));
                    Draw.setScrollbar((int) (hoverSample * Main.drawCanvas.drawVariables.sampleHeight));
                } else {
                    Main.drawCanvas.drawVariables.visiblestart = (short) (0);
                    Main.drawCanvas.drawVariables.visiblesamples = (short) (Main.samples);
                    Main.drawCanvas.resizeCanvas(Main.drawScroll.getViewport().getWidth(),
                            (int) (Main.samples * Main.drawCanvas.drawVariables.sampleHeight));
                    Draw.setScrollbar(0);
                }

                if (hoverVar != null) {

                    FileRead.search = true;
                    VarNode searchHead = hoverVar;

                    while (searchHead.getPrev() != null) {
                        /*if(searchHead.getPrev().getPosition() == 0) {
                           searchHead.getPrev().putNext(searchHead);
                                   
                        }*/
                        if (searchHead.getPrev().getChrom() == null
                                || !searchHead.getPrev().getChrom().equals(hoverVar.getChrom())) {
                            if (searchHead.getPrev().getNext() == null) {
                                searchHead.getPrev().putNext(searchHead);

                            }
                            FileRead.head = searchHead.getPrev();

                            break;
                        }
                        searchHead = searchHead.getPrev();
                    }

                    searchHead = null;

                    Main.drawCanvas.current = hoverVar;

                    if (hoverVar.getExons() != null) {
                        Main.drawCanvas.gotoPos(hoverVar.getChrom(), hoverVar.getPosition() + 1 - 50,
                                hoverVar.getPosition() + 1 + 50);
                    } else {
                        if (hoverVar.getTranscripts().size() > 0) {
                            Main.drawCanvas.gotoPos(hoverVar.getChrom(), hoverVar.getPosition() + 1 - 50,
                                    hoverVar.getPosition() + 1 + 50);
                        }
                    }
                } else if (hoverNode != null) {

                    FileRead.search = true;

                    if (hoverNode.varnodes.get(0).getTranscripts() != null
                            && hoverNode.varnodes.get(0).getTranscripts().size() == 2) {
                        Main.drawCanvas.gotoPos(hoverNode.getChrom(), hoverNode.getEnd(),
                                hoverNode.varnodes.get(0).getTranscripts().get(1).getGene().getStart());
                    } else {
                        VarNode searchHead = hoverNode.varnodes.get(0);

                        /*while(searchHead.getPrev() != null) {
                           if(searchHead.getPrev().getPosition() == 0) {
                              searchHead.getPrev().putNext(searchHead);
                           }
                           searchHead = searchHead.getPrev();                     
                        }*/

                        while (searchHead.getPrev() != null) {
                            /*if(searchHead.getPrev().getPosition() == 0) {
                               searchHead.getPrev().putNext(searchHead);
                                       
                            }*/
                            if (searchHead.getPrev().getChrom() == null
                                    || !searchHead.getPrev().getChrom().equals(searchHead.getChrom())) {

                                FileRead.head = searchHead.getPrev();
                                break;
                            }
                            searchHead = searchHead.getPrev();
                        }
                        //FileRead.head = searchHead;               
                        searchHead = null;
                        Main.drawCanvas.current = hoverNode.varnodes.get(0);
                        Main.drawCanvas.gotoPos(hoverNode.getChrom(), hoverNode.getStart(), hoverNode.getEnd());
                    }
                }
                Main.chromDraw.updateExons = true;
                Main.chromDraw.repaint();

                break;
            } else if (event.getClickCount() == 1) {

                /*   if(hoverVar != null && selectedNode.equals(selectedVar)) {
                      selectedString = hoverString;
                              
                   }
                   else*/

                //MethodLibrary.showVariantMenu(this, varOverLap, sampleOverLap, moveX+(int)selectedSplit.pixel, moveY);
                if (hoverVar != null && (selectedVar == null || !selectedVar.equals(hoverVar))) {

                    selectedVar = hoverVar;
                    selectedString = hoverString;

                    if (selectedVar.isRscode() != null) {
                        hoverString[4] = selectedVar.rscode;
                    }

                    //MethodLibrary.showVariantMenu(this, hoverVar, null, mouseX+(int)Main.defaultFontSize*2, mouseY,hoverBase);
                    /*   if(hoverBase != null) {
                          MethodLibrary.showVariantMenu(this, hoverVar, null, 0, mouseY-Main.defaultFontSize*6,hoverBase);
                       }
                       */
                    repaint();

                    this.setPreferredSize(new Dimension(this.getWidth(),
                            (this.getTableSize() + 2 + samplecount + Integer.parseInt(selectedString[1]))
                                    * rowHeight));

                    this.revalidate();

                } else if (hoverVar != null && selectedVar.equals(hoverVar)) {

                    if (hoverSample == -1) {

                        selectedVar = null;

                        repaint();
                        this.setPreferredSize(new Dimension(this.getWidth(),
                                (this.getTableSize() + 2 + samplecount) * rowHeight));

                        this.revalidate();
                    } else {
                        if (hoverSampleNode != null) {
                            MethodLibrary.showVariantMenu(this, hoverVar, hoverSampleNode,
                                    mouseX + (int) Main.defaultFontSize * 2, mouseY, hoverBase);
                        }

                    }
                } else {

                    if (hoverVar != null && selectedNode != null && hoverNode.equals(selectedNode)) {

                        selectedString = hoverString;

                        samplecount = 0;
                        repaint();

                    } else {

                        if (hoverSample == -1) {

                            if (hoverNode != null) {
                                if (selectedNode != null && selectedNode.equals(hoverNode)) {

                                    selectedString = null;
                                    selectedNode = null;
                                    hoverVar = null;
                                    selectedVar = null;
                                    aminoarray.clear();
                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2) * rowHeight));

                                    this.revalidate();

                                    repaint();
                                    break;
                                }

                                selectedNode = hoverNode;
                                selectedString = hoverString;
                                //   samplecount = selectedNode.mutations;
                                samplecount = selectedNode.varnodes.size();
                                if (VariantHandler.tabs.getSelectedIndex() == 0) {

                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2 + samplecount) * rowHeight));
                                    this.revalidate();
                                    getAminos(selectedNode);
                                    this.repaint();
                                } else {
                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2 + samplecount) * rowHeight));
                                    this.revalidate();
                                    getAminos(selectedNode);
                                    repaint();
                                }
                            }
                        }

                    }
                }
            }
        }
        break;
    }
    case InputEvent.BUTTON3_MASK: {
        selectedString = null;
        selectedNode = null;
        hoverVar = null;
        selectedVar = null;
        aminoarray.clear();
        this.setPreferredSize(new Dimension(this.getWidth(), (this.getTableSize() + 2) * rowHeight));

        this.revalidate();

        repaint();
    }
    }
}

From source file:base.BasePlayer.BedTable.java

@Override
public void mouseClicked(MouseEvent event) {
    switch (event.getModifiers()) {
    case InputEvent.BUTTON1_MASK: {
        if (!this.isEnabled()) {
            break;
        }/*from  ww  w. j  a  v a  2  s.  c  o m*/
        if (this.headerHover == -1) {
            if (event.getClickCount() == 2) {
                FileRead.novars = true;

                if (hoverSample > -1) {
                    Main.drawCanvas.drawVariables.visiblestart = (short) (hoverSample);
                    Main.drawCanvas.drawVariables.visiblesamples = (short) (1);
                    Main.drawCanvas.resizeCanvas(Main.drawScroll.getViewport().getWidth(),
                            (int) (Main.samples * Main.drawCanvas.drawVariables.sampleHeight));
                    Draw.setScrollbar((int) (hoverSample * Main.drawCanvas.drawVariables.sampleHeight));
                }
                FileRead.search = true;
                if (hoverVar != null) {

                    VarNode searchHead = hoverVar;

                    while (searchHead.getPrev() != null) {
                        if (searchHead.getPrev().getPosition() == 0) {
                            searchHead.getPrev().putNext(searchHead);
                        }
                        searchHead = searchHead.getPrev();

                    }

                    FileRead.head = searchHead;
                    searchHead = null;
                    Main.drawCanvas.current = hoverVar;

                    if (hoverVar.getExons() != null) {
                        Main.drawCanvas.gotoPos(hoverVar.getExons().get(0).getTranscript().getChrom(),
                                hoverVar.getPosition() + 1 - 50, hoverVar.getPosition() + 1 + 50);
                    } else {
                        if (hoverVar.getTranscripts() != null) {
                            Main.drawCanvas.gotoPos(hoverVar.getTranscripts().get(0).getChrom(),
                                    hoverVar.getPosition() + 1 - 50, hoverVar.getPosition() + 1 + 50);
                        }
                    }
                } else if (hoverNode != null) {
                    VarNode searchHead = hoverNode.varnodes.get(0);

                    while (searchHead.getPrev() != null) {
                        if (searchHead.getPrev().getPosition() == 0) {
                            searchHead.getPrev().putNext(searchHead);
                        }
                        searchHead = searchHead.getPrev();
                    }

                    FileRead.head = searchHead;
                    searchHead = null;
                    Main.drawCanvas.current = hoverNode.varnodes.get(0);

                    Main.drawCanvas.gotoPos(hoverNode.getChrom().replace("chr", ""), hoverNode.getPosition(),
                            hoverNode.getPosition() + hoverNode.getLength());
                }

                break;
            } else if (event.getClickCount() == 1) {

                if (hoverVar != null && (selectedVar == null || !selectedVar.equals(hoverVar))) {

                    selectedVar = hoverVar;
                    selectedString = hoverString;

                    if (selectedVar.isRscode() != null) {
                        hoverString[4] = selectedVar.rscode;
                    }
                    repaint();

                    this.setPreferredSize(new Dimension(this.getWidth(),
                            (this.getTableSize() + 2 + samplecount + Integer.parseInt(selectedString[1]))
                                    * rowHeight));

                    this.revalidate();

                } else if (hoverVar != null && selectedVar.equals(hoverVar)) {

                    if (hoverSample == -1) {

                        selectedVar = null;

                        repaint();
                        this.setPreferredSize(new Dimension(this.getWidth(),
                                (this.getTableSize() + 2 + samplecount) * rowHeight));

                        this.revalidate();
                    }
                } else {

                    if (hoverVar != null && selectedNode != null && hoverNode.equals(selectedNode)) {

                        selectedString = hoverString;

                        samplecount = 0;
                        repaint();

                    } else {

                        if (hoverSample == -1) {

                            if (hoverNode != null) {
                                if (selectedNode != null && selectedNode.equals(hoverNode)) {

                                    selectedString = null;
                                    selectedNode = null;
                                    hoverVar = null;
                                    selectedVar = null;
                                    aminoarray = null;
                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2) * rowHeight));

                                    this.revalidate();

                                    repaint();
                                    break;
                                }

                                selectedNode = hoverNode;
                                selectedString = hoverString;
                                //   samplecount = selectedNode.mutations;
                                samplecount = selectedNode.varnodes.size();
                                if (VariantHandler.tabs.getSelectedIndex() == 0) {

                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2 + samplecount) * rowHeight));
                                    this.revalidate();
                                    getAminos(selectedNode);
                                    this.repaint();
                                } else {
                                    this.setPreferredSize(new Dimension(this.getWidth(),
                                            (this.getTableSize() + 2 + samplecount) * rowHeight));
                                    this.revalidate();
                                    getAminos(selectedNode);
                                    repaint();
                                }
                            }
                        }

                    }
                }
            }
        }
        break;
    }
    case InputEvent.BUTTON3_MASK: {

        selectedNode = null;
        selectedVar = null;
        repaint();
    }
    }
}

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

public void mousePressed(MouseEvent e) {
    mMouseX1 = mMouseX2 = e.getX();//from w w  w  .j  a  v a2s  .  com
    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:base.BasePlayer.BedCanvas.java

public void mouseClicked(MouseEvent event) {
    switch (event.getModifiers()) {
    case InputEvent.BUTTON1_MASK: {
        if (selectedPlay > -1 && bedTrack.get(selectedPlay).playbox.intersects(sideMouseRect)) {
            if (!Main.drawCanvas.loading) {

                pressIntersect(bedTrack.get(selectedPlay));
            }//from  w  w  w. j av  a 2s .c  om
        } else if (selectedPlay > -1 && bedTrack.get(selectedPlay).graphBox.intersects(sideMouseRect)) {
            pressGraph(bedTrack.get(selectedPlay));
        } else if (removeTrack > -1) {
            removeTrack(removeTrack);
        }
        break;
    }
    case InputEvent.BUTTON3_MASK: {

        if (!sidebar) {
            this.bedTrack.get(hoverIndex).getPopup().show(this, mouseX, mouseY);
        }
    }
    }
    Draw.updatevars = true;
    repaint();

}

From source file:base.BasePlayer.BedCanvas.java

@SuppressWarnings("unchecked")
public void mousePressed(MouseEvent event) {
    resize = false;/*  www.  j av  a  2s  .  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:base.BasePlayer.BedCanvas.java

@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent event) {
    switch (event.getModifiers()) {

    case InputEvent.BUTTON1_MASK: {
        if (sidebar) {
            return;
        }/*w ww . j  a v  a  2  s.co  m*/
        this.mouseX = event.getX();
        this.mouseY = event.getY();

        if (resizer && this.getHeight() > this.trackDivider.size() * 20) {

            this.trackDivider.set(this.resizeDivider, mouseY / (double) this.getHeight());

            if ((positivelock || negative)
                    && this.trackDivider.get(this.resizeDivider) * this.getHeight() - preresizer >= 0) {
                positivelock = false;
                negative = false;
                preresize = mouseY;
                tempDivider = (ArrayList<Double>) trackDivider.clone();

            } else if ((!negative || negativelock)
                    && this.trackDivider.get(this.resizeDivider) * this.getHeight() - preresizer < 0) {
                negativelock = false;
                preresize = mouseY;
                tempDivider = (ArrayList<Double>) trackDivider.clone();
                negative = true;
            }

            if (negativelock) { // || (this.trackDivider.get(this.resizeDivider+1)*this.getHeight()) -(this.trackDivider.get(this.resizeDivider)*this.getHeight()) < 20) {
                this.trackDivider.set(this.resizeDivider,
                        (this.trackDivider.get(this.resizeDivider + 1) * this.getHeight() - 19)
                                / (double) this.getHeight());
            }
            if (positivelock) { // || (this.trackDivider.get(this.resizeDivider+1)*this.getHeight()) -(this.trackDivider.get(this.resizeDivider)*this.getHeight()) < 20) {
                this.trackDivider.set(this.resizeDivider, 19 / (double) this.getHeight());
            }
            if (this.trackDivider.get(this.resizeDivider) * this.getHeight() - preresizer < 0) {

                negative = true;
                positivelock = true;
                if (this.resizeDivider > 0) {

                    for (int i = 1; i < this.resizeDivider + 1; i++) {
                        if ((this.trackDivider.get(i) * this.getHeight())
                                - (this.trackDivider.get(i - 1) * this.getHeight()) < 20) {

                            this.trackDivider.set(i, ((this.trackDivider.get(i - 1) * this.getHeight()) + 19)
                                    / (double) this.getHeight());
                        } else {
                            positivelock = false;
                            if (i != this.resizeDivider) {
                                this.trackDivider.set(i, (this.tempDivider.get(i) / preresize) * mouseY);
                            }
                        }
                    }
                }
                if ((this.trackDivider.get(0) * this.getHeight()) >= 20) {
                    this.trackDivider.set(0, (this.tempDivider.get(0) / preresize) * mouseY);
                    positivelock = false;
                } else {
                    this.trackDivider.set(0, 19 / (double) this.getHeight());
                }

            } else {

                negative = false;
                negativelock = true;
                if (this.resizeDivider < this.trackDivider.size() - 1) {

                    for (int i = this.resizeDivider; i < this.trackDivider.size() - 1; i++) {

                        if ((this.trackDivider.get(i + 1) * this.getHeight())
                                - (this.trackDivider.get(i) * this.getHeight()) < 20) {

                            this.trackDivider.set(i, ((this.trackDivider.get(i + 1) * this.getHeight()) - 19)
                                    / (double) this.getHeight());
                        } else {

                            negativelock = false;
                            if (i != this.resizeDivider) {
                                try {
                                    this.trackDivider.set(i,
                                            1 - ((1 - this.tempDivider.get(i)) / (this.getHeight() - preresize))
                                                    * (this.getHeight() - mouseY));
                                } catch (Exception e) {

                                    //   e.printStackTrace();
                                }
                            }
                        }
                    }
                    if (this.getHeight()
                            - (this.trackDivider.get(this.trackDivider.size() - 2) * this.getHeight()) >= 20) {
                        negativelock = false;
                    } else {
                        this.trackDivider.set(this.trackDivider.size() - 2,
                                (this.getHeight() - 19) / (double) this.getHeight());
                    }

                }
            }

            preresizer = this.trackDivider.get(this.resizeDivider) * this.getHeight();
            repaint();

        } else if (lineZoomer) {

            if (Main.drawCanvas.selectedSplit.start > 1
                    || Main.drawCanvas.selectedSplit.end < Main.drawCanvas.selectedSplit.chromEnd) {
                Main.drawCanvas.gotoPos(
                        Main.drawCanvas.selectedSplit.start
                                - (Main.drawCanvas.tempDrag - mouseX) / Main.drawCanvas.selectedSplit.pixel * 2,
                        Main.drawCanvas.selectedSplit.end + (Main.drawCanvas.tempDrag - mouseX)
                                / Main.drawCanvas.selectedSplit.pixel * 2);
            }

            Main.drawCanvas.tempDrag = mouseX;
            Main.chromDraw.updateExons = true;
            repaint();
            Main.chromDraw.repaint();
            Draw.updatevars = true;
            Main.drawCanvas.repaint();

        } else {
            if (getCursor().getType() != Cursor.N_RESIZE_CURSOR) {
                zoomDrag = true;

                repaint();
            }
            return;
        }
        break;
    }
    case InputEvent.BUTTON3_MASK: {
        if (sidebar) {
            return;
        }
        if ((int) Main.drawCanvas.selectedSplit.start == 1
                && (int) Main.drawCanvas.selectedSplit.end == Main.drawCanvas.selectedSplit.chromEnd) {
            break;
        }

        Main.drawCanvas.mouseDrag = true;
        Main.drawCanvas.moveX = event.getX();
        Main.drawCanvas.drag(Main.drawCanvas.moveX);
        break;
    }
    case 17: {
        if (sidebar) {
            return;
        }
        if ((int) Main.drawCanvas.selectedSplit.start == 1
                && (int) Main.drawCanvas.selectedSplit.end == Main.drawCanvas.selectedSplit.chromEnd) {
            break;
        }

        Main.drawCanvas.mouseDrag = true;
        Main.drawCanvas.moveX = event.getX();
        Main.drawCanvas.drag(Main.drawCanvas.moveX);
        break;
    }
    }
}

From source file:base.BasePlayer.Main.java

@Override
public void mousePressed(MouseEvent event) {
    //if(Logo.frame.isVisible()) {
    //   frame.requestFocus();
    //   }//from   w  ww .  j  av  a2  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.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * Gets the InputEvent-ButtonMask of the given mouse button number
 * @param button the button number/*from w w  w  .  ja va  2  s . c o  m*/
 * @return the InputEvent button mask
 */
private int getButtonMask(int button) {
    switch (button) {
    case InputConstants.MOUSE_BUTTON_LEFT:
        return InputEvent.BUTTON1_MASK;
    case InputConstants.MOUSE_BUTTON_MIDDLE:
        return InputEvent.BUTTON2_MASK;
    case InputConstants.MOUSE_BUTTON_RIGHT:
        return InputEvent.BUTTON3_MASK;
    default:
        throw new RobotException("unsupported mouse button", null); //$NON-NLS-1$
    }
}