Java Code Examples for java.awt.event.MouseEvent.isAltDown()

The following are Jave code examples for showing how to use isAltDown() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jtk   File: AxisAlignedQuad.java   Source Code and License Vote up 6 votes
public void dragBegin(DragContext dc) {
  Point3 origin = dc.getPointWorld();
  Vector3 normal = null;
  Axis axis = _frame.getAxis();
  if (axis==Axis.X) {
    normal = new Vector3(1.0,0.0,0.0);
  } else if (axis==Axis.Y) {
    normal = new Vector3(0.0,1.0,0.0);
  } else if (axis==Axis.Z) {
    normal = new Vector3(0.0,0.0,1.0);
  }
  Plane plane = new Plane(origin,normal);
  MouseEvent event = dc.getMouseEvent();
  Matrix44 worldToPixel = dc.getWorldToPixel();
  if (event.isControlDown() || event.isAltDown()) { // Alt/Option for Mac
    _mouseConstrained = new MouseOnPlane(event,origin,plane,worldToPixel);
  } else {
    _mouseConstrained = new MouseOnLine(event,origin,normal,worldToPixel);
  }
  _origin = origin;
  _qa = _frame.getCornerMin();
  _qb = _frame.getCornerMax();
}
 
Example 2
Project: LivroJavaComoProgramar10Edicao   File: MouseDetailsFrame.java   Source Code and License Vote up 6 votes
@Override
public void mouseClicked(MouseEvent event)
{
   int xPos = event.getX(); // get x-position of mouse
   int yPos = event.getY(); // get y-position of mouse

   details = String.format("Clicked %d time(s)", 
      event.getClickCount());

   if (event.isMetaDown()) // right mouse button   
      details += " with right mouse button";
   else if (event.isAltDown()) // middle mouse button
      details += " with center mouse button";
   else // left mouse button                       
      details += " with left mouse button";

   statusBar.setText(details); 
}
 
Example 3
Project: TopDownGame   File: ClearLineTest.java   Source Code and License Vote up 5 votes
@Override
public void mousePressed(MouseEvent e)
{
	if(e.isAltDown())
		System.out.println(mw.gameMap.clearLine(mouse, click));
	else
		click = translateToReal(e.getX(), e.getY());
	
	
}
 
Example 4
Project: incubator-netbeans   File: EditorCaret.java   Source Code and License Vote up 5 votes
@Override
public void mouseReleased(MouseEvent evt) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("EditorCaret.mouseReleased: " + logMouseEvent(evt) + ", state=" + mouseState + '\n'); // NOI18N
    }

    int offset = mouse2Offset(evt);
    switch (mouseState) {
        case DRAG_SELECTION_POSSIBLE:
            setDot(offset);
            adjustRectangularSelectionMouseX(evt.getX(), evt.getY()); // also fires state change
            break;

        case CHAR_SELECTION:
            if (evt.isAltDown() && evt.isShiftDown()) {
                moveDot(offset);
            } else {
                moveDot(offset); // Will do setDot() if no selection
                adjustRectangularSelectionMouseX(evt.getX(), evt.getY()); // also fires state change
            }
            break;
    }
    // Set DEFAULT state; after next mouse press the state may change
    // to another state according to particular click count
    mouseState = MouseState.DEFAULT;
    component.setDragEnabled(true);
}
 
Example 5
Project: marathonv5   File: RComponent.java   Source Code and License Vote up 5 votes
protected void mousePressed(MouseEvent me) {
    if (me.getButton() == MouseEvent.BUTTON1 && me.getClickCount() == 1 && !me.isAltDown() && !me.isMetaDown()
            && !me.isAltGraphDown() && !me.isControlDown()) {
        mouseButton1Pressed(me);
    } else {
        recorder.recordClick2(this, me, true);
    }
}
 
Example 6
Project: spacesettlers   File: HumanTeamClient.java   Source Code and License Vote up 5 votes
@Override
public void mouseReleased(MouseEvent e) {
	Point point = e.getPoint();
	
	Point2D newPoint = new Point2D.Double(0, 0);
	mouseTransform.transform(point, newPoint); 
	
	// only listen to the right button
	if (e.getButton() == MouseEvent.BUTTON3 || e.isAltDown()) {
		//System.out.println("User right clicked at " + point.x + ", " + point.y);
		lastMouseClick = new Position(newPoint.getX(), newPoint.getY());
	}
}
 
