Commits

Michael Ludwig committed 4a793b4

Rollback auto-formatting by Eclipse and run a clean-up

Comments (0)

Files changed (234)

ferox-input/src/main/java/com/ferox/input/AWTEventAdapter.java

  */
 public class AWTEventAdapter implements java.awt.event.KeyListener, java.awt.event.MouseListener, MouseMotionListener, MouseWheelListener {
     private Component component;
-    
+
     private final MouseKeyEventDispatcher dispatcher;
-    
+
     /**
      * Create a new AWTEventAdapter that will convert AWT events and dispatch
      * them to the given MouseKeyEventDispatcher.
      * @param dispatcher The dispatcher to use
      */
     public AWTEventAdapter(MouseKeyEventDispatcher dispatcher) {
-        if (dispatcher == null)
+        if (dispatcher == null) {
             throw new NullPointerException("Dispatcher cannot be null");
-        
+        }
+
         this.dispatcher = dispatcher;
     }
-    
+
     /**
      * <p>
      * Attach the adapter to the given component. The adapter can only be
      *             another component
      */
     public void attach(Component component) {
-        if (component == null)
+        if (component == null) {
             throw new NullPointerException("Component cannot be null");
-        
+        }
+
         synchronized(this) {
-            if (this.component != null)
+            if (this.component != null) {
                 throw new IllegalStateException("AWTEventAdapter already attached to another Component");
-            
+            }
+
             component.addKeyListener(this);
             component.addMouseListener(this);
             component.addMouseMotionListener(this);
             component.addMouseWheelListener(this);
-            
+
             this.component = component;
         }
     }
-    
+
     /**
      * Detach this adapter from the component it's currently attached to. If the
      * adapter is not attached to a component, nothing happens. After detaching,
                 component.removeMouseListener(this);
                 component.removeMouseMotionListener(this);
                 component.removeMouseWheelListener(this);
-                
+
                 component = null;
             }
         }
     }
-    
+
     /* AWT event listener methods */
-    
+
     private KeyCode getKeyCode(java.awt.event.KeyEvent e) {
         switch(e.getKeyCode()) {
         case java.awt.event.KeyEvent.VK_ESCAPE: return KeyEvent.KeyCode.ESCAPE;
         case java.awt.event.KeyEvent.VK_EQUALS: return KeyEvent.KeyCode.EQUALS;
         case java.awt.event.KeyEvent.VK_BACK_SPACE: return KeyEvent.KeyCode.BACK_SPACE;
         case java.awt.event.KeyEvent.VK_DELETE: return KeyEvent.KeyCode.DELETE;
-        
+
         case java.awt.event.KeyEvent.VK_SPACE: return KeyEvent.KeyCode.SPACE;
-        
+
         case java.awt.event.KeyEvent.VK_PAUSE: return KeyEvent.KeyCode.PAUSE;
         case java.awt.event.KeyEvent.VK_INSERT: return KeyEvent.KeyCode.INSERT;
 
         case java.awt.event.KeyEvent.VK_LEFT: return KeyEvent.KeyCode.LEFT;
         case java.awt.event.KeyEvent.VK_RIGHT: return KeyEvent.KeyCode.RIGHT;
         case java.awt.event.KeyEvent.VK_DOWN: return KeyEvent.KeyCode.DOWN;
-        
+
         case java.awt.event.KeyEvent.VK_F1: return KeyEvent.KeyCode.F1;
         case java.awt.event.KeyEvent.VK_F2: return KeyEvent.KeyCode.F2;
         case java.awt.event.KeyEvent.VK_F3: return KeyEvent.KeyCode.F3;
         case java.awt.event.KeyEvent.VK_F10: return KeyEvent.KeyCode.F10;
         case java.awt.event.KeyEvent.VK_F11: return KeyEvent.KeyCode.F11;
         case java.awt.event.KeyEvent.VK_F12: return KeyEvent.KeyCode.F12;
-        
+
         case java.awt.event.KeyEvent.VK_1: return KeyEvent.KeyCode.N1;
         case java.awt.event.KeyEvent.VK_2: return KeyEvent.KeyCode.N2;
         case java.awt.event.KeyEvent.VK_3: return KeyEvent.KeyCode.N3;
         case java.awt.event.KeyEvent.VK_8: return KeyEvent.KeyCode.N8;
         case java.awt.event.KeyEvent.VK_9: return KeyEvent.KeyCode.N9;
         case java.awt.event.KeyEvent.VK_0: return KeyEvent.KeyCode.N0;
-        
+
         case java.awt.event.KeyEvent.VK_A: return KeyEvent.KeyCode.A;
         case java.awt.event.KeyEvent.VK_B: return KeyEvent.KeyCode.B;
         case java.awt.event.KeyEvent.VK_C: return KeyEvent.KeyCode.C;
         case java.awt.event.KeyEvent.VK_DECIMAL: return KeyEvent.KeyCode.NUMPAD_DECIMAL;
         case java.awt.event.KeyEvent.VK_DIVIDE: return KeyEvent.KeyCode.NUMPAD_DIVIDE;
         case java.awt.event.KeyEvent.VK_MULTIPLY: return KeyEvent.KeyCode.NUMPAD_MULTIPLY;
-        
+
         case java.awt.event.KeyEvent.VK_ALT:
-            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT)
+            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT) {
                 return KeyEvent.KeyCode.RIGHT_ALT;
-            else
+            } else {
                 return KeyEvent.KeyCode.LEFT_ALT;
-        case java.awt.event.KeyEvent.VK_CONTROL: 
-            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT)
+            }
+        case java.awt.event.KeyEvent.VK_CONTROL:
+            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT) {
                 return KeyEvent.KeyCode.RIGHT_CONTROL;
-            else
+            } else {
                 return KeyEvent.KeyCode.LEFT_CONTROL;
-        case java.awt.event.KeyEvent.VK_SHIFT: 
-            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT)
+            }
+        case java.awt.event.KeyEvent.VK_SHIFT:
+            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT) {
                 return KeyEvent.KeyCode.RIGHT_SHIFT;
-            else
+            } else {
                 return KeyEvent.KeyCode.LEFT_SHIFT;
-        case java.awt.event.KeyEvent.VK_META: 
-            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT)
+            }
+        case java.awt.event.KeyEvent.VK_META:
+            if (e.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_RIGHT) {
                 return KeyEvent.KeyCode.RIGHT_META;
-            else
+            } else {
                 return KeyEvent.KeyCode.LEFT_META;
-            
+            }
+
         default:
             return KeyEvent.KeyCode.UNKNOWN;
         }
     }
