< prev index next >

modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/SwingEvents.java

Print this page

        

*** 21,31 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package javafx.embed.swing; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; --- 21,31 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.javafx.embed.swing; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent;
*** 36,48 **** /** * A utility class to translate event types and data between embedded * application and Swing. */ ! class SwingEvents { ! static int mouseIDToEmbedMouseType(int id) { switch (id) { case MouseEvent.MOUSE_PRESSED: return AbstractEvents.MOUSEEVENT_PRESSED; case MouseEvent.MOUSE_RELEASED: return AbstractEvents.MOUSEEVENT_RELEASED; --- 36,48 ---- /** * A utility class to translate event types and data between embedded * application and Swing. */ ! public class SwingEvents { ! public static int mouseIDToEmbedMouseType(int id) { switch (id) { case MouseEvent.MOUSE_PRESSED: return AbstractEvents.MOUSEEVENT_PRESSED; case MouseEvent.MOUSE_RELEASED: return AbstractEvents.MOUSEEVENT_RELEASED;
*** 58,68 **** return AbstractEvents.MOUSEEVENT_EXITED; } return 0; } ! static int mouseButtonToEmbedMouseButton(int button, int extModifiers) { int abstractButton = AbstractEvents.MOUSEEVENT_NONE_BUTTON; switch (button) { case MouseEvent.BUTTON1: abstractButton = AbstractEvents.MOUSEEVENT_PRIMARY_BUTTON; break; --- 58,68 ---- return AbstractEvents.MOUSEEVENT_EXITED; } return 0; } ! public static int mouseButtonToEmbedMouseButton(int button, int extModifiers) { int abstractButton = AbstractEvents.MOUSEEVENT_NONE_BUTTON; switch (button) { case MouseEvent.BUTTON1: abstractButton = AbstractEvents.MOUSEEVENT_PRIMARY_BUTTON; break;
*** 84,101 **** abstractButton = AbstractEvents.MOUSEEVENT_SECONDARY_BUTTON; } return abstractButton; } ! static int getWheelRotation(MouseEvent e) { if (e instanceof MouseWheelEvent) { return ((MouseWheelEvent)e).getWheelRotation(); } return 0; } ! static int keyIDToEmbedKeyType(int id) { switch (id) { case KeyEvent.KEY_PRESSED: return AbstractEvents.KEYEVENT_PRESSED; case KeyEvent.KEY_RELEASED: return AbstractEvents.KEYEVENT_RELEASED; --- 84,101 ---- abstractButton = AbstractEvents.MOUSEEVENT_SECONDARY_BUTTON; } return abstractButton; } ! public static int getWheelRotation(MouseEvent e) { if (e instanceof MouseWheelEvent) { return ((MouseWheelEvent)e).getWheelRotation(); } return 0; } ! public static int keyIDToEmbedKeyType(int id) { switch (id) { case KeyEvent.KEY_PRESSED: return AbstractEvents.KEYEVENT_PRESSED; case KeyEvent.KEY_RELEASED: return AbstractEvents.KEYEVENT_RELEASED;
*** 103,113 **** return AbstractEvents.KEYEVENT_TYPED; } return 0; } ! static int keyModifiersToEmbedKeyModifiers(int extModifiers) { int embedModifiers = 0; if ((extModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { embedModifiers |= AbstractEvents.MODIFIER_SHIFT; } if ((extModifiers & InputEvent.CTRL_DOWN_MASK) != 0) { --- 103,113 ---- return AbstractEvents.KEYEVENT_TYPED; } return 0; } ! public static int keyModifiersToEmbedKeyModifiers(int extModifiers) { int embedModifiers = 0; if ((extModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { embedModifiers |= AbstractEvents.MODIFIER_SHIFT; } if ((extModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
*** 120,137 **** embedModifiers |= AbstractEvents.MODIFIER_META; } return embedModifiers; } ! static char keyCharToEmbedKeyChar(char ch) { // Convert Swing LF character to Fx CR character. return ch == '\n' ? '\r' : ch; } // FX -> Swing conversion methods ! static int fxMouseEventTypeToMouseID(javafx.scene.input.MouseEvent event) { EventType<?> type = event.getEventType(); if (type == javafx.scene.input.MouseEvent.MOUSE_MOVED) { return MouseEvent.MOUSE_MOVED; } if (type == javafx.scene.input.MouseEvent.MOUSE_PRESSED) { --- 120,137 ---- embedModifiers |= AbstractEvents.MODIFIER_META; } return embedModifiers; } ! public static char keyCharToEmbedKeyChar(char ch) { // Convert Swing LF character to Fx CR character. return ch == '\n' ? '\r' : ch; } // FX -> Swing conversion methods ! public static int fxMouseEventTypeToMouseID(javafx.scene.input.MouseEvent event) { EventType<?> type = event.getEventType(); if (type == javafx.scene.input.MouseEvent.MOUSE_MOVED) { return MouseEvent.MOUSE_MOVED; } if (type == javafx.scene.input.MouseEvent.MOUSE_PRESSED) {
*** 156,166 **** return -1; } throw new RuntimeException("Unknown MouseEvent type: " + type); } ! static int fxMouseModsToMouseMods(javafx.scene.input.MouseEvent event) { int mods = 0; if (event.isAltDown()) { mods |= InputEvent.ALT_DOWN_MASK; } if (event.isControlDown()) { --- 156,166 ---- return -1; } throw new RuntimeException("Unknown MouseEvent type: " + type); } ! public static int fxMouseModsToMouseMods(javafx.scene.input.MouseEvent event) { int mods = 0; if (event.isAltDown()) { mods |= InputEvent.ALT_DOWN_MASK; } if (event.isControlDown()) {
*** 182,192 **** mods |= MouseEvent.BUTTON2_DOWN_MASK; } return mods; } ! static int fxMouseButtonToMouseButton(javafx.scene.input.MouseEvent event) { switch (event.getButton()) { case PRIMARY: return MouseEvent.BUTTON1; case SECONDARY: return MouseEvent.BUTTON3; --- 182,192 ---- mods |= MouseEvent.BUTTON2_DOWN_MASK; } return mods; } ! public static int fxMouseButtonToMouseButton(javafx.scene.input.MouseEvent event) { switch (event.getButton()) { case PRIMARY: return MouseEvent.BUTTON1; case SECONDARY: return MouseEvent.BUTTON3;
*** 194,204 **** return MouseEvent.BUTTON2; } return 0; } ! static int fxKeyEventTypeToKeyID(javafx.scene.input.KeyEvent event) { EventType<?> eventType = event.getEventType(); if (eventType == javafx.scene.input.KeyEvent.KEY_PRESSED) { return KeyEvent.KEY_PRESSED; } if (eventType == javafx.scene.input.KeyEvent.KEY_RELEASED) { --- 194,204 ---- return MouseEvent.BUTTON2; } return 0; } ! public static int fxKeyEventTypeToKeyID(javafx.scene.input.KeyEvent event) { EventType<?> eventType = event.getEventType(); if (eventType == javafx.scene.input.KeyEvent.KEY_PRESSED) { return KeyEvent.KEY_PRESSED; } if (eventType == javafx.scene.input.KeyEvent.KEY_RELEASED) {
*** 208,218 **** return KeyEvent.KEY_TYPED; } throw new RuntimeException("Unknown KeyEvent type: " + eventType); } ! static int fxKeyModsToKeyMods(javafx.scene.input.KeyEvent event) { int mods = 0; if (event.isAltDown()) { mods |= InputEvent.ALT_DOWN_MASK; } if (event.isControlDown()) { --- 208,218 ---- return KeyEvent.KEY_TYPED; } throw new RuntimeException("Unknown KeyEvent type: " + eventType); } ! public static int fxKeyModsToKeyMods(javafx.scene.input.KeyEvent event) { int mods = 0; if (event.isAltDown()) { mods |= InputEvent.ALT_DOWN_MASK; } if (event.isControlDown()) {
*** 225,235 **** mods |= InputEvent.SHIFT_DOWN_MASK; } return mods; } ! static int fxScrollModsToMouseWheelMods(ScrollEvent event) { int mods = 0; if (event.isAltDown()) { mods |= InputEvent.ALT_DOWN_MASK; } if (event.isControlDown()) { --- 225,235 ---- mods |= InputEvent.SHIFT_DOWN_MASK; } return mods; } ! public static int fxScrollModsToMouseWheelMods(ScrollEvent event) { int mods = 0; if (event.isAltDown()) { mods |= InputEvent.ALT_DOWN_MASK; } if (event.isControlDown()) {
< prev index next >