@Override public final void mousePressed(final MouseEvent e) { if (!isEnabled() || !isFocusable()) return; requestFocusInWindow(); caret(true); if (SwingUtilities.isMiddleMouseButton(e)) copy(); final boolean shift = e.isShiftDown(); final boolean selected = editor.selected(); if (SwingUtilities.isLeftMouseButton(e)) { final int c = e.getClickCount(); if (c == 1) { // selection mode if (shift) editor.startSelection(true); select(e.getPoint(), !shift); } else if (c == 2) { editor.selectWord(); } else { editor.selectLine(); } } else if (!selected) { select(e.getPoint(), true); } }
@Override public final void mousePressed(final MouseEvent e) { if (!isEnabled() || !isFocusable()) return; requestFocusInWindow(); cursor(true); if (SwingUtilities.isMiddleMouseButton(e)) copy(); final boolean marking = e.isShiftDown(); final boolean nomark = !text.marked(); if (SwingUtilities.isLeftMouseButton(e)) { final int c = e.getClickCount(); if (c == 1) { // selection mode if (marking && nomark) text.startMark(); rend.select(scroll.pos(), e.getPoint(), marking); } else if (c == 2) { text.selectWord(); } else { text.selectLine(); } } else if (nomark) { rend.select(scroll.pos(), e.getPoint(), false); } }
/** * A chat room was selected. Opens the chat room in the chat window. * * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just * occurred. */ public void mousePressed(MouseEvent e) { // Select the object under the right button click. if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0 || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { int ix = this.chatRoomList.rowAtPoint(e.getPoint()); if (ix != -1) { this.chatRoomList.setRowSelectionInterval(ix, ix); } } Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow()); Point selectedCellPoint = e.getPoint(); SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList); if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { JPopupMenu rightButtonMenu; if (o instanceof ChatRoomWrapper) rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o); else return; rightButtonMenu.setInvoker(this); rightButtonMenu.setLocation(selectedCellPoint); rightButtonMenu.setVisible(true); } }
public void mouseReleased(MouseEvent e) { lastInteractionTime = System.currentTimeMillis(); if (enabled && !readOnly && lastPressEvent != null && dragInProgress) { if (enableMouseDrags && !e.getPoint().equals(lastPressEvent.getPoint())) { dragInProgress = false; // Generate the command string String s = "Mouse " + MouseCommand.MOUSE_DRAG; // Insert the button identifier if other than left button was pressed if (e.getButton() != MouseEvent.BUTTON1) { s += " " + MouseCommand.PARAM_BUTTON_SHORT + "=" + parser.buttonToString(e.getButton()); } // Insert modifiers if there are any String modifiers = parser.modifiersToString(e.getModifiers()); if (modifiers.length() > 0) { s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers; } // Generate coordinates s += " " + MouseCommand.PARAM_FROM + "=" + parser.pointToString(lastPressEvent.getPoint()); s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint()); // Insert the command to the current editor insertLine(s, false, true, false); insertEvent(e); } } }
public void mouseDragged(MouseEvent evt) { Graphics g = canvas.getGraphics(); g.setColor(color); if (type == 0) { g.setXORMode(canvas.getBackground()); g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y); end = evt.getPoint(); g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y); } else if (type == 1) { int radius; g.setXORMode(canvas.getBackground()); radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)); g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius); end = evt.getPoint(); radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)); g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius); } else if (type == 2) { g.setXORMode(canvas.getBackground()); g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y); end = evt.getPoint(); g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y); } }
public void mouseReleased(MouseEvent e) { int mods = e.getModifiersEx(); if (nodrag && e.getButton() == MouseEvent.BUTTON3) { popupMenu.show(JImage.this, (int) e.getPoint().getX(), (int) e.getPoint().getY()); } nodrag = true; dragBegin = null; }
private void updateRolloverColumn(MouseEvent e) { if (header.getDraggedColumn() == null && header.contains(e.getPoint())) { int col = header.columnAtPoint(e.getPoint()); if (col != rolloverColumn) { rolloverColumn = col; header.repaint(); } } }
private void hovered(final MouseEvent e, final boolean entered) { hoveredIndex = myList.locationToIndex(e.getPoint()); if (!entered || hoveredIndex != -1 && !myList.getCellBounds(hoveredIndex, hoveredIndex).contains(e.getPoint())) hoveredIndex = -1; myList.repaint(); }
public void mousePressed(MouseEvent e) { if (ctx != null) { // save the current selection set operator prevSetOp = ctx.getSetOperator(tm).getSetOperator(); // set the selection set operator ctx.getSetOperator(tm).setFromInputEventMask(e.getModifiers()); } start = e.getPoint(); current = e.getPoint(); selecting = true; repaint(); }
protected void processMouseEvent(final MouseEvent e) { if (e.isPopupTrigger() && e.getComponent().isShowing()) { super.processMouseEvent(e); return; } if (UIUtil.isCloseClick(e)) { myDecorator.fireHiddenSide(); return; } if (e.getButton() == MouseEvent.BUTTON1) { if (MouseEvent.MOUSE_PRESSED == e.getID()) { myPressedPoint = e.getPoint(); myPressedWhenSelected = isSelected(); myDragCancelled = false; } else if (MouseEvent.MOUSE_RELEASED == e.getID()) { finishDragging(); myPressedPoint = null; myDragButtonImage = null; } } super.processMouseEvent(e); }
@Override public void mouseMoved(MouseEvent evt) { Point point = evt.getPoint(); updateCursor(editor.findView((Container) evt.getSource()), point); DrawingView view = editor.findView((Container) evt.getSource()); updateCursor(view, point); if (view == null || editor.getActiveView() != view) { clearHoverHandles(); } else { // Search first, if one of the selected figures contains // the current mouse location. Only then search for other // figures. This search sequence is consistent with the // search sequence of the SelectionTool. Figure figure = null; Point2D.Double p = view.viewToDrawing(point); for (Figure f : view.getSelectedFigures()) { if (f.contains(p)) { figure = f; } } if (figure == null) { figure = view.findFigure(point); Drawing drawing = view.getDrawing(); while (figure != null && !figure.isSelectable()) { figure = drawing.findFigureBehind(p, figure); } } updateHoverHandles(view, figure); } }
@Override public void mouseMoved(MouseEvent e) { Point pt = e.getPoint(); int prevRow = row; int prevCol = col; row = table.rowAtPoint(pt); col = table.columnAtPoint(pt); if (row < 0 || col < 0) { row = -1; col = -1; } // >>>> HyperlinkCellRenderer.java // @see // http://java.net/projects/swingset3/sources/svn/content/trunk/SwingSet3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java if (row == prevRow && col == prevCol) { return; } Rectangle repaintRect; if (row >= 0 && col >= 0) { Rectangle r = table.getCellRect(row, col, false); if (prevRow >= 0 && prevCol >= 0) { repaintRect = r.union(table.getCellRect(prevRow, prevCol, false)); } else { repaintRect = r; } } else { repaintRect = table.getCellRect(prevRow, prevCol, false); } table.repaint(repaintRect); // <<<< // table.repaint(); }
@Override public void mouseClicked(MouseEvent me) { Element el = doc.getCharacterElement(viewToModel(me.getPoint())); if (el == null) return; AttributeSet as = el.getAttributes(); if (as.isDefined("ip")) { String ip = (String) as.getAttribute("ip"); ScriptException se = (ScriptException) as.getAttribute("exception"); Node node = net.getAtIP(ip); if (node == null) { Utility.displayError("Error", "Computer does not exist"); return; } String errorString = "--ERROR--\n" + "Error at line number " + se.getLineNumber() + " and column number " + se.getColumnNumber() + "\n" + se.getMessage(); new ScriptDialog( parentFrame, str -> { if (str != null) { node.setScript(str); } }, node.getScript(), errorString) .setVisible(true); } }
@Override public void mouseMoved(MouseEvent e) { try { affineTransform.inverseTransform(e.getPoint(), currentMousePointLogic); } catch (Exception ex) { } }
public void mousePressed(MouseEvent e) { if (e.getButton() == e.BUTTON3) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); int index = list.locationToIndex(e.getPoint()); GetImageFile gif = new GetImageFile(files[index]); JTextArea area = new JTextArea( "File: " + gif.getImageString() + "\n" + "Score: " + nf.format(scores[index]) + "\n" + "Pairs: " + nrpairs[index]); area.setEditable(false); area.setBorder(BorderFactory.createLineBorder(Color.black)); area.setFont(new Font("times", Font.PLAIN, 12)); PopupFactory factory = PopupFactory.getSharedInstance(); popup = factory.getPopup( null, area, (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25, (int) e.getComponent().getLocationOnScreen().getY() + e.getY()); popup.show(); } }
public void mouseClicked(MouseEvent e) { Point p = e.getPoint(); MainLoop loop = planner.getMapPanel().getLoop(); final RoadDirection dir; if (fullRect.contains(p)) { dir = RoadDirection.CENTER; } else if (nw.contains(p)) { dir = RoadDirection.NW; } else if (ne.contains(p)) { dir = RoadDirection.NE; } else if (sw.contains(p)) { dir = RoadDirection.SW; } else if (se.contains(p)) { dir = RoadDirection.SE; } else { dir = null; } if (dir != null) { loop.syncAndExecute( () -> { Globals.roadDirection = dir; repaint(); }); } }
// reset shortest path algorithm when the cursor moves @Override public void mouseMoved(MouseEvent e) { // set relative position of the cell that cursor points to base on actual map GameMap temp = (GameMap) panel; mainHero = panel.getFacade().getMainHero(); Cell rangeCell = new Cell(); Point curPos = e.getPoint(); int x = (curPos.x + panel.getScrollX()) / Utilizer.TILE_SIZE; rangeCell.setColPos(x); x = x * Utilizer.TILE_SIZE; rangeCell.setX(x); int y = (curPos.y + panel.getScrollY()) / Utilizer.TILE_SIZE; rangeCell.setRowPos(y); y = y * Utilizer.TILE_SIZE; rangeCell.setY(y); if (rangeCell.getRowPos() >= 0 && rangeCell.getRowPos() <= 39 && rangeCell.getColPos() >= 0 && rangeCell.getColPos() <= 39) temp.setRangedCell(rangeCell); else return; // set hero movement if (panel.getFacade().getMainHero().getIsChosen() // && // inRange(selectCell,panel.getHero().calculateRange(panel.getHero().getRow(),panel.getHero().getCol(),(panel.getHero().getAP()/2) +1 )) ) { mainHero.calculateShortestPath(rangeCell); } panel.repaint(); }
public void mouseClicked(MouseEvent ev) { Window w = (Window) ev.getSource(); Frame f = null; if (w instanceof Frame) { f = (Frame) w; } else { return; } Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane()); int state = f.getExtendedState(); if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) { if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) { if (f.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH); } else { f.setExtendedState(state | Frame.MAXIMIZED_BOTH); } return; } } } }
@Override public void mouseDragged(MouseEvent e) { if (!myDragging) return; MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this); final ToolWindowAnchor anchor = myInfo.getAnchor(); final Point point = event.getPoint(); final Container windowPane = InternalDecorator.this.getParent(); myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane); myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth()); myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight()); final Rectangle bounds = InternalDecorator.this.getBounds(); if (anchor == ToolWindowAnchor.TOP) { InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y); } else if (anchor == ToolWindowAnchor.LEFT) { InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height); } else if (anchor == ToolWindowAnchor.BOTTOM) { InternalDecorator.this.setBounds( 0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y); } else if (anchor == ToolWindowAnchor.RIGHT) { InternalDecorator.this.setBounds( myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height); } InternalDecorator.this.validate(); e.consume(); }
@Override public void mousePressed(MouseEvent e) { // The mouseMoved event continually updates this variable if (direction == 0) return; // Setup for resizing. All future dragging calculations are done based // on the original bounds of the component and mouse pressed location. resizing = true; Component source = e.getComponent(); pressed = e.getPoint(); SwingUtilities.convertPointToScreen(pressed, source); bounds = source.getBounds(); // Making sure autoscrolls is false will allow for smoother resizing // of components if (source instanceof JComponent) { JComponent jc = (JComponent) source; autoscrolls = jc.getAutoscrolls(); jc.setAutoscrolls(false); } }
public void mousePressed(MouseEvent e) { this.mousePoint = e.getPoint(); Object topObject = null; PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition(); if (pickedObjects != null) topObject = pickedObjects.getTopObject(); if (topObject instanceof ControlPointMarker) { this.activeControlPoint = (ControlPointMarker) topObject; this.activeAction = this.activeControlPoint.getType(); setShowAnnotation(true); updateAnnotation(this.activeControlPoint.getPosition()); // update controlPointIndex; int i = 0; for (Marker controlPoint : this.controlPoints) { if (controlPoint.equals(topObject)) break; i++; } this.activeControlPointIndex = i; e.consume(); } else if (topObject == this.getPolygon()) { this.activeAction = MOVE_POLYGON_ACTION; // set the shape to be the "active control point" this.activeControlPointIndex = -1; setShowAnnotation(true); updateAnnotation(this.polygon.getReferencePosition()); e.consume(); } }
public void mouseDragged(MouseEvent e) { int mods = e.getModifiersEx(); Point dragEnd = e.getPoint(); boolean shift = (mods & MouseEvent.SHIFT_DOWN_MASK) > 0; boolean ctrl = (mods & MouseEvent.CTRL_DOWN_MASK) > 0; boolean alt = shift & ctrl; ctrl = ctrl & (!alt); shift = shift & (!alt); boolean nomods = !(shift | ctrl | alt); if (dragBegin == null) dragBegin = dragEnd; nodrag = false; if ((mods & InputEvent.BUTTON3_DOWN_MASK) > 0 || true) { double dx = dragEnd.getX() - dragBegin.getX(); double dy = dragEnd.getY() - dragBegin.getY(); synchronized (JImage.this) { t.preConcatenate(AffineTransform.getTranslateInstance(dx, dy)); } dragBegin = dragEnd; repaint(); } }
private void adjustFocusAndSelection(MouseEvent e) { if (shouldIgnore(e)) { return; } Point p = e.getPoint(); int row = grid.rowAtPoint(p); int column = grid.columnAtPoint(p); // The autoscroller can generate drag events outside range. if ((column == -1) || (row == -1)) { System.err.println("Out of bounds"); return; } if (grid.editCellAt(row, column, e)) { setDispatchComponent(e); repostEvent(e); } else { grid.requestFocus(); } GridCellEditor editor = grid.getCurrentCellEditor(); if (editor == null || editor.shouldSelectCell(e)) { // Update selection model setValueIsAdjusting(true); grid.changeSelection(row, column, e.isControlDown(), e.isShiftDown()); } }
public void mouseDragged(MouseEvent e) { if (isEnabled()) { // System.out.println("LinkTool::mouseDragged"); if (e.getSource() instanceof ONLGraphic) buttonAction.setIntermediate(e.getPoint(), (ONLGraphic) e.getSource()); } }
@Override public void mouseMoved(MouseEvent e) { Component source = e.getComponent(); Point location = e.getPoint(); direction = 0; if (location.x < dragInsets.left) direction += WEST; if (location.x > source.getWidth() - dragInsets.right - 1) direction += EAST; if (location.y < dragInsets.top) direction += NORTH; if (location.y > source.getHeight() - dragInsets.bottom - 1) direction += SOUTH; // Mouse is no longer over a resizable border if (direction == 0) { source.setCursor(sourceCursor); } else // use the appropriate resizable cursor { int cursorType = cursors.get(direction); Cursor cursor = Cursor.getPredefinedCursor(cursorType); source.setCursor(cursor); } }
private boolean isOnNextStepButton(MouseEvent e) { final int index = myList.getSelectedIndex(); final Rectangle bounds = myList.getCellBounds(index, index); final Point point = e.getPoint(); return bounds != null && point.getX() > bounds.width + bounds.getX() - AllIcons.Icons.Ide.NextStep.getIconWidth(); }
public void mousePressed(MouseEvent e) { if (e.getButton() != MouseEvent.BUTTON1) { return; } if (e.getClickCount() != 2) { return; } JTable table = (JTable) e.getSource(); Point p = e.getPoint(); int row = table.rowAtPoint(p); if (row < 0) { return; } FinderTableModel model = getDataModel(); ICFSecurityISOTimezoneObj o = (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER); if (o == null) { return; } JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o); ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View); if (frame == null) { return; } Container cont = getParent(); while ((cont != null) && (!(cont instanceof JInternalFrame))) { cont = cont.getParent(); } if (cont != null) { JInternalFrame myInternalFrame = (JInternalFrame) cont; myInternalFrame.getDesktopPane().add(frame); frame.setVisible(true); frame.show(); } }
public void mouseReleased(MouseEvent evt) { Graphics g = canvas.getGraphics(); g.setColor(color); g.setPaintMode(); end = evt.getPoint(); if (type == 0) { g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y); if (filled.getState() == true) g.fillRect(start.x, start.y, end.x - start.x, end.y - start.y); status.setText("2. Ecke des Rechtecks festgelegt"); } else if (type == 1) { int radius; radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)); g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius); if (filled.getState() == true) g.fillOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius); status.setText("Radius des Kreises festgelegt"); } else if (type == 2) { g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y); if (filled.getState() == true) g.fillOval(start.x, start.y, end.x - start.x, end.y - start.y); status.setText("Radius der Ellipse festgelegt"); } }
public void mousePressed(MouseEvent e) { if (e.getButton() != MouseEvent.BUTTON1) { return; } if (e.getClickCount() != 2) { return; } JTable table = (JTable) e.getSource(); Point p = e.getPoint(); int row = table.rowAtPoint(p); if (row < 0) { return; } PickerTableModel model = getDataModel(); ICFInternetISOCountryObj o = (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER); invokeWhenChosen.choseISOCountry(o); try { Container cont = getParent(); while ((cont != null) && (!(cont instanceof JInternalFrame))) { cont = cont.getParent(); } if (cont != null) { ((JInternalFrame) cont).setClosed(true); } } catch (Exception x) { } }
public void mouseDragged(MouseEvent me) { double[] P = toCartesianPoint(me.getPoint().x, me.getPoint().y); if (newA) { a = P[0]; applet.a.setValue(a); applet.updateGraphs(this); if (a > c) c = a; if (b > a) b = a; } else { originX -= (me.getPoint().x - POINT.x) / scale; originY += (me.getPoint().y - POINT.y) / scale; POINT = me.getPoint(); newBackground = true; repaint(); } }