1 /* |
1 /* |
2 * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 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 |
28 import java.util.Collections; |
28 import java.util.Collections; |
29 import java.util.HashMap; |
29 import java.util.HashMap; |
30 import java.util.Iterator; |
30 import java.util.Iterator; |
31 import java.util.Map; |
31 import java.util.Map; |
32 import java.util.Set; |
32 import java.util.Set; |
33 import javax.tools.annotation.GenerateNativeHeader; |
33 import java.lang.annotation.Native; |
34 |
34 |
35 import javax.tools.annotation.GenerateNativeHeader; |
|
36 |
35 |
37 /** |
36 /** |
38 * This class is used to notify listeners about accelerated device's |
37 * This class is used to notify listeners about accelerated device's |
39 * events such as device reset or dispose that are about to occur. |
38 * events such as device reset or dispose that are about to occur. |
40 */ |
39 */ |
41 /* No native methods here, but the constants are needed in the supporting JNI code */ |
|
42 @GenerateNativeHeader |
|
43 public class AccelDeviceEventNotifier { |
40 public class AccelDeviceEventNotifier { |
44 |
41 |
45 private static AccelDeviceEventNotifier theInstance; |
42 private static AccelDeviceEventNotifier theInstance; |
46 |
43 |
47 /** |
44 /** |
48 * A device is about to be reset. The listeners have to release all |
45 * A device is about to be reset. The listeners have to release all |
49 * resources associated with the device which are required for the device |
46 * resources associated with the device which are required for the device |
50 * to be reset. |
47 * to be reset. |
51 */ |
48 */ |
52 public static final int DEVICE_RESET = 0; |
49 @Native public static final int DEVICE_RESET = 0; |
53 |
50 |
54 /** |
51 /** |
55 * A device is about to be disposed. The listeners have to release all |
52 * A device is about to be disposed. The listeners have to release all |
56 * resources associated with the device. |
53 * resources associated with the device. |
57 */ |
54 */ |
58 public static final int DEVICE_DISPOSED = 1; |
55 @Native public static final int DEVICE_DISPOSED = 1; |
59 |
56 |
60 private final Map<AccelDeviceEventListener, Integer> listeners; |
57 private final Map<AccelDeviceEventListener, Integer> listeners; |
61 |
58 |
62 private AccelDeviceEventNotifier() { |
59 private AccelDeviceEventNotifier() { |
63 listeners = Collections.synchronizedMap( |
60 listeners = Collections.synchronizedMap( |