Java Code Examples for java.awt.event.MouseEvent#MOUSE_WHEEL

The following examples show how to use java.awt.event.MouseEvent#MOUSE_WHEEL . 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: WorldMapPlugin.java    From 07kit with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onMapZoom(MouseWheelEvent event) {
    if (event.getID() == MouseEvent.MOUSE_WHEEL) {
        if (getMapBounds().contains(event.getPoint()) && visible) {
            event.consume();
            int scroll = event.getWheelRotation();
            zoom += scroll * ZOOM_UNIT;
            if (scroll > 0) {
                zoom = Math.min(zoom, ZOOM_MAX);
            } else {
                zoom = Math.max(zoom, ZOOM_MIN);
            }
            if (zoom != lastZoom) {
                double dz = zoom - lastZoom;
                offset.x -= (dz * getMapWidth()) / 2;
                offset.y -= (dz * getMapHeight()) / 2;
            }
            lastZoom = zoom;
            refresh();
        }
    }
}
 
Example 2
Source File: Java3DEditor.java    From MogwaiERDesignerNG with GNU General Public License v3.0 6 votes vote down vote up
private void doProcess(MouseEvent e) {
    // We only handle events if there is something selected
    if (selectedModelItem != null) {
        switch (e.getID()) {
            case MouseEvent.MOUSE_MOVED:
                mouseMoved(e);
                break;
            case MouseEvent.MOUSE_CLICKED:
                mouseClicked(e);
                break;
            case MouseEvent.MOUSE_WHEEL:
                mouseWheel((MouseWheelEvent) e);
                break;
            case MouseEvent.MOUSE_DRAGGED:
                mouseDragged(e);
                break;
            case MouseEvent.MOUSE_RELEASED:
                mouseReleased(e);
                break;
        }
    }
}
 
Example 3
Source File: AWTEvent.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Consumes this event, if this event can be consumed. Only low-level,
 * system events can be consumed
 */
protected void consume() {
    switch(id) {
      case KeyEvent.KEY_PRESSED:
      case KeyEvent.KEY_RELEASED:
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_MOVED:
      case MouseEvent.MOUSE_DRAGGED:
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
      case MouseEvent.MOUSE_WHEEL:
      case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
      case InputMethodEvent.CARET_POSITION_CHANGED:
          consumed = true;
          break;
      default:
          // event type cannot be consumed
    }
}
 
Example 4
Source File: MouseEventUI.java    From darklaf with MIT License 6 votes vote down vote up
@SuppressWarnings("DuplicatedCode")

    private Component getListeningComponent(final MouseEvent event, final Component component) {
        Component comp;
        switch (event.getID()) {
            case MouseEvent.MOUSE_CLICKED :
            case MouseEvent.MOUSE_ENTERED :
            case MouseEvent.MOUSE_EXITED :
            case MouseEvent.MOUSE_PRESSED :
            case MouseEvent.MOUSE_RELEASED :
                comp = getMouseListeningComponent(component);
                break;
            case MouseEvent.MOUSE_DRAGGED :
            case MouseEvent.MOUSE_MOVED :
                comp = getMouseMotionListeningComponent(component);
                break;
            case MouseEvent.MOUSE_WHEEL :
                comp = getMouseWheelListeningComponent(component);
                break;
            default :
                comp = null;
        }
        return comp;
    }
 
Example 5
Source File: bug7146377.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 6
Source File: bug7146377.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 7
Source File: bug7146377.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 8
Source File: bug7146377.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 9
Source File: Outline.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void processMouseEvent(MouseEvent e) {
    switch(e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_RELEASED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_CLICKED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_ENTERED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_EXITED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_MOVED:
          break;
      case MouseEvent.MOUSE_DRAGGED:
          if (selectionDisabled) {
              //System.err.println("\nDrag DISABLED.");
              return ;
          }
          break;
      case MouseEvent.MOUSE_WHEEL:
          break;
    }
    super.processMouseEvent(e);
}
 
Example 10
Source File: bug7146377.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 11
Source File: bug7146377.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 12
Source File: PointSelectionBehavior.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void doProcess(final MouseEvent me) {
	if (me.isConsumed() || Toolbar.getToolId() != Toolbar.WAND)
		return;
	final int mouseEventID = me.getID();
	/*
	 * It's nice to still be able to zoom with the mouse wheel, so don't
	 * consume this event.
	 */
	if (mouseEventID == MouseEvent.MOUSE_WHEEL)
		return;
	me.consume();
	if (mouseEventID != MouseEvent.MOUSE_CLICKED)
		return;
	final Picker picker = univ.getPicker();
	final Content c = picker.getPickedContent(me.getX(), me.getY());
	if (null == c)
		return;

	final Point3d point = picker.getPickPointGeometry(c, me.getX(), me.getY());

	final boolean mac = IJ.isMacintosh();

	final boolean shift_key_down = (me.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
	final boolean joiner_modifier_down = mac ? ((me.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0)
			: ((me.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0);

	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			tracerPlugin.clickForTrace(point, joiner_modifier_down);
		}
	});
}
 