Example 7
Project: Proj4   File: HumanTeamClient.java   Source Code and License Vote up 5 votes
@Override
public void mouseReleased(MouseEvent e) {
	Point point = e.getPoint();
	
	Point2D newPoint = new Point2D.Double(0, 0);
	mouseTransform.transform(point, newPoint); 
	
	// only listen to the right button
	if (e.getButton() == MouseEvent.BUTTON3 || e.isAltDown()) {
		//System.out.println("User right clicked at " + point.x + ", " + point.y);
		lastMouseClick = new Position(newPoint.getX(), newPoint.getY());
	}
}
 
Example 8
Project: JavaGraph   File: JGraphUI.java   Source Code and License Vote up 5 votes
@Override
public void mousePressed(MouseEvent e) {
    if (!isMyEvent(e)) {
        return;
    }
    getJGraph().requestFocus();
    stopEditing(getJGraph());
    // determine the drag mode (although dragging does not yet start)
    DragMode newDragMode;
    JCell<G> jVertex = getJVertexAt(e.getPoint());
    JCell<G> jEdge = getJEdgeAt(e.getPoint());
    if (getJGraphMode() == PAN_MODE && e.getButton() == BUTTON1) {
        newDragMode = PAN;
    } else if (jVertex != null || jEdge != null) {
        // either start adding an edge, or move 
        if (getJGraphMode() == EDIT_MODE && e.getButton() == BUTTON1
            && !ADD_EDGE_BY_CLICK) {
            if (jEdge != null) {
                newDragMode = MOVE;
            } else if (getJGraph().isCellSelected(jVertex)) {
                newDragMode = EDGE;
            } else if (e.isAltDown()) {
                newDragMode = EDGE;
            } else {
                newDragMode = MOVE;
            }
        } else {
            newDragMode = MOVE;
        }
    } else {
        newDragMode = SELECT;
    }
    this.dragMode = newDragMode;
    this.dragStart = e;
}
 
Example 9
Project: Cognizant-Intelligent-Test-Scripter   File: TestCaseAutoSuggest.java   Source Code and License Vote up 5 votes
@Override
public void mouseClicked(MouseEvent me) {
    if (me.isAltDown()) {
        if (table.rowAtPoint(me.getPoint()) != -1 && getTestCase(table) != null) {
            TestStep step = getTestCase(table).getTestSteps().get(table.rowAtPoint(me.getPoint()));
            if (isDataBaseQueryStep(step) && table.columnAtPoint(me.getPoint()) == Input.getIndex()) {
                new SQLTextArea(null, step, getInputs());
            }
        }
    }
}
 
Example 10
Project: jaer   File: EvolutionaryThrottleController.java   Source Code and License Vote up 5 votes
private boolean isShift(MouseEvent e) {
    if (e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) {
        return true;
    } else {
        return false;
    }
}
 
Example 11
Project: Cognizant-Intelligent-Test-Scripter   File: TableCellDrag.java   Source Code and License Vote up 5 votes
@Override
public void mouseDragged(MouseEvent e) {
    if (e.isAltDown() && startLocation != null) {
        isInDragOperation = true;
        JTable t = (JTable) e.getSource();
        int selRow = t.rowAtPoint(e.getPoint());
        int selColumn = t.columnAtPoint(e.getPoint());
        if (selRow != -1 && selColumn != -1) {
            rowsRColumns.add(new Integer[]{selRow, selColumn});
        }
    } else {
        isInDragOperation = false;
    }
}
 
Example 12
Project: jaer   File: HumanVsComputerThrottleController.java   Source Code and License Vote up 5 votes
private boolean isShift(MouseEvent e) {
    if (e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) {
        return true;
    } else {
        return false;
    }
}
 
Example 13
Project: jaer   File: HumanVsComputerThrottleController.java   Source Code and License Vote up 5 votes
private boolean isControl(MouseEvent e) {
    if (!e.isShiftDown() && e.isControlDown() && !e.isAltDown()) {
        return true;
    } else {
        return false;
    }
}
 
