aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2012-03-05 10:16:27 -0800
committerHarvey Harrison <[email protected]>2012-03-05 10:16:27 -0800
commitbd7b118718284396c8bf6b0613a3843689410309 (patch)
tree29dd77c827331e41c7905761c897e502b52cf457 /src/classes/share
parent61786dc4398fcd9c6726b4f66eb2693b4cf95d49 (diff)
j3dcore: annotate the PhysicalEnvironment::devices list
Ensure this list is consistantly synchronized which will make it easier to use ArrayList if desired in a future patch. Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/javax/media/j3d/InputDeviceScheduler.java18
-rw-r--r--src/classes/share/javax/media/j3d/PhysicalEnvironment.java94
2 files changed, 52 insertions, 60 deletions
diff --git a/src/classes/share/javax/media/j3d/InputDeviceScheduler.java b/src/classes/share/javax/media/j3d/InputDeviceScheduler.java
index 806eca1..7706a7a 100644
--- a/src/classes/share/javax/media/j3d/InputDeviceScheduler.java
+++ b/src/classes/share/javax/media/j3d/InputDeviceScheduler.java
@@ -32,7 +32,6 @@
package javax.media.j3d;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.Vector;
/**
@@ -56,9 +55,6 @@ class InputDeviceScheduler extends J3dThread {
// This is used by MasterControl to keep track activeViewRef
PhysicalEnvironment physicalEnv;
- // store all inputDevices
- Vector devices = new Vector(1);
-
J3dThreadData threadData = new J3dThreadData();
boolean active = false;
@@ -89,15 +85,12 @@ class InputDeviceScheduler extends J3dThread {
this.physicalEnv = physicalEnv;
synchronized (physicalEnv.devices) {
- Enumeration elm = physicalEnv.devices.elements();
- while (elm.hasMoreElements()) {
- addInputDevice((InputDevice) elm.nextElement());
- }
- physicalEnv.inputsched = this;
+ for (InputDevice each : physicalEnv.devices) {
+ addInputDevice(each);
+ }
+ physicalEnv.inputsched = this;
}
-
- }
-
+}
void addInputDevice(InputDevice device) {
@@ -219,7 +212,6 @@ class InputDeviceScheduler extends J3dThread {
threads.clear();
blockingDevices.clear();
nonBlockingDevices.clear();
- devices.clear();
}
}
diff --git a/src/classes/share/javax/media/j3d/PhysicalEnvironment.java b/src/classes/share/javax/media/j3d/PhysicalEnvironment.java
index d0c68c1..eea58ff 100644
--- a/src/classes/share/javax/media/j3d/PhysicalEnvironment.java
+++ b/src/classes/share/javax/media/j3d/PhysicalEnvironment.java
@@ -132,8 +132,8 @@ ArrayList<View> users = new ArrayList<View>();
// Scheduler for input devices
InputDeviceScheduler inputsched;
- // store all inputDevices
- Vector devices = new Vector(1);
+// store all inputDevices
+Vector<InputDevice> devices = new Vector<InputDevice>(1);
// Number of active view users
int activeViewRef = 0;
@@ -235,54 +235,54 @@ synchronized void notifyUsers() {
return audioDevice;
}
- /**
- * Create an enumerator that produces all input devices.
- * @return an enumerator of all available devices
- */
- public Enumeration getAllInputDevices() {
+/**
+ * Create an enumerator that produces all input devices.
+ * @return an enumerator of all available devices
+ */
+public Enumeration<InputDevice> getAllInputDevices() {
return devices.elements();
- }
+}
- /**
- * Add an input device to the list of input devices. User is
- * responsible for initializing the device and setting the
- * processing mode (streaming or polling).
- * @param device the device to be added to the list of input devices
- * @exception IllegalArgumentException if InputDevice.getProcessingMode()
- * does not return one of BLOCKING, NON_BLOCKING, or DEMAND_DRIVEN.
- */
- public void addInputDevice(InputDevice device) {
-
- int driver_type = device.getProcessingMode();
-
- if ((driver_type == InputDevice.BLOCKING) ||
- (driver_type == InputDevice.NON_BLOCKING) ||
- (driver_type == InputDevice.DEMAND_DRIVEN)) {
- synchronized (devices) {
- devices.add(device);
- if (inputsched != null) {
- inputsched.addInputDevice(device);
- }
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("PhysicalEnvironment0"));
- }
- }
+/**
+ * Add an input device to the list of input devices. User is
+ * responsible for initializing the device and setting the
+ * processing mode (streaming or polling).
+ * @param device the device to be added to the list of input devices
+ * @exception IllegalArgumentException if InputDevice.getProcessingMode()
+ * does not return one of BLOCKING, NON_BLOCKING, or DEMAND_DRIVEN.
+ */
+public void addInputDevice(InputDevice device) {
+
+ int driver_type = device.getProcessingMode();
+
+ if ((driver_type == InputDevice.BLOCKING) ||
+ (driver_type == InputDevice.NON_BLOCKING) ||
+ (driver_type == InputDevice.DEMAND_DRIVEN)) {
+ synchronized (devices) {
+ devices.add(device);
+ if (inputsched != null) {
+ inputsched.addInputDevice(device);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException(J3dI18N.getString("PhysicalEnvironment0"));
+ }
+}
- /**
- * Remove an input device from the list of input devices.
- * User is responsible for closing out the device and releasing
- * the device resources.
- * @param device the device to be removed
- */
- public void removeInputDevice(InputDevice device) {
- devices.remove(device);
- synchronized (devices) {
- if (inputsched != null) {
- inputsched.removeInputDevice(device);
- }
- }
- }
+/**
+ * Remove an input device from the list of input devices.
+ * User is responsible for closing out the device and releasing
+ * the device resources.
+ * @param device the device to be removed
+ */
+public void removeInputDevice(InputDevice device) {
+ synchronized (devices) {
+ devices.remove(device);
+ if (inputsched != null) {
+ inputsched.removeInputDevice(device);
+ }
+ }
+}
/**
* Sets the index of the head to the specified sensor index.