List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:savant.view.swing.GraphPane.java
/** * {@inheritDoc}//from ww w. j av a 2s . c om */ @Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { LocationController.getInstance().zoomInOnMouse(); return; } trySelect(event.getPoint()); setMouseModifier(event); }
From source file:com.sciaps.view.SpectrumShotPanel.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.// ww w. j ava 2 s. c o m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; btnCreateAvg_ = new javax.swing.JButton(); btnHideShot_ = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); btnDeleteScan_ = new javax.swing.JButton(); btnDelete_ = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); tblShots_ = new JTable() { //Implement table cell tool tips. @Override public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); try { tip = getValueAt(rowIndex, colIndex).toString(); } catch (RuntimeException e1) { //catch null pointer exception if mouse is over an empty line } return tip; } }; btnShowShotl_ = new javax.swing.JButton(); btnBackgroundRemoval_ = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); txtSampleRate_ = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); txtFilterText_ = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); btnBackgroundRemoval_1 = new javax.swing.JButton(); btnBackgroundRemoval_2 = new javax.swing.JButton(); btnAnalyze_ = new javax.swing.JButton(); setMaximumSize(new java.awt.Dimension(160, 190)); setMinimumSize(new java.awt.Dimension(160, 190)); setPreferredSize(new java.awt.Dimension(160, 190)); setLayout(new java.awt.GridBagLayout()); btnCreateAvg_.setText("Create Shot Avg"); btnCreateAvg_.setToolTipText("Create An Avg of All Highlighted"); btnCreateAvg_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnCreateAvg_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCreateAvg_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 14; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnCreateAvg_, gridBagConstraints); btnHideShot_.setText("Hide Shot(s)"); btnHideShot_.setToolTipText("Hide Shot Series"); btnHideShot_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnHideShot_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnHideShot_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 12; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnHideShot_, gridBagConstraints); jLabel1.setBackground(new java.awt.Color(204, 204, 204)); jLabel1.setText("Shot List:"); jLabel1.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(jLabel1, gridBagConstraints); btnDeleteScan_.setText("Delete Scan"); btnDeleteScan_.setToolTipText("Delete All Shots In A Scan"); btnDeleteScan_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnDeleteScan_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDeleteScan_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 10; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnDeleteScan_, gridBagConstraints); btnDelete_.setText("Delete Shot(s)"); btnDelete_.setToolTipText("Delete Shot(s)"); btnDelete_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnDelete_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDelete_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 13; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnDelete_, gridBagConstraints); jLabel2.setBackground(new java.awt.Color(204, 204, 204)); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Scan Data"); jLabel2.setFocusable(false); jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jLabel2.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); add(jLabel2, gridBagConstraints); tblShots_ .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); tblShots_.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tblShots_MouseClicked(evt); } }); jScrollPane2.setViewportView(tblShots_); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(jScrollPane2, gridBagConstraints); btnShowShotl_.setText("Show Shot(s)"); btnShowShotl_.setToolTipText("Show Shot Series"); btnShowShotl_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnShowShotl_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnShowShotl_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 11; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnShowShotl_, gridBagConstraints); btnBackgroundRemoval_.setText("Background Removal"); btnBackgroundRemoval_.setToolTipText("Remove background noise for the selected shots"); btnBackgroundRemoval_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnBackgroundRemoval_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBackgroundRemoval_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnBackgroundRemoval_, gridBagConstraints); jPanel1.setLayout(new java.awt.GridBagLayout()); txtSampleRate_.setText("30"); txtSampleRate_.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { txtSampleRate_KeyReleased(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 0, 1, 0); jPanel1.add(txtSampleRate_, gridBagConstraints); jLabel3.setBackground(new java.awt.Color(204, 204, 204)); jLabel3.setText("Sample Rate:"); jLabel3.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5); jPanel1.add(jLabel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0); jPanel1.add(txtFilterText_, gridBagConstraints); jLabel4.setBackground(new java.awt.Color(204, 204, 204)); jLabel4.setText("Filter:"); jLabel4.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 5); jPanel1.add(jLabel4, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; add(jPanel1, gridBagConstraints); btnBackgroundRemoval_1.setText("Find Peak"); btnBackgroundRemoval_1.setToolTipText("Find the peaks"); btnBackgroundRemoval_1.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnBackgroundRemoval_1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBackgroundRemoval_1ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnBackgroundRemoval_1, gridBagConstraints); btnBackgroundRemoval_2.setText("Normalize Spectrum"); btnBackgroundRemoval_2.setToolTipText("Normalize a spectrum"); btnBackgroundRemoval_2.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnBackgroundRemoval_2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBackgroundRemoval_2ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnBackgroundRemoval_2, gridBagConstraints); btnAnalyze_.setText("Analyze"); btnAnalyze_.setToolTipText("Analyze a spectrum"); btnAnalyze_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnAnalyze_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAnalyze_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnAnalyze_, gridBagConstraints); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
public void fileTableClicked(FileObjectTableModel fileObjectTableModel, JTableX<FileObject> table, MouseEvent e) { int row = table.convertRowIndexToModel(table.rowAtPoint(e.getPoint())); //int column = table.convertColumnIndexToModel(table.columnAtPoint(e.getPoint())); final Collection<FileObject> selectedFileObjects = table.getSelectedObjects(); final FileObject f = fileObjectTableModel.getRowObjects().get(row); if (SwingUtilities.isRightMouseButton(e)) { JPopupMenu m = new JPopupMenu(); {/*from ww w .j av a 2s .c o m*/ JMenuItem menuitem = new JMenuItem("ffnen"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(f); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("Ordner ffnen"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFolder(f); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("Herunterladen (ber SOAP)"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { downloadFiles(selectedFileObjects, DownloadMethod.WEBSERVICE); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("Herunterladen (ber WEBDAV)"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!syncService.getIliasSoapService().isWebdavAuthenticationActive()) { syncService.getIliasSoapService().enableWebdavAuthentication( mainFrame.getFieldLogin().getText(), mainFrame.getFieldPassword().getPassword()); } downloadFiles(selectedFileObjects, DownloadMethod.WEBDAV); } }); m.add(menuitem); } { JMenuItem menuitem = new JMenuItem("In Ilias ffnen"); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openInIlias(f); } }); m.add(menuitem); } { m.add(new JSeparator()); } { JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem("Ignorieren"); menuitem.setSelected(iliasProperties.getBlockedFiles().contains(f.getRefId())); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { switchIgnoreState(selectedFileObjects); } }); m.add(menuitem); } { m.add(new JSeparator()); } { JMenuItem menuitem = new JMenuItem("Fehler anzeigen"); menuitem.setEnabled(f.getException() != null); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showError("Fehler bei " + f.getTargetFile().getAbsolutePath(), f.getException()); } }); m.add(menuitem); } m.show(table, e.getX(), e.getY()); } if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) { openFile(f); } }
From source file:de.tor.tribes.ui.panels.MinimapPanel.java
/** * Creates new form MinimapPanel/*from w w w . ja va 2 s . c o m*/ */ MinimapPanel() { initComponents(); setSize(300, 300); mMinimapListeners = new LinkedList<>(); mToolChangeListeners = new LinkedList<>(); setCursor(ImageManager.getCursor(iCurrentCursor)); mScreenshotPanel = new ScreenshotPanel(); minimapButtons.put(ID_MINIMAP, new Rectangle(2, 2, 26, 26)); minimapButtons.put(ID_ALLY_CHART, new Rectangle(30, 2, 26, 26)); minimapButtons.put(ID_TRIBE_CHART, new Rectangle(60, 2, 26, 26)); try { minimapIcons.put(ID_MINIMAP, ImageIO.read(new File("./graphics/icons/minimap.png"))); minimapIcons.put(ID_ALLY_CHART, ImageIO.read(new File("./graphics/icons/ally_chart.png"))); minimapIcons.put(ID_TRIBE_CHART, ImageIO.read(new File("./graphics/icons/tribe_chart.png"))); } catch (Exception ignored) { } jPanel1.add(mScreenshotPanel); rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); zoomed = false; MarkerManager.getSingleton().addManagerListener(this); TagManager.getSingleton().addManagerListener(this); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); if (!GlobalOptions.isMinimal()) { MinimapRepaintThread.getSingleton().start(); } addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (!showControls && e.getButton() != MouseEvent.BUTTON1) { //show controls Point p = e.getPoint(); p.translate(-5, -5); showControls(p); return; } if (!showControls && iCurrentView == ID_MINIMAP) { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.getX(), p.getY()); MapPanel.getSingleton().getMapRenderer().initiateRedraw(MapRenderer.ALL_LAYERS); if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().toFront(); } } else { if (minimapButtons.get(ID_MINIMAP).contains(e.getPoint())) { iCurrentView = ID_MINIMAP; mBuffer = null; showControls = false; MinimapRepaintThread.getSingleton().update(); } else if (minimapButtons.get(ID_ALLY_CHART).contains(e.getPoint())) { iCurrentView = ID_ALLY_CHART; lastHash = 0; showControls = false; updateComplete(); } else if (minimapButtons.get(ID_TRIBE_CHART).contains(e.getPoint())) { iCurrentView = ID_TRIBE_CHART; lastHash = 0; showControls = false; updateComplete(); } } } @Override public void mousePressed(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT || iCurrentCursor == ImageManager.CURSOR_ZOOM) { iXDown = e.getX(); iYDown = e.getY(); } } @Override public void mouseReleased(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (rDrag == null) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT) { try { BufferedImage i = MinimapRepaintThread.getSingleton().getImage(); double widthFactor = ((double) ServerSettings.getSingleton().getMapDimension().width) / getWidth(); double heightFactor = ((double) ServerSettings.getSingleton().getMapDimension().height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX()); int y = (int) Math.rint(heightFactor * rDrag.getY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); int h = (int) Math.rint(heightFactor * (rDrag.getHeight() - rDrag.getY())); BufferedImage sub = i.getSubimage(x, y, w, h); mScreenshotPanel.setBuffer(sub); jPanel1.setSize(mScreenshotPanel.getSize()); jPanel1.setPreferredSize(mScreenshotPanel.getSize()); jPanel1.setMinimumSize(mScreenshotPanel.getSize()); jPanel1.setMaximumSize(mScreenshotPanel.getSize()); jScreenshotPreview.pack(); jScreenshotControl.pack(); jScreenshotPreview.setVisible(true); jScreenshotControl.setVisible(true); } catch (Exception ie) { logger.error("Failed to initialize mapshot", ie); } } else if (iCurrentCursor == ImageManager.CURSOR_ZOOM) { if (!zoomed) { Rectangle mapDim = ServerSettings.getSingleton().getMapDimension(); double widthFactor = ((double) mapDim.width) / getWidth(); double heightFactor = ((double) mapDim.height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX() + mapDim.getMinX()); int y = (int) Math.rint(heightFactor * rDrag.getY() + mapDim.getMinY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); if (w >= 10) { rVisiblePart = new Rectangle(x, y, w, w); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = true; } } else { rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = false; } MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } @Override public void mouseEntered(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { MinimapZoomFrame.getSingleton().setVisible(true); } } } @Override public void mouseExited(MouseEvent e) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } }); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_MOVE: { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.x, p.y); rDrag = null; break; } case ImageManager.CURSOR_SHOT: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } case ImageManager.CURSOR_ZOOM: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } } } @Override public void mouseMoved(MouseEvent e) { if (iCurrentView == ID_MINIMAP) { switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { if (!MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(true); } int mapWidth = (int) ServerSettings.getSingleton().getMapDimension().getWidth(); int mapHeight = (int) ServerSettings.getSingleton().getMapDimension().getHeight(); int x = (int) Math.rint((double) mapWidth / (double) getWidth() * (double) e.getX()); int y = (int) Math.rint((double) mapHeight / (double) getHeight() * (double) e.getY()); MinimapZoomFrame.getSingleton().updatePosition(x, y); break; } default: { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } } } Point location = minimapButtons.get(ID_MINIMAP).getLocation(); location.translate(-2, -2); if (!new Rectangle(location.x, location.y, 88, 30).contains(e.getPoint())) { //hide controls showControls = false; repaint(); } } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (iCurrentView != ID_MINIMAP) { return; } iCurrentCursor += e.getWheelRotation(); if (iCurrentCursor == ImageManager.CURSOR_DEFAULT + e.getWheelRotation()) { if (e.getWheelRotation() < 0) { iCurrentCursor = ImageManager.CURSOR_SHOT; } else { iCurrentCursor = ImageManager.CURSOR_MOVE; } } else if (iCurrentCursor < ImageManager.CURSOR_MOVE) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } else if (iCurrentCursor > ImageManager.CURSOR_SHOT) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } if (iCurrentCursor != ImageManager.CURSOR_ZOOM) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } else { MinimapZoomFrame.getSingleton().setVisible(true); } setCurrentCursor(iCurrentCursor); } }); }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
/** * adds the listener that showes the popup *///from w w w . j av a 2 s. c o m private void addPopupShower() { //show popup thumbnailList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } private void showMenu(MouseEvent e) { int[] selection = thumbnailList.getSelectedIndices(); if (!(selection != null && selection.length > 1)) { thumbnailList.setSelectedIndex(thumbnailList.locationToIndex(e.getPoint())); selection = thumbnailList.getSelectedIndices(); } menuItemPreview.setEnabled(selection != null && selection.length == 1); popupMenu.show(thumbnailList, e.getX(), e.getY()); } }); }
From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java
@Override public void mouseDragged(MouseEvent e) { int button = 0; if (e.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) { button = 1;/* ww w. j av a2 s. c om*/ } else if (e.getModifiersEx() == InputEvent.BUTTON2_DOWN_MASK) { button = 2; } else if (e.getModifiersEx() == InputEvent.BUTTON3_DOWN_MASK) { button = 3; } processMouse(e.getPoint(), button); }
From source file:net.sf.jabref.groups.GroupSelector.java
private void showPopup(MouseEvent e) { final TreePath path = groupsTree.getPathForLocation(e.getPoint().x, e.getPoint().y); addGroupPopupAction.setEnabled(true); addSubgroupPopupAction.setEnabled(path != null); editGroupPopupAction.setEnabled(path != null); removeGroupAndSubgroupsPopupAction.setEnabled(path != null); removeGroupKeepSubgroupsPopupAction.setEnabled(path != null); moveSubmenu.setEnabled(path != null); expandSubtreePopupAction.setEnabled(path != null); collapseSubtreePopupAction.setEnabled(path != null); removeSubgroupsPopupAction.setEnabled(path != null); sortSubmenu.setEnabled(path != null); addToGroup.setEnabled(false);// w w w . ja v a 2 s . co m moveToGroup.setEnabled(false); removeFromGroup.setEnabled(false); if (path != null) { // some path dependent enabling/disabling GroupTreeNode node = (GroupTreeNode) path.getLastPathComponent(); editGroupPopupAction.setNode(node); addSubgroupPopupAction.setNode(node); removeGroupAndSubgroupsPopupAction.setNode(node); removeSubgroupsPopupAction.setNode(node); removeGroupKeepSubgroupsPopupAction.setNode(node); expandSubtreePopupAction.setNode(node); collapseSubtreePopupAction.setNode(node); sortDirectSubgroupsPopupAction.setNode(node); sortAllSubgroupsPopupAction.setNode(node); groupsTree.setHighlightBorderCell(node); AbstractGroup group = node.getGroup(); if (group instanceof AllEntriesGroup) { editGroupPopupAction.setEnabled(false); addGroupPopupAction.setEnabled(false); removeGroupAndSubgroupsPopupAction.setEnabled(false); removeGroupKeepSubgroupsPopupAction.setEnabled(false); } else { editGroupPopupAction.setEnabled(true); addGroupPopupAction.setEnabled(true); addGroupPopupAction.setNode(node); removeGroupAndSubgroupsPopupAction.setEnabled(true); removeGroupKeepSubgroupsPopupAction.setEnabled(true); } expandSubtreePopupAction .setEnabled(groupsTree.isCollapsed(path) || groupsTree.hasCollapsedDescendant(path)); collapseSubtreePopupAction .setEnabled(groupsTree.isExpanded(path) || groupsTree.hasExpandedDescendant(path)); sortSubmenu.setEnabled(!node.isLeaf()); removeSubgroupsPopupAction.setEnabled(!node.isLeaf()); moveNodeUpPopupAction.setEnabled(node.canMoveUp()); moveNodeDownPopupAction.setEnabled(node.canMoveDown()); moveNodeLeftPopupAction.setEnabled(node.canMoveLeft()); moveNodeRightPopupAction.setEnabled(node.canMoveRight()); moveSubmenu.setEnabled(moveNodeUpPopupAction.isEnabled() || moveNodeDownPopupAction.isEnabled() || moveNodeLeftPopupAction.isEnabled() || moveNodeRightPopupAction.isEnabled()); moveNodeUpPopupAction.setNode(node); moveNodeDownPopupAction.setNode(node); moveNodeLeftPopupAction.setNode(node); moveNodeRightPopupAction.setNode(node); // add/remove entries to/from group List<BibEntry> selection = frame.getCurrentBasePanel().getSelectedEntries(); if (selection.size() > 0) { if (node.getGroup().supportsAdd() && !node.getGroup().containsAll(selection)) { addToGroup.setNode(node); addToGroup.setBasePanel(panel); addToGroup.setEnabled(true); moveToGroup.setNode(node); moveToGroup.setBasePanel(panel); moveToGroup.setEnabled(true); } if (node.getGroup().supportsRemove() && node.getGroup().containsAny(selection)) { removeFromGroup.setNode(node); removeFromGroup.setBasePanel(panel); removeFromGroup.setEnabled(true); } } } else { editGroupPopupAction.setNode(null); addGroupPopupAction.setNode(null); addSubgroupPopupAction.setNode(null); removeGroupAndSubgroupsPopupAction.setNode(null); removeSubgroupsPopupAction.setNode(null); removeGroupKeepSubgroupsPopupAction.setNode(null); moveNodeUpPopupAction.setNode(null); moveNodeDownPopupAction.setNode(null); moveNodeLeftPopupAction.setNode(null); moveNodeRightPopupAction.setNode(null); expandSubtreePopupAction.setNode(null); collapseSubtreePopupAction.setNode(null); sortDirectSubgroupsPopupAction.setNode(null); sortAllSubgroupsPopupAction.setNode(null); } groupsContextMenu.show(groupsTree, e.getPoint().x, e.getPoint().y); }
From source file:ca.phon.app.project.ProjectWindow.java
private void init() { /* Layout *//*from w ww. j ava 2 s. c o m*/ setLayout(new BorderLayout()); final ProjectDataTransferHandler transferHandler = new ProjectDataTransferHandler(this); /* Create components */ newCorpusButton = createNewCorpusButton(); createCorpusButton = createCorpusButton(); corpusList = new JList<String>(); corpusModel = new CorpusListModel(getProject()); corpusList.setModel(corpusModel); corpusList.setCellRenderer(new CorpusListCellRenderer()); corpusList.setVisibleRowCount(20); corpusList.addListSelectionListener(e -> { if (getSelectedCorpus() != null) { String corpus = getSelectedCorpus(); sessionModel.setCorpus(corpus); sessionList.clearSelection(); corpusDetails.setCorpus(corpus); if (getProject().getCorpusSessions(corpus).size() == 0) { onSwapNewAndCreateSession(newSessionButton); } else { onSwapNewAndCreateSession(createSessionButton); } } }); corpusList.addMouseListener(new MouseInputAdapter() { @Override public void mousePressed(MouseEvent e) { doPopup(e); } @Override public void mouseReleased(MouseEvent e) { doPopup(e); } public void doPopup(MouseEvent e) { if (e.isPopupTrigger()) { int clickedIdx = corpusList.locationToIndex(e.getPoint()); if (clickedIdx >= 0 && Arrays.binarySearch(corpusList.getSelectedIndices(), clickedIdx) < 0) { corpusList.setSelectedIndex(clickedIdx); } showCorpusListContextMenu(e.getPoint()); } } }); final DragSource corpusDragSource = new DragSource(); corpusDragSource.createDefaultDragGestureRecognizer(corpusList, DnDConstants.ACTION_COPY, (event) -> { final List<ProjectPath> paths = new ArrayList<>(); for (String corpus : getSelectedCorpora()) { final ProjectPath corpusPath = new ProjectPath(getProject(), corpus, null); paths.add(corpusPath); } final ProjectPathTransferable transferable = new ProjectPathTransferable(paths); event.startDrag(DragSource.DefaultCopyDrop, transferable); }); corpusList.setDragEnabled(true); corpusList.setTransferHandler(transferHandler); corpusDetails = new CorpusDetailsPane(getProject()); corpusDetails.setWrapStyleWord(true); corpusDetails.setRows(6); corpusDetails.setLineWrap(true); corpusDetails.setBackground(Color.white); corpusDetails.setOpaque(true); JScrollPane corpusDetailsScroller = new JScrollPane(corpusDetails); sessionList = new JList<String>(); newSessionButton = createNewSessionButton(); createSessionButton = createSessionButton(); sessionModel = new SessionListModel(getProject()); sessionList.setModel(sessionModel); sessionList.setCellRenderer(new SessionListCellRenderer()); sessionList.setVisibleRowCount(20); sessionList.addListSelectionListener(e -> { if (sessionList.getSelectedValue() != null && !e.getValueIsAdjusting()) { String corpus = getSelectedCorpus(); String session = getSelectedSessionName(); sessionDetails.setSession(corpus, session); } }); sessionList.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == 1) { // get the clicked item int clickedItem = sessionList.locationToIndex(e.getPoint()); if (sessionList.getModel().getElementAt(clickedItem) == null) return; final String session = sessionList.getModel().getElementAt(clickedItem).toString(); final String corpus = ((SessionListModel) sessionList.getModel()).getCorpus(); msgPanel.reset(); msgPanel.setMessageLabel("Opening '" + corpus + "." + session + "'"); msgPanel.setIndeterminate(true); msgPanel.repaint(); SwingUtilities.invokeLater(() -> { final ActionEvent ae = new ActionEvent(sessionList, -1, "openSession"); (new OpenSessionAction(ProjectWindow.this, corpus, session)).actionPerformed(ae); msgPanel.setIndeterminate(false); }); } } @Override public void mousePressed(MouseEvent e) { doPopup(e); } @Override public void mouseReleased(MouseEvent e) { doPopup(e); } public void doPopup(MouseEvent e) { if (e.isPopupTrigger()) { int clickedIdx = sessionList.locationToIndex(e.getPoint()); if (clickedIdx >= 0 && Arrays.binarySearch(sessionList.getSelectedIndices(), clickedIdx) < 0) { sessionList.setSelectedIndex(clickedIdx); } showSessionListContextMenu(e.getPoint()); } } }); sessionList.setDragEnabled(true); sessionList.setTransferHandler(transferHandler); final DragSource sessionDragSource = new DragSource(); sessionDragSource.createDefaultDragGestureRecognizer(sessionList, DnDConstants.ACTION_COPY, (event) -> { final List<ProjectPath> paths = new ArrayList<>(); final String corpus = getSelectedCorpus(); if (corpus == null) return; for (String session : getSelectedSessionNames()) { final ProjectPath sessionPath = new ProjectPath(getProject(), corpus, session); paths.add(sessionPath); } final ProjectPathTransferable transferable = new ProjectPathTransferable(paths); event.startDrag(DragSource.DefaultCopyDrop, transferable); }); sessionDetails = new SessionDetailsPane(getProject()); sessionDetails.setLineWrap(true); sessionDetails.setRows(6); sessionDetails.setWrapStyleWord(true); sessionDetails.setBackground(Color.white); sessionDetails.setOpaque(true); JScrollPane sessionDetailsScroller = new JScrollPane(sessionDetails); JScrollPane corpusScroller = new JScrollPane(corpusList); JScrollPane sessionScroller = new JScrollPane(sessionList); blindModeBox = new JCheckBox("Blind transcription"); blindModeBox.setSelected(false); msgPanel = new StatusPanel(); corpusPanel = new JPanel(new BorderLayout()); corpusPanel.add(newCorpusButton, BorderLayout.NORTH); corpusPanel.add(corpusScroller, BorderLayout.CENTER); corpusPanel.add(corpusDetailsScroller, BorderLayout.SOUTH); sessionPanel = new JPanel(new BorderLayout()); sessionPanel.add(newSessionButton, BorderLayout.NORTH); sessionPanel.add(sessionScroller, BorderLayout.CENTER); sessionPanel.add(sessionDetailsScroller, BorderLayout.SOUTH); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(corpusPanel); splitPane.setRightComponent(sessionPanel); splitPane.setResizeWeight(0.5); // invoke later SwingUtilities.invokeLater(() -> { splitPane.setDividerLocation(0.5); }); // the frame layout String projectName = null; projectName = getProject().getName(); DialogHeader header = new DialogHeader(projectName, StringUtils.abbreviate(projectLoadPath, 80)); add(header, BorderLayout.NORTH); CellConstraints cc = new CellConstraints(); final JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref")); topPanel.add(msgPanel, cc.xy(1, 1)); topPanel.add(blindModeBox, cc.xy(3, 1)); add(splitPane, BorderLayout.CENTER); add(topPanel, BorderLayout.SOUTH); // if no corpora are currently available, 'prompt' the user to create a new one if (getProject().getCorpora().size() == 0) { SwingUtilities.invokeLater(() -> { onSwapNewAndCreateCorpus(newCorpusButton); }); } else { SwingUtilities.invokeLater(() -> { corpusList.setSelectedIndex(0); }); } }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * Opens the <tt>WritePanelRightButtonMenu</tt> when user clicks with the * right mouse button on the editor area. * * @param e the <tt>MouseEvent</tt> that notified us *///from w w w.j a va 2s . c om public void mouseClicked(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { Point p = e.getPoint(); SwingUtilities.convertPointToScreen(p, e.getComponent()); //SPELLCHECK ArrayList<JMenuItem> contributedMenuEntries = new ArrayList<JMenuItem>(); for (ChatMenuListener listener : this.menuListeners) { contributedMenuEntries.addAll(listener.getMenuElements(this.chatPanel, e)); } for (JMenuItem item : contributedMenuEntries) { rightButtonMenu.add(item); } JPopupMenu rightMenu = rightButtonMenu.makeMenu(contributedMenuEntries); rightMenu.setInvoker(editorPane); rightMenu.setLocation(p.x, p.y); rightMenu.setVisible(true); } }
From source file:org.kalypso.ogc.gml.map.widgets.GetFeatureInfoWidget.java
/** * @see org.kalypso.ogc.gml.widgets.AbstractWidget#mouseClicked(java.awt.event.MouseEvent) *///from ww w. j av a 2 s .co m @Override public void mouseClicked(final MouseEvent event) { try { /* We need a wms theme. */ if (m_wmsTheme == null) { /* Initialize from configuration or user selection. */ initialize(getMapPanel()); /* HINT 1: If the theme property is not set, the dialog was open. */ /* HINT 1: So do not proceed, regardless if there is a theme. */ /* HINT 1: This prevents from opening the feature info right after the dialog was open. */ final String themeProperty = getParameter("getFeatureInfoProperty"); //$NON-NLS-1$ if (StringUtils.isEmpty(themeProperty)) return; /* HINT 2: If the theme property is set, the widget should configure itself without a dialog. */ /* HINT 2: So the user was not interupted, so only leave, if there is no theme. */ /* HINT 2: If there is a theme, show the feature info. */ if (m_wmsTheme == null) return; } /* Create the dialog. */ final GetFeatureInfoDialog dialog = new GetFeatureInfoDialog(SWT_AWT_Utilities.findActiveShell(), m_wmsTheme, event.getPoint().getX(), event.getPoint().getY()); /* Open the dialog. */ SWT_AWT_Utilities.openSwtWindow(dialog); /* Adjust the position of the dialog. */ final Shell shell = dialog.getShell(); shell.getDisplay().syncExec(new Runnable() { @Override public void run() { if (shell.isDisposed()) return; final org.eclipse.swt.graphics.Point shellSize = shell.getSize(); final org.eclipse.swt.graphics.Point mousePos = shell.getDisplay().getCursorLocation(); shell.setBounds(new Rectangle(mousePos.x, mousePos.y, shellSize.x, shellSize.y)); } }); } catch (final Exception ex) { ex.printStackTrace(); } }