diff options
-rw-r--r-- | src/classes/share/javax/media/j3d/Screen3D.java | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/classes/share/javax/media/j3d/Screen3D.java b/src/classes/share/javax/media/j3d/Screen3D.java index 7d02fcf..fe15eb3 100644 --- a/src/classes/share/javax/media/j3d/Screen3D.java +++ b/src/classes/share/javax/media/j3d/Screen3D.java @@ -180,8 +180,8 @@ public class Screen3D extends Object { // A count of the number of active View associated with this screen UnorderList activeViews = new UnorderList(1, View.class); - // A list of Canvas3D Objects that refer to this - ArrayList users = new ArrayList(); + // A list of Canvas3D Objects that refer to this + private final ArrayList<Canvas3D> users = new ArrayList<Canvas3D>(); void addActiveView(View v) { activeViews.addUnique(v); @@ -195,32 +195,23 @@ public class Screen3D extends Object { return activeViews.isEmpty(); } - // Add a user to the list of users - synchronized void removeUser(Canvas3D c) { - int idx = users.indexOf(c); - if (idx >= 0) { - users.remove(idx); - } - } - - // Add a user to the list of users - synchronized void addUser(Canvas3D c) { - int idx = users.indexOf(c); - if (idx < 0) { - users.add(c); - } - } +// Add a user to the list of users +synchronized void removeUser(Canvas3D c) { + users.remove(c); +} - // Add a user to the list of users - synchronized void notifyUsers() { - int i; - Canvas3D c; +// Add a user to the list of users +synchronized void addUser(Canvas3D c) { + if (!users.contains(c)) + users.add(c); +} - for (i=0; i<users.size(); i++) { - c = (Canvas3D)users.get(i); - c.redraw(); +// Add a user to the list of users +synchronized void notifyUsers() { + for (int i = 0; i < users.size(); i++) { + users.get(i).redraw(); } - } +} /** * Retrieves the width and height (in pixels) of this Screen3D. |