Java Code Examples for java.awt.event.MouseEvent#BUTTON3_DOWN_MASK
The following examples show how to use
java.awt.event.MouseEvent#BUTTON3_DOWN_MASK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultMapController.java From amodeus with GNU General Public License v2.0 | 6 votes |
/** Sets the mouse button that is used for moving the map. Possible values are: * <ul> * <li>{@link MouseEvent#BUTTON1} (left mouse button)</li> * <li>{@link MouseEvent#BUTTON2} (middle mouse button)</li> * <li>{@link MouseEvent#BUTTON3} (right mouse button)</li> * </ul> * * @param movementMouseButton the mouse button that is used for moving the map */ public void setMovementMouseButton(int movementMouseButton) { this.movementMouseButton = movementMouseButton; switch (movementMouseButton) { case MouseEvent.BUTTON1: movementMouseButtonMask = MouseEvent.BUTTON1_DOWN_MASK; break; case MouseEvent.BUTTON2: movementMouseButtonMask = MouseEvent.BUTTON2_DOWN_MASK; break; case MouseEvent.BUTTON3: movementMouseButtonMask = MouseEvent.BUTTON3_DOWN_MASK; break; default: throw new RuntimeException("Unsupported button"); } }
Example 2
Source File: NBodyVisualizer.java From gpu-nbody with MIT License | 6 votes |
@Override public void mouseDragged(final MouseEvent e) { final int dx = e.getX() - previousMousePosition.x; final int dy = e.getY() - previousMousePosition.y; // If the left button is held down, move the object if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK) { translationX += dx / 100.0f; translationY -= dy / 100.0f; } // If the right button is held down, rotate the object else if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) { rotationX += dy; rotationY += dx; } previousMousePosition = e.getPoint(); updateModelviewMatrix(); }
Example 3
Source File: DefaultMapController.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
/** * Sets the mouse button that is used for moving the map. Possible values are: * <ul> * <li>{@link MouseEvent#BUTTON1} (left mouse button)</li> * <li>{@link MouseEvent#BUTTON2} (middle mouse button)</li> * <li>{@link MouseEvent#BUTTON3} (right mouse button)</li> * </ul> * * @param movementMouseButton */ public void setMovementMouseButton(int movementMouseButton) { this.movementMouseButton = movementMouseButton; switch (movementMouseButton) { case MouseEvent.BUTTON1: movementMouseButtonMask = MouseEvent.BUTTON1_DOWN_MASK; break; case MouseEvent.BUTTON2: movementMouseButtonMask = MouseEvent.BUTTON2_DOWN_MASK; break; case MouseEvent.BUTTON3: movementMouseButtonMask = MouseEvent.BUTTON3_DOWN_MASK; break; default: throw new RuntimeException("Unsupported button"); } }
Example 4
Source File: CGMapController.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
/** * Sets the mouse button that is used for moving the map. Possible values are: * <ul> * <li>{@link MouseEvent#BUTTON1} (left mouse button)</li> * <li>{@link MouseEvent#BUTTON2} (middle mouse button)</li> * <li>{@link MouseEvent#BUTTON3} (right mouse button)</li> * </ul> * * @param movementMouseButton */ public void setMovementMouseButton(int movementMouseButton) { this.movementMouseButton = movementMouseButton; switch (movementMouseButton) { case MouseEvent.BUTTON1: movementMouseButtonMask = MouseEvent.BUTTON1_DOWN_MASK; break; case MouseEvent.BUTTON2: movementMouseButtonMask = MouseEvent.BUTTON2_DOWN_MASK; break; case MouseEvent.BUTTON3: movementMouseButtonMask = MouseEvent.BUTTON3_DOWN_MASK; break; default: throw new RuntimeException("Unsupported button"); } }
Example 5
Source File: SimpleInteraction.java From jcuda-samples with MIT License | 6 votes |
@Override public void mouseDragged(MouseEvent e) { int dx = e.getX() - previousMousePosition.x; int dy = e.getY() - previousMousePosition.y; // If the left button is held down, move the object if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK) { translationX += dx / 100.0f; translationY -= dy / 100.0f; } // If the right button is held down, rotate the object else if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) { rotationDegX += dy; rotationDegY += dx; } previousMousePosition = e.getPoint(); updateModelviewMatrix(); }
Example 6
Source File: MainFrame.java From zxpoly with GNU General Public License v3.0 | 6 votes |
private int extractButtons(final MouseEvent event) { int result = AbstractTool.BUTTON_NONE; if ((event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) { result |= AbstractTool.BUTTON_CTRL; } if ((event.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) != 0) { result |= AbstractTool.BUTTON_ALT; } if ((event.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) { result |= AbstractTool.BUTTON_SHIFT; } if ((event.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { result |= AbstractTool.BUTTON_MOUSE_LEFT; } if ((event.getModifiersEx() & MouseEvent.BUTTON2_DOWN_MASK) != 0) { result |= AbstractTool.BUTTON_MOUSE_MIDDLE; } if ((event.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) != 0) { result |= AbstractTool.BUTTON_MOUSE_RIGHT; } return result; }
Example 7
Source File: ProtocolTab.java From aion-germany with GNU General Public License v3.0 | 5 votes |
public void mousePressed(MouseEvent e) { if (_format == null) return; if (_dragedObject != null && (e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) { // TODO: cancel System.out.println("Cancel"); return; } _firstMouseEvent = e; _dragedObject = getObjectAt(e.getX(), e.getY()); }
Example 8
Source File: SwingTerminal.java From jexer with MIT License | 5 votes |
/** * Pass mouse events into the event queue. * * @param mouse mouse event received */ public void mouseDragged(final MouseEvent mouse) { int modifiers = mouse.getModifiersEx(); boolean eventMouse1 = false; boolean eventMouse2 = false; boolean eventMouse3 = false; if ((modifiers & MouseEvent.BUTTON1_DOWN_MASK) != 0) { eventMouse1 = true; } if ((modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0) { eventMouse2 = true; } if ((modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0) { eventMouse3 = true; } mouse1 = eventMouse1; mouse2 = eventMouse2; mouse3 = eventMouse3; int x = textColumn(mouse.getX()); int y = textRow(mouse.getY()); TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_MOTION, x, y, x, y, mouse1, mouse2, mouse3, false, false); synchronized (eventQueue) { eventQueue.add(mouseEvent); resetBlinkTimer(); } if (listener != null) { synchronized (listener) { listener.notifyAll(); } } }
Example 9
Source File: SwingTerminal.java From jexer with MIT License | 5 votes |
/** * Pass mouse events into the event queue. * * @param mouse mouse event received */ public void mousePressed(final MouseEvent mouse) { int modifiers = mouse.getModifiersEx(); boolean eventMouse1 = false; boolean eventMouse2 = false; boolean eventMouse3 = false; if ((modifiers & MouseEvent.BUTTON1_DOWN_MASK) != 0) { eventMouse1 = true; } if ((modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0) { eventMouse2 = true; } if ((modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0) { eventMouse3 = true; } mouse1 = eventMouse1; mouse2 = eventMouse2; mouse3 = eventMouse3; int x = textColumn(mouse.getX()); int y = textRow(mouse.getY()); TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_DOWN, x, y, x, y, mouse1, mouse2, mouse3, false, false); synchronized (eventQueue) { eventQueue.add(mouseEvent); resetBlinkTimer(); } if (listener != null) { synchronized (listener) { listener.notifyAll(); } } }
Example 10
Source File: ConsoleProxyRdpClient.java From cloudstack with Apache License 2.0 | 5 votes |
public int mapMouseDownModifier(int code, int modifiers) { int mod = mapModifier(modifiers); switch (code) { case 0: mod = mod | MouseEvent.BUTTON1_DOWN_MASK; break; case 2: mod = mod | MouseEvent.BUTTON3_DOWN_MASK; break; default: } return mod; }
Example 11
Source File: ColorIndicator.java From Spade with GNU General Public License v3.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { boolean swap = (e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == 0; if(swap) { MutableColor tmp = primary; primary = secondary; secondary = tmp; parent.makeChange(this, Red, secondary.getRed(), false); parent.makeChange(this, Green, secondary.getGreen(), false); parent.makeChange(this, Blue, secondary.getBlue(), false); parent.makeChange(this, Alpha, secondary.getAlpha(), false); parent.makeChange(this, Red, primary.getRed(), true); parent.makeChange(this, Green, primary.getGreen(), true); parent.makeChange(this, Blue, primary.getBlue(), true); parent.makeChange(this, Alpha, primary.getAlpha(), true); parent.broadcastChanges(this); } else { int x = e.getX(); int y = e.getY(); if(x >= 2 && y >= 2 && x < 34 && y < 34) { hexField.showFor(true, this); } else if(((x >= 36 && y >= 18) || (x >= 18 && y >= 36)) && x < 50 && y < 50) { hexField.showFor(false, this); } } }
Example 12
Source File: GraphEditorMouseEvent.java From workcraft with MIT License | 4 votes |
public int getButtonModifiers() { // BUTTON2 is ignored as it is reserved for panning return event.getModifiersEx() & (MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK); }
Example 13
Source File: SwingTerminal.java From jexer with MIT License | 4 votes |
/** * Pass mouse events into the event queue. * * @param mouse mouse event received */ public void mouseReleased(final MouseEvent mouse) { int modifiers = mouse.getModifiersEx(); boolean eventMouse1 = false; boolean eventMouse2 = false; boolean eventMouse3 = false; if ((modifiers & MouseEvent.BUTTON1_DOWN_MASK) != 0) { eventMouse1 = true; } if ((modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0) { eventMouse2 = true; } if ((modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0) { eventMouse3 = true; } if (mouse1) { mouse1 = false; eventMouse1 = true; } if (mouse2) { mouse2 = false; eventMouse2 = true; } if (mouse3) { mouse3 = false; eventMouse3 = true; } int x = textColumn(mouse.getX()); int y = textRow(mouse.getY()); TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_UP, x, y, x, y, eventMouse1, eventMouse2, eventMouse3, false, false); synchronized (eventQueue) { eventQueue.add(mouseEvent); resetBlinkTimer(); } if (listener != null) { synchronized (listener) { listener.notifyAll(); } } }
Example 14
Source File: SwingTerminal.java From jexer with MIT License | 4 votes |
/** * Pass mouse events into the event queue. * * @param mouse mouse event received */ public void mouseWheelMoved(final MouseWheelEvent mouse) { int modifiers = mouse.getModifiersEx(); boolean eventMouse1 = false; boolean eventMouse2 = false; boolean eventMouse3 = false; boolean mouseWheelUp = false; boolean mouseWheelDown = false; if ((modifiers & MouseEvent.BUTTON1_DOWN_MASK) != 0) { eventMouse1 = true; } if ((modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0) { eventMouse2 = true; } if ((modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0) { eventMouse3 = true; } mouse1 = eventMouse1; mouse2 = eventMouse2; mouse3 = eventMouse3; int x = textColumn(mouse.getX()); int y = textRow(mouse.getY()); if (mouse.getWheelRotation() > 0) { mouseWheelDown = true; } if (mouse.getWheelRotation() < 0) { mouseWheelUp = true; } TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_DOWN, x, y, x, y, mouse1, mouse2, mouse3, mouseWheelUp, mouseWheelDown); synchronized (eventQueue) { eventQueue.add(mouseEvent); resetBlinkTimer(); } if (listener != null) { synchronized (listener) { listener.notifyAll(); } } }