List of usage examples for java.awt.event MouseEvent getX
public int getX()
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Handles a 'mouse pressed' event.//from w ww .j a va 2 s.c om * <P> * This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse * released' event. * * @param e * The mouse event. */ @Override public void mousePressed(MouseEvent e) { if (this.chart == null) { return; } Plot plot = this.chart.getPlot(); int mods = e.getModifiers(); if ((mods & this.panMask) == this.panMask) { // can we pan this plot? if (plot instanceof Pannable) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null && screenDataArea.contains(e.getPoint())) { this.panW = screenDataArea.getWidth(); this.panH = screenDataArea.getHeight(); this.panLast = e.getPoint(); setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } } } else if (this.selectionRectangle == null) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.zoomPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea); } else { this.zoomPoint = null; } if (e.isPopupTrigger()) { if (this.popup != null) { displayPopupMenu(e.getX(), e.getY()); } } } }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the * rows if no row was selected./*from ww w .ja v a2 s. co m*/ */ private void checkAttachmentSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = attachmentTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row == -1) { deselectAttachmentRows(); } if (evt.isPopupTrigger()) { if (row != -1) { attachmentTable.setRowSelectionInterval(row, row); } attachmentPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the * rows if no row was selected.//from w w w . j a v a2 s .co m */ private void checkMessageSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = messageTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row == -1) { deselectRows(); } if (evt.isPopupTrigger()) { if (row != -1) { messageTreeTable.setRowSelectionInterval(row, row); } parent.messagePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:net.rptools.maptool.client.ui.MapToolFrame.java
private AssetPanel createAssetPanel() { final AssetPanel panel = new AssetPanel("mainAssetPanel"); panel.addImagePanelMouseListener(new MouseAdapter() { @Override/*from w w w . j a v a 2s. co m*/ public void mouseReleased(MouseEvent e) { // TODO use for real popup logic // if (SwingUtilities.isLeftMouseButton(e)) { // if (e.getClickCount() == 2) { // // List<Object> idList = panel.getSelectedIds(); // if (idList == null || idList.size() == 0) { // return; // } // // final int index = (Integer) idList.get(0); // createZone(panel.getAsset(index)); // } // } if (SwingUtilities.isRightMouseButton(e) && MapTool.getPlayer().isGM()) { List<Object> idList = panel.getSelectedIds(); if (idList == null || idList.size() == 0) { return; } final int index = (Integer) idList.get(0); JPopupMenu menu = new JPopupMenu(); menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, I18N.getText("action.newMap")); } public void actionPerformed(ActionEvent e) { createZone(panel.getAsset(index)); } })); panel.showImagePanelPopup(menu, e.getX(), e.getY()); } } private void createZone(Asset asset) { Zone zone = ZoneFactory.createZone(); zone.setName(asset.getName()); BufferedImage image = ImageManager.getImageAndWait(asset.getId()); if (image.getWidth() < 200 || image.getHeight() < 200) { zone.setBackgroundPaint(new DrawableTexturePaint(asset)); } else { zone.setMapAsset(asset.getId()); zone.setBackgroundPaint(new DrawableColorPaint(Color.black)); } MapPropertiesDialog newMapDialog = new MapPropertiesDialog(MapTool.getFrame()); newMapDialog.setZone(zone); newMapDialog.setVisible(true); if (newMapDialog.getStatus() == MapPropertiesDialog.Status.OK) { MapTool.addZone(zone); } } }); return panel; }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
/** * Sets the properties and adds the listeners for the Mappings Table. No data is loaded at this * point./* w w w .jav a 2s . co m*/ */ private void makeMappingsTable() { updateMappingsTable(null, true); // listen for trigger button and double click to edit channel. mappingsTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { if (mappingsTable.rowAtPoint(new Point(evt.getX(), evt.getY())) == -1) { return; } if (evt.getClickCount() >= 2) { new ViewContentDialog((String) mappingsTable.getModel() .getValueAt(mappingsTable.convertRowIndexToModel(mappingsTable.getSelectedRow()), 2)); } } }); mappingsTable.setSelectionMode(0); mappingsTable.getColumnExt(SCOPE_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH); mappingsTable.getColumnExt(SCOPE_COLUMN_NAME).setMaxWidth(UIConstants.MAX_WIDTH); // Disable HTML in a column. DefaultTableCellRenderer noHTMLRenderer = new DefaultTableCellRenderer(); noHTMLRenderer.putClientProperty("html.disable", Boolean.TRUE); mappingsTable.getColumnExt(VALUE_COLUMN_NAME).setCellRenderer(noHTMLRenderer); mappingsPane.setViewportView(mappingsTable); }
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
/** * Creates a new {@link AttributeStatisticsPanel} instance. Before displaying the panel, an * {@link AbstractAttributeStatisticsModel} should be set via * {@link #setModel(AbstractAttributeStatisticsModel, boolean)}. * *//* w w w . j av a 2 s . c o m*/ public AttributeStatisticsPanel() { listOfChartPanels = new LinkedList<>(); // create listener which listens for hovering/enlarge mouse events on this panel enlargeAndHoverAndPopupMouseAdapter = new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { // only popup trigger for popup menu if (e.isPopupTrigger()) { handlePopup(e); } // only left mouse button to enlarge if (!SwingUtilities.isLeftMouseButton(e)) { return; } // little hack so hovering over the details button does not remove the hover effect // (because MouseExited is called) // but clicking the button is still possible and does not enlarge the panel if (e.getSource() instanceof JButton) { ((JButton) e.getSource()).doClick(); return; } // change enlarged status if (getModel() != null) { getModel().setEnlarged(!getModel().isEnlarged()); } } @Override public void mouseExited(final MouseEvent e) { if (SwingTools.isMouseEventExitedToChildComponents(AttributeStatisticsPanel.this, e)) { // we are still hovering over the ASP, just a child component return; } hovered = false; repaint(); } @Override public void mouseEntered(final MouseEvent e) { hovered = true; repaint(); } @Override public void mouseReleased(final MouseEvent e) { if (e.isPopupTrigger()) { handlePopup(e); } } /** * Handles the popup click event. * * @param e */ private void handlePopup(final MouseEvent e) { if (model.getAttribute().isNumerical()) { popupAttributeNumericalStatPanel.show(e.getComponent(), e.getX(), e.getY()); } else if (model.getAttribute().isNominal()) { popupAttributeNominalStatPanel.show(e.getComponent(), e.getX(), e.getY()); } else if (model.getAttribute().isDateTime()) { popupAttributeDateTimeStatPanel.show(e.getComponent(), e.getX(), e.getY()); } } }; // create listener which listens for AttributeStatisticsEvents on the model listener = new AttributeStatisticsEventListener() { @Override public void modelChanged(final AttributeStatisticsEvent e) { switch (e.getEventType()) { case ALTERNATING_CHANGED: repaint(); break; case ENLARGED_CHANGED: updateCharts(); updateVisibilityOfChartPanels(); if (AttributeStatisticsPanel.this.model.getAttribute().isNominal()) { displayNominalValues(); } break; case SHOW_CONSTRUCTION_CHANGED: panelStatsConstruction.setVisible(model.isShowConstruction()); break; case STATISTICS_CHANGED: SwingUtilities.invokeLater(new Runnable() { @Override public void run() { AbstractAttributeStatisticsModel model = AttributeStatisticsPanel.this.model; if (model.getAttribute().isNumerical()) { updateNumericalElements(model); } else if (model.getAttribute().isNominal()) { updateNominalElements(model); } else { updateDateTimeElements(model); } } }); break; default: } } }; initGUI(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Handles a 'mouse dragged' event.//from ww w. j av a 2 s . co m * * @param e * the mouse event. */ public void mouseDragged(MouseEvent e) { // if the popup menu has already been triggered, then ignore dragging... if (this.popup != null && this.popup.isShowing()) { return; } // if no initial zoom point was set, ignore dragging... if (this.zoomPoint == null) { return; } Graphics2D g2 = (Graphics2D) getGraphics(); // Erase the previous zoom rectangle (if any)... drawZoomRectangle(g2); boolean hZoom = false; boolean vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } Rectangle2D scaledDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); this.zoomRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), this.zoomPoint.getY(), xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY()); } else if (hZoom) { double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); this.zoomRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), scaledDataArea.getMinY(), xmax - this.zoomPoint.getX(), scaledDataArea.getHeight()); } else if (vZoom) { double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); this.zoomRectangle = new Rectangle2D.Double(scaledDataArea.getMinX(), this.zoomPoint.getY(), scaledDataArea.getWidth(), ymax - this.zoomPoint.getY()); } // Draw the new zoom rectangle... drawZoomRectangle(g2); g2.dispose(); }
From source file:GUI.MainWindow.java
private void handleAffectedHosts(MouseEvent evt) { Object obj = this.VulnTree.getLastSelectedPathComponent(); if (obj == null) { return;//from www.ja v a 2 s . com } int row = VulnAffectedHostsTable.getSelectedRow(); if (row == -1) // No vulns selected { // Setup the context menu as required EditHostname.setEnabled(false); DeleteHost.setEnabled(false); } else { // A vuln is selected // Setup the context menu as required EditHostname.setEnabled(true); DeleteHost.setEnabled(true); } if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { // this was a double click on the try showNotesForSpecificHost(); } else if (evt.getButton() == MouseEvent.BUTTON3) { VulnAffectedHostsContextMenu.show(VulnAffectedHostsTable, evt.getX(), evt.getY()); } }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
private void showPasswordMenu(MouseEvent e) { try {//from w w w .j av a2 s. com JPopupMenu passwordMenu = new JPopupMenu(); JMenuItem copyItem = new JMenuItem("Copy"); passwordMenu.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { StringSelection stringSelection = new StringSelection(passwordField.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, JWeblinkEditor.this); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); JMenuItem encodeItem = new JMenuItem("Encrypt/decrypt"); passwordMenu.add(encodeItem); encodeItem.setHorizontalTextPosition(JMenuItem.RIGHT); encodeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { save(); JTextEncrypter te = new JTextEncrypter(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, passwordField.getText()); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT_TITLE, nameField.getText()); String weLocator$ = JWeblinkEditor.this.getLocator(); weLocator$ = Locator.append(weLocator$, BaseHandler.HANDLER_METHOD, "response"); weLocator$ = Locator.append(weLocator$, JRequester.REQUESTER_ACTION, ACTION_ENCODE_PASSWORD); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(weLocator$)); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); passwordMenu.show(e.getComponent(), e.getX(), e.getY()); } catch (Exception ee) { Logger.getLogger(getClass().getName()).severe(ee.toString()); } }
From source file:net.sf.jabref.gui.maintable.MainTableSelectionListener.java
/** * Process popup trigger events occurring on an icon cell in the table. Show a menu where the user can choose which * external resource to open for the entry. If no relevant external resources exist, let the normal popup trigger * handler do its thing instead./* w w w . ja v a2s .c o m*/ * * @param e The mouse event defining this popup trigger. * @param row The row where the event occurred. * @param column the MainTableColumn associated with this table cell. */ private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn column) { BibEntry entry = tableRows.get(row); JPopupMenu menu = new JPopupMenu(); boolean showDefaultPopup = true; // See if this is a simple file link field, or if it is a file-list // field that can specify a list of links: if (!column.getBibtexFields().isEmpty()) { for (String field : column.getBibtexFields()) { if (FieldName.FILE.equals(field)) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); entry.getFieldOptional(field).ifPresent(fileList::setContent); for (int i = 0; i < fileList.getRowCount(); i++) { FileListEntry flEntry = fileList.getEntry(i); if (column.isFileFilter() && (!flEntry.type.get().getName().equalsIgnoreCase(column.getColumnName()))) { continue; } String description = flEntry.description; if ((description == null) || (description.trim().isEmpty())) { description = flEntry.link; } menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.link, flEntry.type.get().getIcon(), panel.getBibDatabaseContext(), flEntry.type)); showDefaultPopup = false; } } else { if (SpecialFieldsUtils.isSpecialField(column.getColumnName())) { // full pop should be shown as left click already shows short popup showDefaultPopup = true; } else { if (entry.hasField(field)) { String content = entry.getField(field); Icon icon; JLabel iconLabel = GUIGlobals.getTableIcon(field); if (iconLabel == null) { icon = IconTheme.JabRefIcon.FILE.getIcon(); } else { icon = iconLabel.getIcon(); } menu.add(new ExternalFileMenuItem(panel.frame(), entry, content, content, icon, panel.getBibDatabaseContext(), field)); showDefaultPopup = false; } } } } if (showDefaultPopup) { processPopupTrigger(e, row); } else { menu.show(table, e.getX(), e.getY()); } } }