-    
+
     private char getCharacter(java.awt.event.KeyEvent e) {
-        if (e.getKeyChar() == java.awt.event.KeyEvent.CHAR_UNDEFINED)
+        if (e.getKeyChar() == java.awt.event.KeyEvent.CHAR_UNDEFINED) {
             return KeyEvent.CHAR_UNKNOWN;
-        else
+        } else {
             return e.getKeyChar();
+        }
     }
-    
+
     private MouseButton getButton(java.awt.event.MouseEvent e) {
         switch(e.getButton()) {
         case java.awt.event.MouseEvent.NOBUTTON:
             throw new IllegalArgumentException("Unknown AWT button code");
         }
     }
-    
+
     private int getY(java.awt.event.MouseEvent e) {
         return component.getHeight() - e.getY();
     }
 
     @Override
     public void keyPressed(java.awt.event.KeyEvent e) {
-        KeyEvent event = new KeyEvent(KeyEvent.Type.PRESS, dispatcher.getSource(), 
+        KeyEvent event = new KeyEvent(KeyEvent.Type.PRESS, dispatcher.getSource(),
                                       getKeyCode(e), getCharacter(e));
         dispatcher.dispatchEvent(event);
     }
 
     @Override
     public void mousePressed(java.awt.event.MouseEvent e) {
-        MouseEvent event = new MouseEvent(MouseEvent.Type.PRESS, dispatcher.getSource(), 
+        MouseEvent event = new MouseEvent(MouseEvent.Type.PRESS, dispatcher.getSource(),
                                           e.getX(), getY(e), 0, getButton(e));
         dispatcher.dispatchEvent(event);
     }
 
     @Override
     public void mouseReleased(java.awt.event.MouseEvent e) {
-        MouseEvent event = new MouseEvent(MouseEvent.Type.RELEASE, dispatcher.getSource(), 
+        MouseEvent event = new MouseEvent(MouseEvent.Type.RELEASE, dispatcher.getSource(),
                                           e.getX(), getY(e), 0, getButton(e));
         dispatcher.dispatchEvent(event);
     }
 
     @Override
     public void mouseMoved(java.awt.event.MouseEvent e) {
-        MouseEvent event = new MouseEvent(MouseEvent.Type.MOVE, dispatcher.getSource(), 
+        MouseEvent event = new MouseEvent(MouseEvent.Type.MOVE, dispatcher.getSource(),
                                           e.getX(), getY(e), 0, MouseButton.NONE);
         dispatcher.dispatchEvent(event);
     }
-    
+
     @Override
     public void mouseWheelMoved(MouseWheelEvent e) {
-        MouseEvent event = new MouseEvent(MouseEvent.Type.SCROLL, dispatcher.getSource(), 
+        MouseEvent event = new MouseEvent(MouseEvent.Type.SCROLL, dispatcher.getSource(),
                                           e.getX(), getY(e), e.getWheelRotation(), MouseButton.NONE);
         dispatcher.dispatchEvent(event);
     }

ferox-input/src/main/java/com/ferox/input/KeyEvent.java

      * modifiers that would not produce characters by themselves.
      */
     public static enum KeyCode {
-        UNKNOWN("Unknown"), 
-        
-        ESCAPE("Esc"), 
-        BACK_QUOTE("`"), 
-        TAB("Tab"), 
-        LEFT_BRACKET("["), 
+        UNKNOWN("Unknown"),
+
+        ESCAPE("Esc"),
+        BACK_QUOTE("`"),
+        TAB("Tab"),
+        LEFT_BRACKET("["),
         RIGHT_BRACKET("]"),
-        BACK_SLASH("\\"), 
-        FORWARD_SLASH("/"), 
-        RETURN("Return"), 
-        SEMICOLON(";"), 
-        QUOTE("'"), 
-        COMMA(","), 
-        PERIOD("."), 
-        MINUS("-"), 
-        EQUALS("="), 
+        BACK_SLASH("\\"),
+        FORWARD_SLASH("/"),
+        RETURN("Return"),
+        SEMICOLON(";"),
+        QUOTE("'"),
+        COMMA(","),
+        PERIOD("."),
+        MINUS("-"),
+        EQUALS("="),
         BACK_SPACE("Back Space"),
-        DELETE("Delete"), 
+        DELETE("Delete"),
         SPACE("Space"),
-        INSERT("Insert"), 
-        PAUSE("Pause"), 
-        HOME("Home"), 
-        END("End"), 
-        PAGE_UP("Page Up"), 
+        INSERT("Insert"),
+        PAUSE("Pause"),
+        HOME("Home"),
+        END("End"),
+        PAGE_UP("Page Up"),
         PAGE_DOWN("Page Down"),
-        
-        UP("Up"), LEFT("Left"), RIGHT("Right"), DOWN("Down"), 
-        
-        F1("F1"), F2("F2"), F3("F3"), F4("F4"), F5("F5"), F6("F6"), F7("F7"), F8("F8"), F9("F9"), F10("F10"), F11("F11"), F12("F12"), 
-        
-        N1("1"), N2("2"), N3("3"), N4("4"), N5("5"), N6("6"), N7("7"), N8("8"), N9("9"), N0("0"), 
-        
-        A("a"), B("b"), C("c"), D("d"), E("e"), F("f"), G("g"), H("h"), I("i"), J("j"), K("k"), L("l"), M("m"), 
-        N("n"), O("o"), P("p"), Q("q"), R("r"), S("s"), T("t"), U("u"), V("v"), W("w"), X("x"), Y("y"), Z("z"), 
-        
-        NUM_LOCK("Num Lock"), SCROLL_LOCK("Scroll Lock"), CAPS_LOCK("Caps Lock"), 
-        
-        NUMPAD_0("Numpad 0"), NUMPAD_1("Numpad 1"), NUMPAD_2("Numpad 2"), NUMPAD_3("Numpad 3"), NUMPAD_4("Numpad 4"), 
-        NUMPAD_5("Numpad 5"), NUMPAD_6("Numpad 6"), NUMPAD_7("Numpad 7"), NUMPAD_8("Numpad 8"), NUMPAD_9("Numpad 9"), 
-        NUMPAD_ADD("Numpad +"), NUMPAD_SUBTRACT("Numpad -"), NUMPAD_DECIMAL("Numpad ."), NUMPAD_DIVIDE("Numpad /"), NUMPAD_MULTIPLY("NUMPAD *"), 
-        
+
+        UP("Up"), LEFT("Left"), RIGHT("Right"), DOWN("Down"),
+
+        F1("F1"), F2("F2"), F3("F3"), F4("F4"), F5("F5"), F6("F6"), F7("F7"), F8("F8"), F9("F9"), F10("F10"), F11("F11"), F12("F12"),
+
+        N1("1"), N2("2"), N3("3"), N4("4"), N5("5"), N6("6"), N7("7"), N8("8"), N9("9"), N0("0"),
+
+        A("a"), B("b"), C("c"), D("d"), E("e"), F("f"), G("g"), H("h"), I("i"), J("j"), K("k"), L("l"), M("m"),
+        N("n"), O("o"), P("p"), Q("q"), R("r"), S("s"), T("t"), U("u"), V("v"), W("w"), X("x"), Y("y"), Z("z"),
+
+        NUM_LOCK("Num Lock"), SCROLL_LOCK("Scroll Lock"), CAPS_LOCK("Caps Lock"),
+
+        NUMPAD_0("Numpad 0"), NUMPAD_1("Numpad 1"), NUMPAD_2("Numpad 2"), NUMPAD_3("Numpad 3"), NUMPAD_4("Numpad 4"),
+        NUMPAD_5("Numpad 5"), NUMPAD_6("Numpad 6"), NUMPAD_7("Numpad 7"), NUMPAD_8("Numpad 8"), NUMPAD_9("Numpad 9"),
+        NUMPAD_ADD("Numpad +"), NUMPAD_SUBTRACT("Numpad -"), NUMPAD_DECIMAL("Numpad ."), NUMPAD_DIVIDE("Numpad /"), NUMPAD_MULTIPLY("NUMPAD *"),
+
         RIGHT_ALT("Right Alt"), LEFT_ALT("Left Alt"),
-        RIGHT_CONTROL("Right Control"), LEFT_CONTROL("Left Control"), 
+        RIGHT_CONTROL("Right Control"), LEFT_CONTROL("Left Control"),
         RIGHT_SHIFT("Right Shift"), LEFT_SHIFT("Left Shift"),
         RIGHT_META("Right Meta"), LEFT_META("Left Meta");
-        
+
         private final String descr;
         private KeyCode(String descr) { this.descr = descr; }
-        
+
         public String getDescription() { return descr; }
     }
-    
+
     private final KeyCode keyCode;
     private final char charValue;
     private final Type type;
     private final KeyEventSource source;
-    
+
     /**
      * Create a new KeyEvent with the given parameters.
      * 
      * @throws NullPointerException if type, source, or keyCode are null
      */
     public KeyEvent(Type type, KeyEventSource source, KeyCode keyCode, char charValue) {
-        if (source == null)
+        if (source == null) {
             throw new NullPointerException("Event source cannot be null");
-        if (type == null)
+        }
+        if (type == null) {
             throw new NullPointerException("Event type cannot be null");
-        if (keyCode == null)
+        }
+        if (keyCode == null) {
             throw new NullPointerException("KeyCode cannot be null");
-        
+        }
+
         this.source = source;
         this.type = type;
         this.keyCode = keyCode;
         this.charValue = charValue;
     }
-    
+
     /**
      * Get the character typed by this event. This will correctly have any
      * previously pressed modifier keys or language layouts applied to produce
     public char getCharacter() {
         return charValue;
     }
-    
+
     /**
      * @return The KeyCode representing the physical key that was pressed or
      *         released for this event
     public KeyCode getKeyCode() {
         return keyCode;
     }
-    
+
     /**
      * @return The type of key event
      */
     public Type getEventType() {
         return type;
     }
-    
+
     @Override
     public KeyEventSource getSource() {
         return source;
     }
-    
+
     @Override
     public String toString() {
         return "[Key " + type + " on " + keyCode.getDescription() + "]";

ferox-input/src/main/java/com/ferox/input/KeyEventSource.java

      * @throws NullPointerException if listener is null
      */
     public void addKeyListener(KeyListener listener);
-    
+
     /**
      * Remove the given KeyListener from this KeyEventSource. Nothing is
      * done if the given listener has never been added, or was already removed.

ferox-input/src/main/java/com/ferox/input/MouseEvent.java

          * yet. Use {@link MouseEvent#getButton()} to determine which button was
          * pressed.
          */
-        PRESS, 
+        PRESS,
         /**
          * One of the mouse's buttons was released that has previously been
          * pressed. Use {@link MouseEvent#getButton()} to determine which button
          */
         SCROLL
     }
-    
+
     /**
      * MouseButton is an enum representing all supported buttons in this event
      * framework. Some mice might not be capable of using the right or center
          */
         CENTER
     }
-    
+
     private final MouseEventSource source;
     private final Type type;
-    
+
     private final int x;
     private final int y;
     private final int scrollDelta;
-    
+
     private final MouseButton button;
-    
+
     /**
      * Create a new MouseEvent with the given arguments.
      * 
      *             incompatible
      */
     public MouseEvent(Type type, MouseEventSource source, int x, int y, int scrollDelta, MouseButton button) {
-        if (source == null)
+        if (source == null) {
             throw new NullPointerException("Event source cannot be null");
-        if (type == null)
+        }
+        if (type == null) {
             throw new NullPointerException("Type cannot be null");
-        if (button == null)
+        }
+        if (button == null) {
             throw new IllegalArgumentException("Mouse button cannot be null");
-        
+        }
+
         // verify state
         if (type == Type.PRESS || type == Type.RELEASE) {
-            if (button == MouseButton.NONE)
+            if (button == MouseButton.NONE) {
                 throw new IllegalArgumentException("Button cannot be NONE for a " + type + " event");
+            }
         } else {
-            if (button != MouseButton.NONE)
+            if (button != MouseButton.NONE) {
                 throw new IllegalArgumentException("Button must be NONE for a " + type + " event");
+            }
         }
         if (type == Type.SCROLL) {
-            if (scrollDelta == 0)
+            if (scrollDelta == 0) {
                 throw new IllegalArgumentException("Scroll delta must be non-zero for a " + type + " event");
+            }
         } else {
-            if (scrollDelta != 0)
+            if (scrollDelta != 0) {
                 throw new IllegalArgumentException("Scroll delta must be 0 for a " + type + " event");
+            }
         }
-        
+
         this.source = source;
         this.type = type;
         this.x = x;
         this.scrollDelta = scrollDelta;
         this.button = button;
     }
-    
+
     /**
      * @return The type of mouse event
      */
     public Type getEventType() {
         return type;
     }
-    
+
     /**
      * <p>
      * Get the x position of the mouse at the time of the event. Given that most
     public int getX() {
         return x;
     }
-    
+
     /**
      * <p>
      * Get the y position of the mouse at the time of the event. Given that most
     public int getY() {
         return y;
     }
-    
+
     /**
      * Get the amount of scroll increments the scroll wheel has been adjusted
      * by. This value is always 0 if the type is not SCROLL. When the event is a
     public int getScrollDelta() {
         return scrollDelta;
     }
-    
+
     /**
      * Get the mouse button that produced the event if the type is PRESS or
      * RELEASE. MOVE and SCROLL will always return NONE. PRESS and RELEASE will
     public MouseButton getButton() {
         return button;
     }
-    
+
     @Override
     public MouseEventSource getSource() {
         return source;
     }
-    
+
     @Override
     public String toString() {
         return "[Mouse " + type + " at (" + x + ", " + y + "), button: " + button + ", scroll: " + scrollDelta + "]";

ferox-input/src/main/java/com/ferox/input/MouseEventSource.java

      * @throws NullPointerException if listener is null
      */
     public void addMouseListener(MouseListener listener);
-    
+
     /**
      * Remove the given MouseListener from this MouseEventSource. Nothing is
      * done if the given listener has never been added, or was already removed.

ferox-input/src/main/java/com/ferox/input/MouseKeyEventDispatcher.java

     private final ExecutorService executor;
     private final CopyOnWriteArrayList<KeyListener> keyListeners;
     private final CopyOnWriteArrayList<MouseListener> mouseListeners;
-    
+
     private final MouseKeyEventSource source;
-    
+
     /**
      * Create a new MouseKeyEventDispatcher.
      * 
      *            dispatcher
      */
     public MouseKeyEventDispatcher(MouseKeyEventSource source) {
-        if (source == null)
+        if (source == null) {
             throw new NullPointerException("Source cannot be null");
+        }
         this.source = source;
         executor = Executors.newFixedThreadPool(1);
         keyListeners = new CopyOnWriteArrayList<KeyListener>();
         mouseListeners = new CopyOnWriteArrayList<MouseListener>();
     }
-    
+
     /**
      * @return The source of events that are dispatched by this dispatcher
      */
     public MouseKeyEventSource getSource() {
         return source;
     }
-    
+
     /**
      * Function compatible with
      * {@link KeyEventSource#addKeyListener(KeyListener)}.
      * @param listener The listener to register
      */
     public void addKeyListener(KeyListener listener) {
-        if (listener == null)
+        if (listener == null) {
             throw new NullPointerException("KeyListener cannot be null");
+        }
         keyListeners.addIfAbsent(listener);
     }
-    
+
     /**
      * Function compatible with
      * {@link KeyEventSource#removeKeyListener(KeyListener)}.
      * @param listener The listener to unregister
      */
     public void removeKeyListener(KeyListener listener) {
-        if (listener == null)
+        if (listener == null) {
             throw new NullPointerException("KeyListener cannot be null");
+        }
         keyListeners.remove(listener);
     }
 
      * @param listener The listener to register
      */
     public void addMouseListener(MouseListener listener) {
-        if (listener == null)
+        if (listener == null) {
             throw new NullPointerException("MouseListener cannot be null");
+        }
         mouseListeners.addIfAbsent(listener);
     }
 
      * @param listener The listener to unregister
      */
     public void removeMouseListener(MouseListener listener) {
-        if (listener == null)
+        if (listener == null) {
             throw new NullPointerException("MouseListener cannot be null");
+        }
         mouseListeners.remove(listener);
     }
-    
+
     /**
      * Dispatch the given event to all registered listeners that are interested
      * in the event. This will be invoked on an internal thread managed by this
      *             the dispatcher's
      */
     public void dispatchEvent(Event e) {
-        if (e.getSource() != source)
+        if (e.getSource() != source) {
             throw new IllegalArgumentException("Event's source does not match this dispatcher's source");
-        
+        }
+
         try {
-            if (e instanceof MouseEvent)
+            if (e instanceof MouseEvent) {
                 executor.submit(new MouseEventTask((MouseEvent) e));
-            else if (e instanceof KeyEvent)
+            } else if (e instanceof KeyEvent) {
                 executor.submit(new KeyEventTask((KeyEvent) e));
-            else
+            } else {
                 throw new UnsupportedOperationException("Unsupported type of event: " + e.getClass());
+            }
         } catch(RejectedExecutionException ree) {
             // ignore
         }
     public void shutdown() {
         executor.shutdownNow();
     }
-    
+
     private class KeyEventTask implements Runnable {
         private final KeyEvent e;
-        
+
         public KeyEventTask(KeyEvent e) {
             this.e = e;
         }
-        
+
         @Override
         public void run() {
             for (KeyListener l: keyListeners) {
             }
         }
     }
-    
+
     private class MouseEventTask implements Runnable {
         private final MouseEvent e;
-        
+
         public MouseEventTask(MouseEvent e) {
             this.e = e;
         }
-        
+
         @Override
         public void run() {
             for (MouseListener l: mouseListeners) {

ferox-input/src/main/java/com/ferox/input/logic/InputManager.java

     private InputState lastState;
     private InputState lastProcessedState;
     private final Queue<InputState> stateQueue;
-    
+
     private final InternalListener listener; // also acts as synchronization lock
     private final List<PredicatedAction> triggers;
-    
+
     private MouseKeyEventSource source;
-    
+
     /**
      * Create a new InputManager that is not attached to any
      * MouseKeyEventSource, and must be attached before it can process any
     public InputManager() {
         stateQueue = new ArrayDeque<InputState>();
         triggers = new ArrayList<PredicatedAction>();
-        
+
         listener = new InternalListener();
         lastState = new InputState();
         lastProcessedState = lastState;
     }
-    
+
     /**
      * <p>
      * Attach the InputManager to the given MouseKeyEventSource. The manager can
      *             another component
      */
     public void attach(MouseKeyEventSource source) {
-        if (source == null)
+        if (source == null) {
             throw new NullPointerException("Source cannot be null");
-        
+        }
+
         synchronized(this) {
-            if (this.source != null)
+            if (this.source != null) {
                 throw new IllegalStateException("InputManager already attached to another event source");
-            
+            }
+
             source.addKeyListener(listener);
             source.addMouseListener(listener);
-            
+
             this.source = source;
         }
     }
-    
+
     /**
      * Detach this InputManager from the event source it's currently attached
      * to. If the adapter is not attached to a component, nothing happens. After
             if (source != null) {
                 source.removeKeyListener(listener);
                 source.removeMouseListener(listener);
-                
+
                 source = null;
             }
         }
     }
-    
+
     /**
      * @return The event source this manager is attached to or null
      */
     public MouseKeyEventSource getEventSource() {
         return source;
     }
-    
+
     /**
      * <p>
      * Begin registering a new action with this InputManager that will be
     public ActionBuilder on(Predicate predicate) {
         return new ActionBuilderImpl(predicate);
     }
-    
+
     /**
      * Remove or unregister the given action from this manager. If the action
      * was registered with multiple predicates, all occurrences of it will be
      * @throws NullPointerException if trigger is null
      */
     public void removeAction(Action trigger) {
-        if (trigger == null)
+        if (trigger == null) {
             throw new NullPointerException("Action cannot be null");
-        
+        }
+
         synchronized(listener) {
             Iterator<PredicatedAction> it = triggers.iterator();
             while(it.hasNext()) {
             }
         }
     }
-    
+
     /**
      * Process all events that have been accumulated since the last call to
      * {@link #process()} and run all actions that are triggered based on their
 
     private void processTriggers(InputState prev, InputState next) {
         int ct = triggers.size();
-        for (int i = 0; i < ct; i++)
+        for (int i = 0; i < ct; i++) {
             triggers.get(i).apply(prev, next);
+        }
     }
-    
+
     // caller must be synchronized on event listener
     private void advanceState(InputState next) {
         lastState = next;
         stateQueue.add(next);
     }
-    
+
     /*
      * Internal class used to listen for events to prevent InputManager being
      * used as a listener directly. It is also the monitor used by each manager.
             }
         }
     }
-    
+
     /*
      * Internal ActionBuilder implementation
      */
     private class ActionBuilderImpl implements ActionBuilder {
         Predicate condition;
-        
+
         public ActionBuilderImpl(Predicate base) {
-            if (base == null)
+            if (base == null) {
                 throw new NullPointerException("Predicate cannot be null");
+            }
             condition = base;
         }
-        
+
         @Override
         public void trigger(Action action) {
-            if (action == null)
+            if (action == null) {
                 throw new NullPointerException("Action cannot be null");
-            
+            }
+
             synchronized(listener) {
                 triggers.add(new PredicatedAction(action, condition));
             }
         }
     }
-    
+
     /*
      * Simple pair between an action and its triggering predicate
      */
     private static class PredicatedAction {
         final Action trigger;
         final Predicate condition;
-        
+
         public PredicatedAction(Action trigger, Predicate condition) {
             this.trigger = trigger;
             this.condition = condition;
         }
-        
+
         public void apply(InputState prev, InputState next) {
-            if (condition.apply(prev, next))
+            if (condition.apply(prev, next)) {
                 trigger.perform(prev, next);
+            }
         }
     }
 }

ferox-input/src/main/java/com/ferox/input/logic/InputState.java

 public class InputState {
     private final KeyboardState keyboard;
     private final MouseState mouse;
-    
+
     private final long timestamp; // nanos
-    
+
     /**
      * Create a new InputState that has the empty or default keyboard and mouse
      * states. Its timestamp is set to the currently reporting system time.
     public InputState() {
         keyboard = new KeyboardState();
         mouse = new MouseState();
-        
+
         timestamp = System.currentTimeMillis();
     }
-    
+
     /**
      * Create a new InputState that clones the mouse and keyboard states from
      * the given InputState, but has an updated timestamp to the current system
     public InputState(InputState prev) {
         keyboard = prev.keyboard;
         mouse = prev.mouse;
-        
+
         timestamp = System.nanoTime();
     }
-    
+
     /**
      * Create a new InputState that computes the effective state of applying the
      * given key event to the previous keyboard state, and preserving the
             keyboard = new KeyboardState(null, event);
             mouse = new MouseState();
         }
-        
+
         timestamp = System.nanoTime();
     }
-    
+
     /**
      * Create a new InputState that computes the effective state of applying the
      * given mouse event to the previous mouse state, and preserving the
             keyboard = new KeyboardState();
             mouse = new MouseState(null, event);
         }
-        
+
         timestamp = System.nanoTime();
     }
-    
+
     /**
      * @return The time stamp in nanoseconds of the event that produced this
      *         input state
     public long getTimestamp() {
         return timestamp;
     }
-    
+
     /**
      * @return The state of the mouse device at the time this state was current
      */
     public MouseState getMouseState() {
         return mouse;
     }
-    
+
     /**
      * @return The state of the keyboard at the time this state was current
      */

ferox-input/src/main/java/com/ferox/input/logic/KeyTypedPredicate.java

 class KeyTypedPredicate implements Predicate {
     private final KeyCode code;
     private final long typeDuration;
-    
+
     private long startTime;
-    
+
     public KeyTypedPredicate(KeyCode code, long typeDuration) {
-        if (code == null)
+        if (code == null) {
             throw new NullPointerException("KeyCode cannot be null");
-        if (typeDuration <= 0)
+        }
+        if (typeDuration <= 0) {
             throw new IllegalArgumentException("Type duration must be a positive number of milliseconds, not: " + typeDuration);
-        
+        }
+
         this.code = code;
         this.typeDuration = typeDuration * 1000000; // convert from millis to nanoseconds
         startTime = -1;
     }
-    
+
     @Override
     public boolean apply(InputState prev, InputState next) {
         if (!prev.getKeyboardState().isKeyDown(code) && next.getKeyboardState().isKeyDown(code)) {
             // key is released, see if it was fast enough
             long start = startTime;
             startTime = -1;
-            
+
             // check for faulty data (i.e. we missed the 1st press somehow)
-            if (start < 0)
+            if (start < 0) {
                 return false;
-            
+            }
+
             return (next.getTimestamp() - start) <= typeDuration;
         } else {
             // extraneous event so ignore it

ferox-input/src/main/java/com/ferox/input/logic/KeyboardState.java

  */
 public class KeyboardState {
     private final EnumSet<KeyCode> keysDown;
-    
+
     /**
      * Create a new KeyboardState that has zero keys marked as down.
      */
     public KeyboardState() {
         keysDown = EnumSet.noneOf(KeyCode.class);
     }
-    
+
     /**
      * Create a new KeyboardState that will mark a key as down if the event is a
      * PRESS, or will mark it as up if the event is a RELEASE. Any other key
      * @throws NullPointerException if event is null
      */
     public KeyboardState(KeyboardState prev, KeyEvent event) {
-        if (prev != null)
+        if (prev != null) {
             keysDown = EnumSet.copyOf(prev.keysDown);
-        else
+        } else {
             keysDown = EnumSet.noneOf(KeyCode.class);
-        
-        if (event.getEventType() == Type.PRESS)
+        }
+
+        if (event.getEventType() == Type.PRESS) {
             keysDown.add(event.getKeyCode());
-        else
+        } else {
             keysDown.remove(event.getKeyCode());
+        }
     }
-    
+
     /**
      * Return whether or not the given key is down. The PRESS event that marked
      * the key as down could have happened any number of frames in the past, but

ferox-input/src/main/java/com/ferox/input/logic/MouseClickedPredicate.java

     private final MouseButton button;
     private final long clickDuration;
     private final int numClicks;
-    
+
     private long startTime;
     private int currentClickCount;
-    
+
     public MouseClickedPredicate(MouseButton button, int numClicks, long clickDuration) {
-        if (button == null)
+        if (button == null) {
             throw new NullPointerException("MouseButton cannot be null");
-        if (button == MouseButton.NONE)
+        }
+        if (button == MouseButton.NONE) {
             throw new IllegalArgumentException("NONE is not a valid button for mouse clicks");
-        if (numClicks <= 0)
+        }
+        if (numClicks <= 0) {
             throw new IllegalArgumentException("Number of clicks must be at least 1, not: " + numClicks);
-        if (clickDuration <= 0)
+        }
+        if (clickDuration <= 0) {
             throw new IllegalArgumentException("Click duration must be at least 1 ms, not: " + clickDuration);
-        
+        }
+
         this.button = button;
         this.numClicks = numClicks;
         this.clickDuration = clickDuration * 1000000; // convert from millis to nanos
-        
+
         startTime = -1;
         currentClickCount = 0;
     }
-    
+
     @Override
     public boolean apply(InputState prev, InputState next) {
         if (!prev.getMouseState().isButtonDown(button) && next.getMouseState().isButtonDown(button)) {
             // record time of first press
-            if (currentClickCount == 0)
+            if (currentClickCount == 0) {
                 startTime = next.getTimestamp();
-            
+            }
+
             // increase the number of 'clicks', which for our purposes is tracked on mouse down
             currentClickCount++;
             return false;
                 long start = startTime;
                 startTime = -1;
                 currentClickCount = 0;
-                
+
                 // check for faulty data (i.e. we missed the 1st press somehow)
-                if (start < 0)
+                if (start < 0) {
                     return false;
-                
+                }
+
                 return (next.getTimestamp() - start) <= clickDuration;
             } else {
                 // haven't reach click count yet, but if we've taken too long
                     startTime = -1;
                     currentClickCount = 0;
                 }
-                
+
                 return false;
             }
         } else {

ferox-input/src/main/java/com/ferox/input/logic/MouseState.java

 public class MouseState {
     private final int x;
     private final int y;
-    
+
     private final EnumSet<MouseButton> buttonsDown;
     private final int scrollCount;
-    
+
     /**
      * Create a new MouseState that starts at (0, 0) and has an initial scroll
      * value of 0.
     public MouseState() {
         x = 0;
         y = 0;
-        
+
         buttonsDown = EnumSet.noneOf(MouseButton.class);
         scrollCount = 0;
     }
-    
+
     /**
      * <p>
      * Create a new MouseState that will mark a button as down if the event is a
     public MouseState(MouseState prev, MouseEvent event) {
         x = event.getX();
         y = event.getY();
-        
-        if (prev != null)
+
+        if (prev != null) {
             buttonsDown = EnumSet.copyOf(prev.buttonsDown);
-        else
+        } else {
             buttonsDown = EnumSet.noneOf(MouseButton.class);
-        
-        if (event.getEventType() == Type.PRESS)
+        }
+
+        if (event.getEventType() == Type.PRESS) {
             buttonsDown.add(event.getButton());
-        else if (event.getEventType() == Type.RELEASE)
+        } else if (event.getEventType() == Type.RELEASE) {
             buttonsDown.remove(event.getButton());
-        
-        if (event.getEventType() == Type.SCROLL)
+        }
+
+        if (event.getEventType() == Type.SCROLL) {
             scrollCount = prev.scrollCount + event.getScrollDelta();
-        else
+        } else {
             scrollCount = prev.scrollCount;
+        }
     }
-    
+
     /**
      * <p>
      * Return whether or not the given mouse button is pressed as of this state.
      * @return True if the button is currently held down
      */
     public boolean isButtonDown(MouseButton button) {
-        if (button == MouseButton.NONE)
+        if (button == MouseButton.NONE) {
             return buttonsDown.isEmpty();
-        else
+        } else {
             return buttonsDown.contains(button);
+        }
     }
-    
+
     /**
      * @return The current x position of the mouse
      */
     public int getX() {
         return x;
     }
-    
+
     /**
      * @return The current y position of the mouse
      */
     public int getY() {
         return y;
     }
-    
+
     /**
      * <p>
      * Get the number of scroll ticks that have been performed as of this state.

ferox-input/src/main/java/com/ferox/input/logic/Predicates.java

  */
 public final class Predicates {
     private Predicates() { }
-    
+
     /**
      * Return a Predicate that evaluates to true when the key code transitions
      * from the up to down position.
      * @throws NullPointerException if code is null
      */
     public static Predicate keyPress(final KeyCode code) {
-        if (code == null)
+        if (code == null) {
             throw new NullPointerException("KeyCode cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the key code transitions
      * from the down to up position.
      * @throws NullPointerException if code is null
      */
     public static Predicate keyRelease(final KeyCode code) {
-        if (code == null)
+        if (code == null) {
             throw new NullPointerException("KeyCode cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the key code is held down
      * for the duration of the state transition. This will continue to evaluate
      * @throws NullPointerException if code is null
      */
     public static Predicate keyHeld(final KeyCode code) {
-        if (code == null)
+        if (code == null) {
             throw new NullPointerException("KeyCode cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
                 // we use prev as the signal so that we still trigger during
-                // the transition of a release (since it was held until the 
+                // the transition of a release (since it was held until the
                 // very end), but not the transition for a press (since it was
                 // not held until the very end).
                 return prev.getKeyboardState().isKeyDown(code);
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the key code is pressed
      * and released in under 250 milliseconds (i.e. typing that key). This will
     public static Predicate keyTyped(KeyCode code) {
         return keyTyped(code, 250L);
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the key code is pressed
      * and released in under <tt>delay</tt> milliseconds (i.e. typing that key).
     public static Predicate keyTyped(KeyCode code, long delay) {
         return new KeyTypedPredicate(code, delay);
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button
      * transitions from the up to down position. When the NONE button is used,
      * @throws NullPointerException if button is null
      */
     public static Predicate mousePress(final MouseButton button) {
-        if (button == null)
+        if (button == null) {
             throw new NullPointerException("MouseButton cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button transitions
      * from the down to up position. When the NONE button is used, it
      * @throws NullPointerException if button is null
      */
     public static Predicate mouseRelease(final MouseButton button) {
-        if (button == null)
+        if (button == null) {
             throw new NullPointerException("MouseButton cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button is held
      * down for the duration of the state transition. This will continue to
      * @throws NullPointerException if button is null
      */
     public static Predicate mouseHeld(final MouseButton button) {
-        if (button == null)
+        if (button == null) {
             throw new NullPointerException("MouseButton cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button is
      * pressed and released once in under 150 milliseconds (i.e. a single
     public static Predicate mouseClick(MouseButton button) {
         return mouseClick(button, 1);
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button is
      * pressed and released <tt>numClicks</tt> times in under 150 milliseconds
     public static Predicate mouseClick(MouseButton button, int numClicks) {
         return mouseClick(button, numClicks, 150L);
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button is
      * pressed and released <tt>numClicks</tt> times in under <tt>delay</tt>
     public static Predicate mouseClick(MouseButton button, int numClicks, long delay) {
         return new MouseClickedPredicate(button, numClicks, delay);
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse button is
      * pressed and released twice in under 150 milliseconds
     public static Predicate doubleClick(MouseButton button) {
         return mouseClick(button, 2);
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse's position
      * changes and no button is held down.
     public static Predicate mouseMove() {
         return mouseMove(false);
     }
-    
+
     /**
      * <p>
      * Return a Predicate that evaluates to true when the mouse's position
             return mouseDrag(MouseButton.NONE);
         }
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the mouse's position
      * changes and the specified mouse button is held down. If the NONE button
     public static Predicate mouseDrag(MouseButton button) {
         return and(mouseMove(true), mouseHeld(button));
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the amount of wheel
      * scrolling moves in the negative direction, which is synonymous with
             }
         };
     }
-    
+
     /**
      * Return a Predicate that evaluates to true when the amount of wheel
      * scrolling moves in the positive direction, which is synonymous with
             }
         };
     }
-    
+
     /**
      * Return a Predicate that returns true when the logical AND of the left and
      * right predicates returns true (i.e. when both left and right return
      * @throws NullPointerException if left or right are null
      */
     public static Predicate and(final Predicate left, final Predicate right) {
-        if (left == null || right == null)
+        if (left == null || right == null) {
             throw new NullPointerException("Predicate arguments to and() cannot be null");
+        }
         return new Predicate() {
             @Override
             public boolean apply(InputState prev, InputState next) {
             }
         };
     }
-    
+
     /**
      * Return a Predicate that returns true when the logical OR of the left and
      * right predicates returns true (i.e. when either left or right return
      * @throws NullPointerException if left or right are null
      */
     public static Predicate or(final Predicate left, final Predicate right) {
-        if (left == null || right == null)
+        if (left == null || right == null) {
             throw new NullPointerException("Predicate arguments to or() cannot be null");
+        }
         return new Predicate() {
             @Override