@Test public void testKeysReleased2() throws Exception { ks1 = new KeyboardState(EnumSet.of(Key.A, Key.B), KeyEvent.NOTHING); ks2 = new KeyboardState(EnumSet.noneOf(Key.class), KeyEvent.NOTHING); final EnumSet<Key> released = ks2.getKeysReleasedSince(ks1); assertEquals("2 key", 2, released.size()); assertTrue("a released", released.contains(Key.A)); assertTrue("b released", released.contains(Key.B)); }
public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; }
KeyboardState { public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; } }
KeyboardState { public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; } KeyboardState(final EnumSet<Key> keysDown, final KeyEvent keyEvent); }
KeyboardState { public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; } KeyboardState(final EnumSet<Key> keysDown, final KeyEvent keyEvent); boolean isDown(final Key key); boolean isAllDown(final Key... keys); boolean isAtLeastOneDown(final Key... keys); Set<Key> getKeysDown(); KeyEvent getKeyEvent(); EnumSet<Key> getKeysReleasedSince(final KeyboardState previous); EnumSet<Key> getKeysPressedSince(final KeyboardState previous); EnumSet<Key> getKeysHeldSince(final KeyboardState previous); @Override String toString(); }
KeyboardState { public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; } KeyboardState(final EnumSet<Key> keysDown, final KeyEvent keyEvent); boolean isDown(final Key key); boolean isAllDown(final Key... keys); boolean isAtLeastOneDown(final Key... keys); Set<Key> getKeysDown(); KeyEvent getKeyEvent(); EnumSet<Key> getKeysReleasedSince(final KeyboardState previous); EnumSet<Key> getKeysPressedSince(final KeyboardState previous); EnumSet<Key> getKeysHeldSince(final KeyboardState previous); @Override String toString(); static final KeyboardState NOTHING; }