List of usage examples for java.awt.event MouseEvent getModifiers
@Deprecated(since = "9") public int getModifiers()
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
@SuppressWarnings("unused") public void mouseDragged(MouseEvent e) { if (threeButton) { if (threeBstate != s) { if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null;/* w w w. ja va 2 s .c o m*/ threeBstate = s; } else if (threeBstate == spp) { e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } else if (threeBstate == sppr) { return; } } } int x = e.getX() + window.x; int y = e.getY() + window.y; XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); // button 1 -> 16 // button 2 -> 8 // button 3 -> 4 // shift -> 1 // control -> 2 // alt -> 12 ?? 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 = state; px = x; py = y; event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/ XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1); try { if (!XWindow.checkMotion(event, window)) { return; } event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/ XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, //e.getX(), //e.getY(), state, 1); if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1); } catch (Exception ee) { } }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void mousePressed(MouseEvent e) { if (threeButton) { if (threeBstate == s) { threeBPressed = e;//from w w w. ja v a2s . c o m threeBstate = sp; return; } if (threeBstate == sp // || threeBstate==sppr ) { threeBPressed = null; threeBstate = spp; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } procPressed(e); }
From source file:com.jcraft.weirdx.DDXWindowImp.java
@SuppressWarnings("unused") public void mouseDragged(MouseEvent e) { if (threeButton) { if (threeBstate != s) { if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null;//from w w w . ja v a 2 s . co m threeBstate = s; } else if (threeBstate == spp) { e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } else if (threeBstate == sppr) { return; } } } if (window == null) return; // calc abs cursor position use old window position for calculation // as mouseDragged (if you use Panel) delivers its coordinates relative to the position after mousepressed // UPDATE: this was a bug of the IBM JDK // int x=e.getX()+oldwindowx; // int y=e.getY()+oldwindowy; int x = e.getX() + window.x; int y = e.getY() + window.y; // set new drag position (absolute) XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); // button 1 -> 16 // button 2 -> 8 // button 3 -> 4 // shift -> 1 // control -> 2 // alt -> 12 ?? 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 = state; px = x; py = y; event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1); try { if (!XWindow.checkMotion(event, window)) { return; } event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, state, 1); if (XWindow.grab != null) { XWindow.sendGrabbedEvent(event, false, 1); } else { XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1); } } catch (Exception ee) { } }
From source file:base.BasePlayer.ClusterTable.java
public void mouseClicked(MouseEvent event) { switch (event.getModifiers()) { case InputEvent.BUTTON1_MASK: { if (!this.isEnabled()) { break; }//from ww w . java 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); 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:com.jcraft.weirdx.DDXWindowImpSwing.java
public void mouseReleased(MouseEvent e) { if (threeButton) { if (threeBstate == sppr) { threeBPressed = null;// w ww.ja va 2 s. c o m threeBstate = s; return; } if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null; threeBstate = s; } else if (threeBstate == spp) { threeBPressed = null; threeBstate = sppr; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } procReleased(e); }
From source file:javazoom.jlgui.player.amp.playlist.ui.PlaylistUI.java
/** * Handle mouse clicks on playlist.//from ww w. j a va 2 s . co m * @param evt */ protected void handleMouseClick(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); ui.getAcPlAddPopup().setVisible(false); ui.getAcPlAdd().setVisible(true); ui.getAcPlRemovePopup().setVisible(false); ui.getAcPlRemove().setVisible(true); ui.getAcPlSelectPopup().setVisible(false); ui.getAcPlSelect().setVisible(true); ui.getAcPlMiscPopup().setVisible(false); ui.getAcPlMisc().setVisible(true); ui.getAcPlListPopup().setVisible(false); ui.getAcPlList().setVisible(true); // Check select action if (ui.getPlaylistPanel().isInSelectArea(x, y)) { int index = getIndex(y); if (index != -1) { // PopUp if (javax.swing.SwingUtilities.isRightMouseButton(evt)) { if (fipopup != null) fipopup.show(this, x, y); } else { PlaylistItem pli = playlist.getItemAt(index); if (pli != null) { pli.setSelected(!pli.isSelected()); if ((evt.getClickCount() == 2) && (evt.getModifiers() == MouseEvent.BUTTON1_MASK)) { player.pressStop(); player.setCurrentSong(pli); playlist.setCursor(index); player.pressStart(); } } } repaint(); } } }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void mouseReleased(MouseEvent e) { if (threeButton) { if (threeBstate == sppr) { threeBPressed = null;/* w w w . j ava2 s . c om*/ threeBstate = s; return; } if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null; threeBstate = s; } else if (threeBstate == spp) { threeBPressed = null; threeBstate = sppr; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } try { procReleased(e); } catch (Exception ee) { } }
From source file:base.BasePlayer.BedTable.java
@Override public void mousePressed(MouseEvent event) { switch (event.getModifiers()) { case InputEvent.BUTTON1_MASK: { if (!this.isEnabled()) { break; }// ww w.j av a 2 s . co m this.dragX = event.getX(); if (headerHover > -1) { if (resizeColumn == -1) { if (sorter.ascending) { sorter.ascending = false; } else { sorter.ascending = true; } sorter.index = headerHover; Collections.sort(bedarray, sorter); createPolygon(); repaint(); } } } if (hoverNode != null || hoverVar != null) { Main.chromDraw.repaint(); } } }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java
/** * When a right button click is performed in the editor pane, a popup menu * is opened.// ww w.ja va2 s . co m * In case of the Scheme being internal, it won't open the Browser but * instead it will trigger the forwarded action. * * @param e The MouseEvent. */ public void mouseClicked(MouseEvent e) { Point p = e.getPoint(); SwingUtilities.convertPointToScreen(p, e.getComponent()); if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { openContextMenu(p); } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && currentHref != null && currentHref.length() != 0) { URI uri; try { uri = new URI(currentHref); } catch (URISyntaxException e1) { logger.error( "Failed to open hyperlink in chat window. " + "Error was: Invalid URL - " + currentHref); return; } if ("jitsi".equals(uri.getScheme())) { for (ChatLinkClickedListener l : chatLinkClickedListeners) { l.chatLinkClicked(uri); } } else GuiActivator.getBrowserLauncher().openURL(currentHref); // after opening the link remove the currentHref to avoid // clicking on the window to gain focus to open the link again this.currentHref = ""; } }
From source file:base.BasePlayer.BedTable.java
@Override public void mouseClicked(MouseEvent event) { switch (event.getModifiers()) { case InputEvent.BUTTON1_MASK: { if (!this.isEnabled()) { break; }/*w w 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(); } } }