Example 13
Source File: bug7146377.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 14
Source File: Java3DEditor.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
public MouseNavigationBehavior() {
    WakeupOnAWTEvent mouseMoveCondition = new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED);
    WakeupOnAWTEvent mouseClickCondition = new WakeupOnAWTEvent(MouseEvent.MOUSE_CLICKED);
    WakeupOnAWTEvent mouseWheel = new WakeupOnAWTEvent(MouseEvent.MOUSE_WHEEL);
    WakeupOnAWTEvent mouseDrag = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
    WakeupOnAWTEvent mouseReleased = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
    wakeupCondition = new WakeupOr(new WakeupCriterion[]{mouseMoveCondition, mouseClickCondition, mouseWheel, mouseDrag, mouseReleased});
}
 
Example 15
Source File: bug7146377.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 16
Source File: ProfilerTableHover.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private boolean isForwardEvent(MouseEvent e) {
    int eventID = e.getID();
    return eventID == MouseEvent.MOUSE_PRESSED ||
           eventID == MouseEvent.MOUSE_RELEASED ||
           eventID == MouseEvent.MOUSE_WHEEL;
}
 
Example 17
Source File: ProfilerTableHover.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private boolean isForwardEvent(MouseEvent e) {
    int eventID = e.getID();
    return eventID == MouseEvent.MOUSE_PRESSED ||
           eventID == MouseEvent.MOUSE_RELEASED ||
           eventID == MouseEvent.MOUSE_WHEEL;
}
 
Example 18
Source File: UIMouse.java    From open-ig with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Create an UIMouse from a Mouse Event.
 * @param e the mouse event
 * @return the UI mouse
 */
public static UIMouse from(MouseEvent e) {
	UIMouse m = new UIMouse();
	m.x = e.getX();
	m.y = e.getY();
	if (SwingUtilities.isLeftMouseButton(e)) {
		m.buttons.add(Button.LEFT);
	}
	if (SwingUtilities.isMiddleMouseButton(e)) {
		m.buttons.add(Button.MIDDLE);
	}
	if (SwingUtilities.isRightMouseButton(e)) {
		m.buttons.add(Button.RIGHT);
	}
	if (e.isShiftDown()) {
		m.modifiers.add(Modifier.SHIFT);
	}
	if (e.isControlDown()) {
		m.modifiers.add(Modifier.CTRL);
	}
	if (e.isAltDown()) {
		m.modifiers.add(Modifier.ALT);
	}
	switch (e.getID()) {
	case MouseEvent.MOUSE_CLICKED:
		m.type = e.getClickCount() == 1 ? Type.CLICK : Type.DOUBLE_CLICK;
		m.z = e.getClickCount();
		break;
	case MouseEvent.MOUSE_PRESSED:
		m.type = Type.DOWN;
		break;
	case MouseEvent.MOUSE_RELEASED:
		m.type = Type.UP;
		break;
	case MouseEvent.MOUSE_MOVED:
		m.type = Type.MOVE;
		break;
	case MouseEvent.MOUSE_DRAGGED:
		m.type = Type.DRAG;
		break;
	case MouseEvent.MOUSE_ENTERED:
		m.type = Type.ENTER;
		break;
	case MouseEvent.MOUSE_EXITED:
		m.type = Type.LEAVE;
		break;
	case MouseEvent.MOUSE_WHEEL:
		m.type = Type.WHEEL;
		m.z = ((MouseWheelEvent)e).getUnitsToScroll();
		break;
	default:
	}
	
	return m;
}
 
