1 /* |
1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
29 import java.util.*; |
29 import java.util.*; |
30 import java.util.List; |
30 import java.util.List; |
31 |
31 |
32 import javax.swing.*; |
32 import javax.swing.*; |
33 |
33 |
34 import javax.tools.annotation.GenerateNativeHeader; |
34 import java.lang.annotation.Native; |
35 |
35 |
36 /* No native methods here, but the constants are needed in the supporting JNI code */ |
|
37 @GenerateNativeHeader |
|
38 final class GestureHandler { |
36 final class GestureHandler { |
39 private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalGestureHandler"; |
37 private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalGestureHandler"; |
40 |
38 |
41 // native constants for the supported types of high-level gestures |
39 // native constants for the supported types of high-level gestures |
42 static final int PHASE = 1; |
40 @Native static final int PHASE = 1; |
43 static final int ROTATE = 2; |
41 @Native static final int ROTATE = 2; |
44 static final int MAGNIFY = 3; |
42 @Native static final int MAGNIFY = 3; |
45 static final int SWIPE = 4; |
43 @Native static final int SWIPE = 4; |
46 |
44 |
47 // installs a private instance of GestureHandler, if necessary |
45 // installs a private instance of GestureHandler, if necessary |
48 static void addGestureListenerTo(final JComponent component, final GestureListener listener) { |
46 static void addGestureListenerTo(final JComponent component, final GestureListener listener) { |
49 final Object value = component.getClientProperty(CLIENT_PROPERTY); |
47 final Object value = component.getClientProperty(CLIENT_PROPERTY); |
50 if (value instanceof GestureHandler) { |
48 if (value instanceof GestureHandler) { |