Example 14
Project: jaer   File: HumanVsComputerThrottleController.java   Source Code and License Vote up 5 votes
@Override
public void mouseDragged(MouseEvent e) {
    if (currentProfile == null) {
        return;
    }
    int idx = -1;
    if ((idx = getIndex(e)) == -1) {
        return;
    }
    if (idx != lastEditIdx) {
        if (e.isAltDown() && e.isShiftDown()) {
            // brake point
            currentProfile.editClearBrake(idx);
            currentProfile.log();
            editState = EditState.None;
            glCanvas.repaint();
        } else if (e.isAltDown() && !e.isShiftDown()) {
            // brake point
            currentProfile.editSetBrake(idx);
            currentProfile.log();
            editState = EditState.None;
            glCanvas.repaint();
        } else if (isShift(e)) {
            currentProfile.editIncreaseThrottle(idx);
            currentProfile.log();
            editState = EditState.Increae;
            glCanvas.repaint();
        } else if (isControl(e)) {
            currentProfile.editDecreaseThrottle(idx);
            currentProfile.log();
            editState = EditState.Decrease;
            glCanvas.repaint();
        } else {
            editState = EditState.None;
        }
    }
    lastEditIdx = idx;
}
 
Example 15
Project: incubator-netbeans   File: EditorCaret.java   Source Code and License Vote up 4 votes
@Override
public void mouseDragged(MouseEvent evt) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("EditorCaret.mouseDragged: " + logMouseEvent(evt) + ", state=" + mouseState + '\n'); //NOI18N
    }

    if (isLeftMouseButtonExt(evt)) {
        JTextComponent c = component;
        int offset = mouse2Offset(evt);
        int dot = getDot();
        int mark = getMark();
        LineDocument lineDoc = LineDocumentUtils.asRequired(c.getDocument(), LineDocument.class);
        
        try {
            switch (mouseState) {
                case DEFAULT:
                case DRAG_SELECTION:
                    break;

                case DRAG_SELECTION_POSSIBLE:
                    mouseState = MouseState.DRAG_SELECTION;
                    break;

                case CHAR_SELECTION:
                    if (evt.isAltDown() && evt.isShiftDown()) {
                        moveDot(offset);
                    } else {
                        moveDot(offset);
                        adjustRectangularSelectionMouseX(evt.getX(), evt.getY());
                    }
                    break; // Use the offset under mouse pointer

                case WORD_SELECTION:
                    // Increase selection if at least in the middle of a word.
                    // It depends whether selection direction is from lower offsets upward or back.
                    if (offset >= mark) { // Selection extends forward.
                        offset = LineDocumentUtils.getWordEnd(lineDoc, offset);
                    } else { // Selection extends backward.
                        offset = LineDocumentUtils.getWordStart(lineDoc, offset);
                    }
                    selectEnsureMinSelection(mark, dot, offset);
                    break;

                case LINE_SELECTION:
                    if (offset >= mark) { // Selection extends forward
                        offset = Math.min(LineDocumentUtils.getLineEnd(lineDoc, offset) + 1, c.getDocument().getLength());
                    } else { // Selection extends backward
                        offset = LineDocumentUtils.getLineStart(lineDoc, offset);
                    }
                    selectEnsureMinSelection(mark, dot, offset);
                    break;

                default:
                    throw new AssertionError("Invalid state " + mouseState); // NOI18N
            }
        } catch (BadLocationException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
 
Example 16
Project: incubator-netbeans   File: ProfilerTableContainer.java   Source Code and License Vote up 4 votes
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
Example 17
Project: incubator-netbeans   File: JTreeTablePanel.java   Source Code and License Vote up 4 votes
private static boolean onlyShift(MouseEvent e) {
    return e.isShiftDown() && !(e.isAltDown() || e.isAltGraphDown() ||
                                e.isControlDown() || e.isMetaDown());
}
 
Example 18
Project: Tarski   File: mxGraphComponent.java   Source Code and License Vote up 2 votes
/**
 * Note: This is not used during drag and drop operations due to limitations of the underlying
 * API. To enable this for move operations set dragEnabled to false.
 * 
 * @param event
 * @return Returns true if the given event is constrained.
 */
public boolean isForceMarqueeEvent(MouseEvent event) {
  return (event != null) ? event.isAltDown() : false;
}
 
Example 19
Project: Tarski   File: mxGraphComponent.java   Source Code and License Vote up 2 votes
/**
 * 
 * @param event
 * @return Returns true if the given event allows the grid to be applied.
 */
public boolean isGridEnabledEvent(MouseEvent event) {
  return (event != null) ? !event.isAltDown() : false;
}
 
Example 20
Project: TrabalhoFinalEDA2   File: mxGraphComponent.java   Source Code and License Vote up 2 votes
/**
 * 
 * @param event
 * @return Returns true if the given event allows the grid to be applied.
 */
public boolean isGridEnabledEvent(MouseEvent event)
{
	return (event != null) ? !event.isAltDown() : false;
}