List of usage examples for java.awt.event InputEvent BUTTON1_MASK
int BUTTON1_MASK
To view the source code for java.awt.event InputEvent BUTTON1_MASK.
Click Source Link
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Activates itself as a viewer by configuring Size, and location of itself, * and configures the default Tabbed Pane elements with the correct layout, * table columns, and sets itself viewable. *//*w w w . j a v a 2 s. c o m*/ public void activateViewer() { LoggerRepository repo = LogManager.getLoggerRepository(); if (repo instanceof LoggerRepositoryEx) { this.pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry(); } initGUI(); initPrefModelListeners(); /** * We add a simple appender to the MessageCenter logger * so that each message is displayed in the Status bar */ MessageCenter.getInstance().getLogger().addAppender(new AppenderSkeleton() { protected void append(LoggingEvent event) { getStatusBar().setMessage(event.getMessage().toString()); } public void close() { } public boolean requiresLayout() { return false; } }); initSocketConnectionListener(); if (pluginRegistry.getPlugins(Receiver.class).size() == 0) { noReceiversDefined = true; } getFilterableColumns().add(ChainsawConstants.LEVEL_COL_NAME); getFilterableColumns().add(ChainsawConstants.LOGGER_COL_NAME); getFilterableColumns().add(ChainsawConstants.THREAD_COL_NAME); getFilterableColumns().add(ChainsawConstants.NDC_COL_NAME); getFilterableColumns().add(ChainsawConstants.PROPERTIES_COL_NAME); getFilterableColumns().add(ChainsawConstants.CLASS_COL_NAME); getFilterableColumns().add(ChainsawConstants.METHOD_COL_NAME); getFilterableColumns().add(ChainsawConstants.FILE_COL_NAME); getFilterableColumns().add(ChainsawConstants.NONE_COL_NAME); JPanel panePanel = new JPanel(); panePanel.setLayout(new BorderLayout(2, 2)); getContentPane().setLayout(new BorderLayout()); getTabbedPane().addChangeListener(getToolBarAndMenus()); getTabbedPane().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { LogPanel thisLogPanel = getCurrentLogPanel(); if (thisLogPanel != null) { thisLogPanel.updateStatusBar(); } } }); KeyStroke ksRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); KeyStroke ksLeft = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); KeyStroke ksGotoLine = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksRight, "MoveRight"); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksLeft, "MoveLeft"); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksGotoLine, "GotoLine"); Action moveRight = new AbstractAction() { public void actionPerformed(ActionEvent e) { int temp = getTabbedPane().getSelectedIndex(); ++temp; if (temp != getTabbedPane().getTabCount()) { getTabbedPane().setSelectedTab(temp); } } }; Action moveLeft = new AbstractAction() { public void actionPerformed(ActionEvent e) { int temp = getTabbedPane().getSelectedIndex(); --temp; if (temp > -1) { getTabbedPane().setSelectedTab(temp); } } }; Action gotoLine = new AbstractAction() { public void actionPerformed(ActionEvent e) { String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number to go:", "Goto Line", -1); try { int lineNumber = Integer.parseInt(inputLine); int row = getCurrentLogPanel().setSelectedEvent(lineNumber); if (row == -1) { JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error", 0); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error", 0); } } }; getTabbedPane().getActionMap().put("MoveRight", moveRight); getTabbedPane().getActionMap().put("MoveLeft", moveLeft); getTabbedPane().getActionMap().put("GotoLine", gotoLine); /** * We listen for double clicks, and auto-undock currently selected Tab if * the mouse event location matches the currently selected tab */ getTabbedPane().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if ((e.getClickCount() > 1) && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) { int tabIndex = getTabbedPane().getSelectedIndex(); if ((tabIndex != -1) && (tabIndex == getTabbedPane().getSelectedIndex())) { LogPanel logPanel = getCurrentLogPanel(); if (logPanel != null) { logPanel.undock(); } } } } }); panePanel.add(getTabbedPane()); addWelcomePanel(); getContentPane().add(toolbar, BorderLayout.NORTH); getContentPane().add(statusBar, BorderLayout.SOUTH); mainReceiverSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panePanel, receiversPanel); dividerSize = mainReceiverSplitPane.getDividerSize(); mainReceiverSplitPane.setDividerLocation(-1); getContentPane().add(mainReceiverSplitPane, BorderLayout.CENTER); /** * We need to make sure that all the internal GUI components have been added to the * JFrame so that any plugns that get activated during initPlugins(...) method * have access to inject menus */ initPlugins(pluginRegistry); mainReceiverSplitPane.setResizeWeight(1.0); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { exit(); } }); preferencesFrame.setTitle("'Application-wide Preferences"); preferencesFrame.setIconImage(((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage()); preferencesFrame.getContentPane().add(applicationPreferenceModelPanel); preferencesFrame.setSize(750, 520); Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); preferencesFrame.setLocation(new Point((screenDimension.width / 2) - (preferencesFrame.getSize().width / 2), (screenDimension.height / 2) - (preferencesFrame.getSize().height / 2))); pack(); final JPopupMenu tabPopup = new JPopupMenu(); final Action hideCurrentTabAction = new AbstractAction("Hide") { public void actionPerformed(ActionEvent e) { Component selectedComp = getTabbedPane().getSelectedComponent(); if (selectedComp instanceof LogPanel) { displayPanel(getCurrentLogPanel().getIdentifier(), false); tbms.stateChange(); } else { getTabbedPane().remove(selectedComp); } } }; final Action hideOtherTabsAction = new AbstractAction("Hide Others") { public void actionPerformed(ActionEvent e) { Component selectedComp = getTabbedPane().getSelectedComponent(); String currentName; if (selectedComp instanceof LogPanel) { currentName = getCurrentLogPanel().getIdentifier(); } else if (selectedComp instanceof WelcomePanel) { currentName = ChainsawTabbedPane.WELCOME_TAB; } else { currentName = ChainsawTabbedPane.ZEROCONF; } int count = getTabbedPane().getTabCount(); int index = 0; for (int i = 0; i < count; i++) { String name = getTabbedPane().getTitleAt(index); if (getPanelMap().keySet().contains(name) && !name.equals(currentName)) { displayPanel(name, false); tbms.stateChange(); } else { index++; } } } }; Action showHiddenTabsAction = new AbstractAction("Show All Hidden") { public void actionPerformed(ActionEvent e) { for (Iterator iter = getPanels().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); Boolean docked = (Boolean) entry.getValue(); if (docked.booleanValue()) { String identifier = (String) entry.getKey(); int count = getTabbedPane().getTabCount(); boolean found = false; for (int i = 0; i < count; i++) { String name = getTabbedPane().getTitleAt(i); if (name.equals(identifier)) { found = true; break; } } if (!found) { displayPanel(identifier, true); tbms.stateChange(); } } } } }; tabPopup.add(hideCurrentTabAction); tabPopup.add(hideOtherTabsAction); tabPopup.addSeparator(); tabPopup.add(showHiddenTabsAction); final PopupListener tabPopupListener = new PopupListener(tabPopup); getTabbedPane().addMouseListener(tabPopupListener); this.handler.addPropertyChangeListener("dataRate", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { double dataRate = ((Double) evt.getNewValue()).doubleValue(); statusBar.setDataRate(dataRate); } }); getSettingsManager().addSettingsListener(this); getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance()); getSettingsManager().addSettingsListener(receiversPanel); try { //if an uncaught exception is thrown, allow the UI to continue to load getSettingsManager().loadSettings(); } catch (Exception e) { e.printStackTrace(); } //app preferences have already been loaded (and configuration url possibly set to blank if being overridden) //but we need a listener so the settings will be saved on exit (added after loadsettings was called) getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel)); setVisible(true); if (applicationPreferenceModel.isReceivers()) { showReceiverPanel(); } else { hideReceiverPanel(); } removeSplash(); synchronized (initializationLock) { isGUIFullyInitialized = true; initializationLock.notifyAll(); } if (noReceiversDefined && applicationPreferenceModel.isShowNoReceiverWarning()) { SwingHelper.invokeOnEDT(new Runnable() { public void run() { showReceiverConfigurationPanel(); } }); } Container container = tutorialFrame.getContentPane(); final JEditorPane tutorialArea = new JEditorPane(); tutorialArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tutorialArea.setEditable(false); container.setLayout(new BorderLayout()); try { tutorialArea.setPage(ChainsawConstants.TUTORIAL_URL); JTextComponentFormatter.applySystemFontAndSize(tutorialArea); container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER); } catch (Exception e) { MessageCenter.getInstance().getLogger().error("Error occurred loading the Tutorial", e); } tutorialFrame.setIconImage(new ImageIcon(ChainsawIcons.HELP).getImage()); tutorialFrame.setSize(new Dimension(640, 480)); final Action startTutorial = new AbstractAction("Start Tutorial", new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "This will start 3 \"Generator\" receivers for use in the Tutorial. Is that ok?", "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { new Thread(new Tutorial()).start(); putValue("TutorialStarted", Boolean.TRUE); } else { putValue("TutorialStarted", Boolean.FALSE); } } }; final Action stopTutorial = new AbstractAction("Stop Tutorial", new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched. Is that ok?", "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { new Thread(new Runnable() { public void run() { LoggerRepository repo = LogManager.getLoggerRepository(); if (repo instanceof LoggerRepositoryEx) { PluginRegistry pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry(); List list = pluginRegistry.getPlugins(Generator.class); for (Iterator iter = list.iterator(); iter.hasNext();) { Plugin plugin = (Plugin) iter.next(); pluginRegistry.stopPlugin(plugin.getName()); } } } }).start(); setEnabled(false); startTutorial.putValue("TutorialStarted", Boolean.FALSE); } } }; stopTutorial.putValue(Action.SHORT_DESCRIPTION, "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched"); startTutorial.putValue(Action.SHORT_DESCRIPTION, "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action"); stopTutorial.setEnabled(false); final SmallToggleButton startButton = new SmallToggleButton(startTutorial); PropertyChangeListener pcl = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { stopTutorial.setEnabled(((Boolean) startTutorial.getValue("TutorialStarted")).equals(Boolean.TRUE)); startButton.setSelected(stopTutorial.isEnabled()); } }; startTutorial.addPropertyChangeListener(pcl); stopTutorial.addPropertyChangeListener(pcl); pluginRegistry.addPluginListener(new PluginListener() { public void pluginStarted(PluginEvent e) { } public void pluginStopped(PluginEvent e) { List list = pluginRegistry.getPlugins(Generator.class); if (list.size() == 0) { startTutorial.putValue("TutorialStarted", Boolean.FALSE); } } }); final SmallButton stopButton = new SmallButton(stopTutorial); final JToolBar tutorialToolbar = new JToolBar(); tutorialToolbar.setFloatable(false); tutorialToolbar.add(startButton); tutorialToolbar.add(stopButton); container.add(tutorialToolbar, BorderLayout.NORTH); tutorialArea.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e.getDescription().equals("StartTutorial")) { startTutorial.actionPerformed(null); } else if (e.getDescription().equals("StopTutorial")) { stopTutorial.actionPerformed(null); } else { try { tutorialArea.setPage(e.getURL()); } catch (IOException e1) { MessageCenter.getInstance().getLogger() .error("Failed to change the URL for the Tutorial", e1); } } } } }); /** * loads the saved tab settings and if there are hidden tabs, * hide those tabs out of currently loaded tabs.. */ if (!getTabbedPane().tabSetting.isWelcome()) { displayPanel(ChainsawTabbedPane.WELCOME_TAB, false); } if (!getTabbedPane().tabSetting.isZeroconf()) { displayPanel(ChainsawTabbedPane.ZEROCONF, false); } tbms.stateChange(); }
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.//from w w w .ja va2 s .c o 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:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_/*from w ww .ja v a 2 s .c o m*/ * * @param event _more_ * * @throws RemoteException _more_ * @throws VisADException _more_ */ public void displayChanged(DisplayEvent event) throws VisADException, RemoteException { if (!isActive()) { return; } double[] viewpoint = viewManager.getDisplayMatrix(); if (!Misc.arraysEquals(viewpoint, lastViewpoint)) { lastViewpoint = viewpoint; updateDashboard(); } if (goToClick && (event.getId() == DisplayEvent.MOUSE_PRESSED)) { InputEvent inputEvent = event.getInputEvent(); int mods = inputEvent.getModifiers(); if ((mods & InputEvent.BUTTON1_MASK) != 0 && !inputEvent.isShiftDown() && !inputEvent.isControlDown()) { NavigatedDisplay navDisplay = viewManager.getNavigatedDisplay(); location = navDisplay.screenToEarthLocation(event.getX(), event.getY()); doDrive(false, heading); } } }
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 ww w . ja v a2 s . co 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:ExText.java
/** * Process a new wakeup. Interpret mouse button presses, releases, and mouse * drags.// w ww .j a v a 2 s. c o m * * @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:gda.plots.SimplePlot.java
/** * Part of the implementation of MouseMotionListener - overrides the super class (ChartPanel) implementation so that * the mouse can be used to select a rectangle as well as for zooming. * /* w ww . j av a 2 s . c o m*/ * @param e * the mouse event which caused the call */ @Override public void mouseDragged(MouseEvent e) { // If the rectangle dragger is not in operation then call the // super class method (to deal with any possible zooming) then // deal with magnifyingImage or magnifyingData. if (rd == null) { super.mouseDragged(e); if ((magnifyingImage || magnifyingData) && (e.getModifiers() & InputEvent.BUTTON3_MASK) == 0) { Graphics2D g2 = (Graphics2D) getGraphics(); g2.setXORMode(dragColour); if (magnifyRectangle != null) { if (magnifyRectangleIsNew) { magnifyRectangleIsNew = false; } else { g2.fill(magnifyRectangle); } } if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { magnifyWidth = e.getX() - magnifyXPoint; magnifyHeight = e.getY() - magnifyYPoint; } recalculateMagnifyRectangle(e); if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0) { magnifier.update(magnifyRectangle); } if (magnifyRectangle != null) { g2.fill(magnifyRectangle); } g2.dispose(); } } else { rd.mouseDragged(e); } }
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. j a v a 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.BedTable.java
@Override public void mouseClicked(MouseEvent event) { switch (event.getModifiers()) { case InputEvent.BUTTON1_MASK: { if (!this.isEnabled()) { break; }/*from 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(); } } }
From source file:com.virtusa.isq.rft.runtime.RFTCommandBase.java
/** * Performs a Java robot click on the specific coordinates. <br> * /*from w w w . j a v a 2 s .c o m*/ * @param resolution * the resolution * @param coordinates * the coordinates * @param waitTime * the wait time * @throws Exception * the exception */ @Override public final void mouseMoveAndClick(final String resolution, final String coordinates, final String waitTime) { String res = resolution; final int f11KeyCode = KeyEvent.VK_F11; final int optimumPauseBetweenkeyCombs = 10; String[] resArr = res.split(","); String[] coordinatesArr = coordinates.split(","); float screenWidht = Float.parseFloat(resArr[0]); float screeHigt = Float.parseFloat(resArr[1]); float xCordinate = Float.parseFloat(coordinatesArr[0]); float yCordinate = Float.parseFloat(coordinatesArr[1]); String command = ""; if (coordinatesArr.length > 2) { command = coordinatesArr[2]; } Robot robot = null; try { robot = new Robot(); } catch (AWTException e) { e.printStackTrace(); } Utils.pause(Integer.parseInt(waitTime)); int xCordinateAutual = (int) calWidth(screenWidht, xCordinate); int yCordinateAutual = (int) calHight(screeHigt, yCordinate); robot.keyPress(f11KeyCode); robot.delay(optimumPauseBetweenkeyCombs); robot.keyRelease(f11KeyCode); Utils.pause(retryInterval); // Mouse Move robot.mouseMove(xCordinateAutual, yCordinateAutual); // Click if ("".equals(command)) { robot.mousePress(InputEvent.BUTTON1_MASK); Utils.pause(retryInterval); robot.mouseRelease(InputEvent.BUTTON1_MASK); reportResults(ReportLogger.ReportLevel.SUCCESS, "Mouse Move And Click", "Success", "Resolution : " + res); } else if ("dclick".equals(command.toLowerCase(Locale.getDefault()))) { robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); final int optimumPauseBetweenDclick = 500; robot.delay(optimumPauseBetweenDclick); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); reportResults(true, ReportLogger.ReportLevel.SUCCESS, "Mouse Move And Click", "Success", "Resolution : " + res); } robot.keyPress(f11KeyCode); robot.delay(optimumPauseBetweenkeyCombs); robot.keyRelease(f11KeyCode); }
From source file:base.BasePlayer.AminoTable.java
@Override public void mousePressed(MouseEvent event) { switch (event.getModifiers()) { case InputEvent.BUTTON1_MASK: { if (!this.isEnabled()) { break; }/*from w ww.j a va 2s .c om*/ 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(genearray, sorter); createPolygon(); } repaint(); } } if (hoverNode != null || hoverVar != null) { Main.chromDraw.repaint(); } } }