List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseClicked(final MouseEvent e) { if (this.application != null) { if (e.getButton() == MouseEvent.BUTTON1) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); this.hexMapPanel.setToolTipText( this.application.processHexAction(this.hexMapPanel, e, HexAction.CLICK, hexNumber)); }// w w w. j a v a 2s. com } else { switch (e.getButton()) { case MouseEvent.BUTTON1: { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); useCurrentToolAtPosition(hexNumber); } break; } } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
void handleRightMouseClick(final MouseEvent e) { Point p = e.getPoint(); // save a keep of click position // so some menu actions can make use of it this.rightClickPos = p; // float sp[] = {0.0f, 0.0f}; this.convertMousePointToSceneSpace(p, scenePos); // System.out.println("---- Mouse Right Click at " + // p.x + ", " + p.y); // System.out.println("---- Which is Scene Space: " + // scenePos[0] + ", " + scenePos[1]); determineSelectedSceneComponents(scenePos, e); this.scenePopupMenu.show(e.getComponent(), p.x, p.y); selectedMarker = SceneGraph.accessPickedMarker(); // System.out.println("MarkerId: " + selectedMarker + " is selected"); if (selectedMarker < 0) { return;/*from w w w. j a va 2 s . co m*/ } else { // JMenuItem title = // (JMenuItem) this.scenePopupMenu.getComponent(4); // title.setText("Edit Annotation"); // this.annotationEditMenu.setEnabled(true); // this.annotationAddMenu.setEnabled(false); } this.scenePopupMenu.repaint(); }
From source file:edmondskarp.Gui.EdmondsKarpGui.java
private void myPanelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_myPanelMouseDragged if (MODE == DRAG) { if (!isInDragging) { if (shapeTmp != null) { shapeTmp.setSelect(false); isSecond = false;/*w w w.j av a 2s. com*/ } shapeTmp = getSelectedCircle(evt.getPoint()); if (shapeTmp != null) { shapeTmp.setFirstPoint(evt.getPoint()); shapeTmp.needUpdate(); isInDragging = true; } else { // addCircle(evt.getPoint()); isInDragging = false; shapeTmp = null; } } else { shapeTmp.setFirstPoint(evt.getPoint()); shapeTmp.needUpdate(); shapeTmp.updateArrow(); update(); } } }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
public void mousePressed(MouseEvent event) { if (event.getSource() instanceof JLabel) { } else {// w ww.ja va2 s .co m if (SwingUtilities.isRightMouseButton(event)) { String columnName = table.getColumnModel().getColumn(table.columnAtPoint(event.getPoint())) .getHeaderValue().toString(); SwingUtilities.convertPointFromScreen(event.getPoint(), table); spreadsheetPopups.popupMenu(table, event.getX() + 10, event.getY() + 10, columnName); } if (SwingUtilities.isLeftMouseButton(event)) { startRow = table.rowAtPoint(event.getPoint()); startCol = table.columnAtPoint(event.getPoint()); } } }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseReleased(final MouseEvent e) { if (this.application == null) { if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0 && e.isPopupTrigger()) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); onPopup(e.getPoint(), hexNumber); } else {//from w w w. j av a 2 s . c o m switch (e.getButton()) { case MouseEvent.BUTTON3: { this.dragging = false; this.hexMapPanelDesktop.endDrag(); } break; } } } else if (e.getButton() == MouseEvent.BUTTON3) { this.dragging = false; this.hexMapPanelDesktop.endDrag(); } }
From source file:net.sf.jabref.groups.GroupSelector.java
private void definePopup() { // These key bindings are just to have the shortcuts displayed // in the popup menu. The actual keystroke processing is in // BasePanel (entryTable.addKeyListener(...)). groupsContextMenu.add(editGroupPopupAction); groupsContextMenu.add(addGroupPopupAction); groupsContextMenu.add(addSubgroupPopupAction); groupsContextMenu.addSeparator();/*w ww . j ava 2s .c o m*/ groupsContextMenu.add(removeGroupAndSubgroupsPopupAction); groupsContextMenu.add(removeGroupKeepSubgroupsPopupAction); groupsContextMenu.add(removeSubgroupsPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(expandSubtreePopupAction); groupsContextMenu.add(collapseSubtreePopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(moveSubmenu); sortSubmenu.add(sortDirectSubgroupsPopupAction); sortSubmenu.add(sortAllSubgroupsPopupAction); groupsContextMenu.add(sortSubmenu); moveSubmenu.add(moveNodeUpPopupAction); moveSubmenu.add(moveNodeDownPopupAction); moveSubmenu.add(moveNodeLeftPopupAction); moveSubmenu.add(moveNodeRightPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(addToGroup); groupsContextMenu.add(moveToGroup); groupsContextMenu.add(removeFromGroup); groupsTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseClicked(MouseEvent e) { TreePath path = groupsTree.getPathForLocation(e.getPoint().x, e.getPoint().y); if (path == null) { return; } GroupTreeNode node = (GroupTreeNode) path.getLastPathComponent(); // the root node is "AllEntries" and cannot be edited if (node.isRoot()) { return; } if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) { // edit editGroupAction.actionPerformed(null); // dummy event } else if ((e.getClickCount() == 1) && (e.getButton() == MouseEvent.BUTTON1)) { annotationEvent(node); } } }); // be sure to remove a possible border highlight when the popup menu // disappears groupsContextMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // nothing to do } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } @Override public void popupMenuCanceled(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } }); }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
public void mouseMoved(final MouseEvent e) { if (SceneGraph.hasCrossHair()) { this.convertMousePointToSceneSpace(e.getPoint(), scenePos); String msg = ""; msg = msg + scenePos[0] / SceneGraph.getCanvasDPIX(canvasId) + "\t" + scenePos[1] / SceneGraph.getCanvasDPIY(canvasId); CorelyzerApp.getApp().getPluginManager().broadcastEventToPlugins(CorelyzerPluginEvent.MOUSE_MOTION, msg);//from www . j ava 2 s.co m // set mouse position to draw cross hair SceneGraph.positionMouse(scenePos[0], scenePos[1]); CorelyzerApp.getApp().updateGLWindows(); } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
public void mousePressed(final MouseEvent e) { prePos = e.getPoint(); float sp[] = { 0.0f, 0.0f }; this.convertMousePointToSceneSpace(prePos, scenePos); PAN_MODE = 0;// w w w . ja v a 2 s.c om ZOOM_MODE = 0; MANIPULATE_MODE = 0; // For mouse right-click or Ctrl-Left-Click if (e.isPopupTrigger()) { this.handleRightMouseClick(e); return; } switch (e.getButton()) { case MouseEvent.BUTTON1: if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) { return; } else if (canvasMode == CorelyzerApp.APP_MARKER_MODE) { // the first check up: focused marker manipulation if (SceneGraph.focusedMarker > -1) { if (SceneGraph.hitMarker(canvasId, scenePos[0], scenePos[1])) { MANIPULATE_MODE = 1; /* * System.out.println( * "---- Left button pressed down at: " + prePos.x + * ", " + prePos.y); System.out.println( * "Converted to Scene Space: " + scenePos[0] + ", " * + sp[1]); * System.out.println("Marker manipulator hit!"); */ prescenePos[0] = scenePos[0]; prescenePos[1] = scenePos[1]; return; } } } else if (canvasMode == CorelyzerApp.APP_CLAST_MODE || canvasMode == CorelyzerApp.APP_CUT_MODE) { determineSelectedSceneComponents(scenePos, e); if (selectedTrackSection != -1) { if (!SceneGraph.getDepthOrientation()) { float t = scenePos[0]; scenePos[0] = scenePos[1]; scenePos[1] = -t; } SceneGraph.addClastPoint1(scenePos[0], scenePos[1]); this.convertScenePointToAbsolute(scenePos, sp); CorelyzerApp.getApp().getToolFrame().setClastUpperLeft(sp); } PAN_MODE = 0; return; } PAN_MODE = 1; // System.out.println("---- Left button pressed down at: " + // prePos.x + ", " + prePos.y); // System.out.println("Converted to Scene Space: " + // scenePos[0] + ", " + sp[1]); determineSelectedSceneComponents(scenePos, e); break; case MouseEvent.BUTTON2: // System.out.println("MOUSE BUTTON 2!!!???"); break; case MouseEvent.BUTTON3: // System.out.println("---- Right button clicked at: " + // prePos.x + ", " + prePos.y); // System.out.println("Converted to Scene Space: " + // scenePos[0] + ", " + sp[1]); this.handleRightMouseClick(e); break; default: // more reliable than BUTTON3 (ctrl-click) if (e.isPopupTrigger()) { this.handleRightMouseClick(e); } } }
From source file:grupob.TipoProceso.java
private void tblInstitucionalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblInstitucionalMouseClicked // TODO add your handling code here: DefaultTableModel modelo = (DefaultTableModel) tblInstitucional.getModel(); int row = tblInstitucional.rowAtPoint(evt.getPoint()); int col = tblInstitucional.columnAtPoint(evt.getPoint()); if (col == 3) { int dialogButton = JOptionPane.YES_NO_OPTION; int n = JOptionPane.showConfirmDialog(null, "Estas Seguro que deseas eliminar?", "Advertencia", dialogButton);/*from ww w . ja v a 2 s.c o m*/ if (n == JOptionPane.YES_OPTION) { String nombre = tblInstitucional.getValueAt(row, 0).toString(); //Buscar el id en la lista for (int i = 0; i < listaInstituciones.size(); i++) { if (listaInstituciones.get(i).getNombre().equals(nombre)) { Manager.deleteInstitucion(listaInstituciones.get(i).getId()); listaInstituciones.remove(i);//Ver si es correcto esto break; } } modelo.removeRow(tblInstitucional.getSelectedRow()); } } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
private void handleClastMouseReleased(final MouseEvent e) { if (selectedTrackSection != -1) { Point releasePos = e.getPoint(); float[] releaseScenePos = { 0.0f, 0.0f }; float[] releaseAbsPos = { 0.0f, 0.0f }; convertMousePointToSceneSpace(releasePos, releaseScenePos); if (!SceneGraph.getDepthOrientation()) { float t = scenePos[0]; scenePos[0] = scenePos[1];/*from ww w . j a v a 2 s .c om*/ scenePos[1] = -t; } SceneGraph.addClastPoint2(scenePos[0], scenePos[1]); convertScenePointToAbsolute(scenePos, releaseAbsPos); CorelyzerApp.getApp().getToolFrame().setClastLowerRight(releaseAbsPos); float[] clastUpperLeft = CorelyzerApp.getApp().getToolFrame().getClastUpperLeft(); String trackname = CorelyzerApp.getApp().getTrackListModel().getElementAt(selectedTrackIndex) .toString(); String secname = CorelyzerApp.getApp().getSectionListModel().getElementAt(selectedTrackSectionIndex) .toString(); String sessionname = CoreGraph.getInstance().getCurrentSession().getName(); // Different kinds of annotations AnnotationTypeDirectory dir = AnnotationTypeDirectory.getLocalAnnotationTypeDirectory(); if (dir == null) { System.out.println("Null AnnotationTypeDirectory abort."); return; } Enumeration<String> keys = dir.keys(); Vector<String> annotationOptions = new Vector<String>(); annotationOptions.add("Cancel"); while (keys.hasMoreElements()) { annotationOptions.add(keys.nextElement()); } Object[] options = annotationOptions.toArray(); int sel = JOptionPane.showOptionDialog(getPopupParent(), "Which kind of Annotation?", "Annotation Form Selector", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (sel < 0) { return; } try { this.handleAnnotationEvent(options[sel].toString(), sessionname, trackname, secname, clastUpperLeft, releaseAbsPos); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } } }