diff options
Diffstat (limited to 'ardor3d-awt/src/main')
-rw-r--r-- | ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java | 23 | ||||
-rw-r--r-- | ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java | 24 |
2 files changed, 6 insertions, 41 deletions
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java index c9247d4..fc291dc 100644 --- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java +++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java @@ -15,7 +15,6 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyListener; import java.util.EnumSet; -import java.util.LinkedList; import java.util.Objects; import com.ardor3d.annotation.GuardedBy; @@ -23,18 +22,15 @@ import com.ardor3d.input.Key; import com.ardor3d.input.KeyEvent; import com.ardor3d.input.KeyState; import com.ardor3d.input.KeyboardWrapper; -import com.google.common.collect.AbstractIterator; -import com.google.common.collect.PeekingIterator; +import com.ardor3d.util.PeekingIterator; /** * Keyboard wrapper class for use with AWT. */ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener { - @GuardedBy("this") - protected final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<>(); @GuardedBy("this") - protected AwtKeyboardIterator _currentIterator = null; + protected KeyboardIterator _currentIterator = null; protected final Component _component; @@ -63,7 +59,7 @@ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener { @Override public synchronized PeekingIterator<KeyEvent> getEvents() { if (_currentIterator == null || !_currentIterator.hasNext()) { - _currentIterator = new AwtKeyboardIterator(); + _currentIterator = new KeyboardIterator(this); } return _currentIterator; @@ -110,19 +106,6 @@ public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener { return AwtKey.findByCode(e.getKeyCode()); } - private class AwtKeyboardIterator extends AbstractIterator<KeyEvent> implements PeekingIterator<KeyEvent> { - @Override - protected KeyEvent computeNext() { - synchronized (AwtKeyboardWrapper.this) { - if (_upcomingEvents.isEmpty()) { - return endOfData(); - } - - return _upcomingEvents.poll(); - } - } - } - public boolean isConsumeEvents() { return _consumeEvents; } diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java index 6d6949a..667a932 100644 --- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java +++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java @@ -19,7 +19,6 @@ import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.util.EnumMap; import java.util.EnumSet; -import java.util.LinkedList; import java.util.Objects; import com.ardor3d.annotation.GuardedBy; @@ -29,20 +28,17 @@ import com.ardor3d.input.MouseButton; import com.ardor3d.input.MouseManager; import com.ardor3d.input.MouseState; import com.ardor3d.input.MouseWrapper; -import com.google.common.collect.AbstractIterator; +import com.ardor3d.util.PeekingIterator; import com.google.common.collect.EnumMultiset; import com.google.common.collect.Multiset; -import com.google.common.collect.PeekingIterator; /** * Mouse wrapper class for use with AWT. */ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelListener, MouseMotionListener { - @GuardedBy("this") - protected final LinkedList<MouseState> _upcomingEvents = new LinkedList<>(); @GuardedBy("this") - protected AwtMouseIterator _currentIterator = null; + protected MouseIterator _currentIterator = null; @GuardedBy("this") protected MouseState _lastState = null; @@ -85,7 +81,7 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL expireClickEvents(); if (_currentIterator == null || !_currentIterator.hasNext()) { - _currentIterator = new AwtMouseIterator(); + _currentIterator = new MouseIterator(this); } return _currentIterator; @@ -301,20 +297,6 @@ public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelL return button; } - private class AwtMouseIterator extends AbstractIterator<MouseState> implements PeekingIterator<MouseState> { - @Override - protected MouseState computeNext() { - synchronized (AwtMouseWrapper.this) { - if (_upcomingEvents.isEmpty()) { - return endOfData(); - } - - return _upcomingEvents.poll(); - } - - } - } - // -- The following interface methods are not used. -- @Override |