Example 19
Source File: Toolkit.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void eventDispatched(AWTEvent event) {
    long eventBit = 0; // Used to save the bit of the event type.
    if (((eventBit = eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 &&
         event.id >= ComponentEvent.COMPONENT_FIRST &&
         event.id <= ComponentEvent.COMPONENT_LAST)
     || ((eventBit = eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 &&
         event.id >= ContainerEvent.CONTAINER_FIRST &&
         event.id <= ContainerEvent.CONTAINER_LAST)
     || ((eventBit = eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 &&
         event.id >= FocusEvent.FOCUS_FIRST &&
         event.id <= FocusEvent.FOCUS_LAST)
     || ((eventBit = eventMask & AWTEvent.KEY_EVENT_MASK) != 0 &&
         event.id >= KeyEvent.KEY_FIRST &&
         event.id <= KeyEvent.KEY_LAST)
     || ((eventBit = eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 &&
         event.id == MouseEvent.MOUSE_WHEEL)
     || ((eventBit = eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 &&
         (event.id == MouseEvent.MOUSE_MOVED ||
          event.id == MouseEvent.MOUSE_DRAGGED))
     || ((eventBit = eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 &&
         event.id != MouseEvent.MOUSE_MOVED &&
         event.id != MouseEvent.MOUSE_DRAGGED &&
         event.id != MouseEvent.MOUSE_WHEEL &&
         event.id >= MouseEvent.MOUSE_FIRST &&
         event.id <= MouseEvent.MOUSE_LAST)
     || ((eventBit = eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 &&
         (event.id >= WindowEvent.WINDOW_FIRST &&
         event.id <= WindowEvent.WINDOW_LAST))
     || ((eventBit = eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 &&
         event.id >= ActionEvent.ACTION_FIRST &&
         event.id <= ActionEvent.ACTION_LAST)
     || ((eventBit = eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 &&
         event.id >= AdjustmentEvent.ADJUSTMENT_FIRST &&
         event.id <= AdjustmentEvent.ADJUSTMENT_LAST)
     || ((eventBit = eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 &&
         event.id >= ItemEvent.ITEM_FIRST &&
         event.id <= ItemEvent.ITEM_LAST)
     || ((eventBit = eventMask & AWTEvent.TEXT_EVENT_MASK) != 0 &&
         event.id >= TextEvent.TEXT_FIRST &&
         event.id <= TextEvent.TEXT_LAST)
     || ((eventBit = eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 &&
         event.id >= InputMethodEvent.INPUT_METHOD_FIRST &&
         event.id <= InputMethodEvent.INPUT_METHOD_LAST)
     || ((eventBit = eventMask & AWTEvent.PAINT_EVENT_MASK) != 0 &&
         event.id >= PaintEvent.PAINT_FIRST &&
         event.id <= PaintEvent.PAINT_LAST)
     || ((eventBit = eventMask & AWTEvent.INVOCATION_EVENT_MASK) != 0 &&
         event.id >= InvocationEvent.INVOCATION_FIRST &&
         event.id <= InvocationEvent.INVOCATION_LAST)
     || ((eventBit = eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 &&
         event.id == HierarchyEvent.HIERARCHY_CHANGED)
     || ((eventBit = eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 &&
         (event.id == HierarchyEvent.ANCESTOR_MOVED ||
          event.id == HierarchyEvent.ANCESTOR_RESIZED))
     || ((eventBit = eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 &&
         event.id == WindowEvent.WINDOW_STATE_CHANGED)
     || ((eventBit = eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 &&
         (event.id == WindowEvent.WINDOW_GAINED_FOCUS ||
          event.id == WindowEvent.WINDOW_LOST_FOCUS))
        || ((eventBit = eventMask & sun.awt.SunToolkit.GRAB_EVENT_MASK) != 0 &&
            (event instanceof sun.awt.UngrabEvent))) {
        // Get the index of the call count for this event type.
        // Instead of using Math.log(...) we will calculate it with
        // bit shifts. That's what previous implementation looked like:
        //
        // int ci = (int) (Math.log(eventBit)/Math.log(2));
        int ci = 0;
        for (long eMask = eventBit; eMask != 0; eMask >>>= 1, ci++) {
        }
        ci--;
        // Call the listener as many times as it was added for this
        // event type.
        for (int i=0; i<calls[ci]; i++) {
            listener.eventDispatched(event);
        }
    }
}
 
Example 20
Source File: MouseEventUI.java    From darklaf with MIT License 4 votes vote down vote up
@SuppressWarnings("Duplicates")
private void redispatch(final MouseEvent originalEvent,
                        final JXLayer<? extends V> layer) {
    if (layer.getView() != null) {
        if (originalEvent.getComponent() != layer.getGlassPane()) {
            originalEvent.consume();
        }
        MouseEvent newEvent = null;

        Point realPoint = calculateTargetPoint(layer, originalEvent);
        Component realTarget = getTarget(layer, realPoint);
        if (realTarget != null) {
            realTarget = getListeningComponent(originalEvent, realTarget);
        }

        switch (originalEvent.getID()) {
            case MouseEvent.MOUSE_PRESSED :
                newEvent = transformMouseEvent(layer, originalEvent, realTarget, realPoint);
                if (newEvent != null) {
                    lastPressedTarget = newEvent.getComponent();
                }
                break;
            case MouseEvent.MOUSE_RELEASED :
                newEvent = transformMouseEvent(layer, originalEvent, lastPressedTarget, realPoint);
                lastPressedTarget = null;
                break;
            case MouseEvent.MOUSE_ENTERED :
            case MouseEvent.MOUSE_EXITED :
                generateEnterExitEvents(layer, originalEvent, realTarget, realPoint);
                break;
            case MouseEvent.MOUSE_MOVED :
                newEvent = transformMouseEvent(layer, originalEvent, realTarget, realPoint);
                generateEnterExitEvents(layer, originalEvent, realTarget, realPoint);
                break;
            case MouseEvent.MOUSE_DRAGGED :
                newEvent = transformMouseEvent(layer, originalEvent, lastPressedTarget, realPoint);
                generateEnterExitEvents(layer, originalEvent, realTarget, realPoint);
                break;
            case MouseEvent.MOUSE_CLICKED :
                newEvent = transformMouseEvent(layer, originalEvent, realTarget, realPoint);
                break;
            case (MouseEvent.MOUSE_WHEEL) :
                redispatchMouseWheelEvent((MouseWheelEvent) originalEvent, realTarget, layer);
                break;
        }
        dispatchMouseEvent(newEvent);
    }
}