diff --git a/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java b/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java index 337d232..5f3f345 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java @@ -89,7 +89,7 @@ * Set the node that should receive key events. */ public void setKeyboardFocus(PInputEventListener eventHandler) { - PInputEvent focusEvent = new PInputEvent(this, null, null); + PInputEvent focusEvent = new PInputEvent(this, null); if (keyboardFocus != null) { dispatchEventToListener(focusEvent, FocusEvent.FOCUS_LOST, keyboardFocus); @@ -228,7 +228,7 @@ if (nextInput == null) return; - PInputEvent e = new PInputEvent(this, nextInput, nextInputSource); + PInputEvent e = new PInputEvent(this, nextInput); Point2D newCurrentCanvasPosition = null; Point2D newLastCanvasPosition = null; diff --git a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java index 4b16e1e..bc3b75b 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java +++ b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java @@ -64,14 +64,12 @@ private InputEvent inputEvent; private PPickPath pickPath; private PInputManager inputManager; - private PCamera inputSource; private boolean handled; - public PInputEvent(PInputManager inputManager, InputEvent event, PCamera inputSource) { + public PInputEvent(PInputManager inputManager, InputEvent event) { super(); inputEvent = event; this.inputManager = inputManager; - this.inputSource = inputSource; } public void pushCursor(Cursor cursor) { @@ -102,7 +100,7 @@ * getTopCamera. */ public PCamera getCamera() { - return (getPath() == null) ? inputSource : getPath().getBottomCamera(); + return getPath().getBottomCamera(); } /** @@ -110,7 +108,7 @@ * with the PCanvas that requested the current repaint. */ public PCamera getTopCamera() { - return (getPath() == null) ? inputSource : getPath().getTopCamera(); + return getPath().getTopCamera(); } /** diff --git a/core/src/test/java/edu/umd/cs/piccolo/PInputManagerTest.java b/core/src/test/java/edu/umd/cs/piccolo/PInputManagerTest.java index 8351dfe..dabd832 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/PInputManagerTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/PInputManagerTest.java @@ -78,14 +78,14 @@ public void testKeyPressedDispatchesToCurrentFocus() { manager.setKeyboardFocus(mockListener); - PInputEvent event = new PInputEvent(manager, null, null); + PInputEvent event = new PInputEvent(manager, null); manager.keyPressed(event); assertEquals(2, mockListener.getNotificationCount()); assertEquals(KeyEvent.KEY_PRESSED, mockListener.getNotification(1).type); } public void testKeyReleasedDispatchesToCurrentFocus() { manager.setKeyboardFocus(mockListener); - PInputEvent event = new PInputEvent(manager, null, null); + PInputEvent event = new PInputEvent(manager, null); manager.keyReleased(event); assertEquals(2, mockListener.getNotificationCount()); assertEquals(KeyEvent.KEY_RELEASED, mockListener.getNotification(1).type); @@ -93,7 +93,7 @@ public void testKeyTypedDispatchesToCurrentFocus() { manager.setKeyboardFocus(mockListener); - PInputEvent event = new PInputEvent(manager, null, null); + PInputEvent event = new PInputEvent(manager, null); manager.keyTyped(event); assertEquals(2, mockListener.getNotificationCount()); assertEquals(KeyEvent.KEY_TYPED, mockListener.getNotification(1).type); diff --git a/core/src/test/java/edu/umd/cs/piccolo/event/PBasicInputEventListenerTest.java b/core/src/test/java/edu/umd/cs/piccolo/event/PBasicInputEventListenerTest.java index 229474a..a6a56ad 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/event/PBasicInputEventListenerTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/event/PBasicInputEventListenerTest.java @@ -53,7 +53,7 @@ private PInputEvent buildInputEvent() { PCanvas canvas = new PCanvas(); MouseEvent mouseEvent = new MouseEvent(canvas, 1, System.currentTimeMillis(), 0, 0, 0, 1, false); - PInputEvent event = new PInputEvent(canvas.getRoot().getDefaultInputManager(), mouseEvent, canvas.getCamera()); + PInputEvent event = new PInputEvent(canvas.getRoot().getDefaultInputManager(), mouseEvent); return event; } diff --git a/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventFilterTest.java b/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventFilterTest.java index 2d37142..e894be1 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventFilterTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventFilterTest.java @@ -7,7 +7,6 @@ import javax.swing.JPanel; import junit.framework.TestCase; -import edu.umd.cs.piccolo.PCamera; import edu.umd.cs.piccolo.PInputManager; public class PInputEventFilterTest extends TestCase { @@ -216,9 +215,8 @@ private PInputEvent buildTestEvent(int modifiers, int clickCount) { JComponent component = new JPanel(); PInputManager inputManager = new PInputManager(); - PCamera camera = new PCamera(); MouseEvent event = new MouseEvent(component, 1, System.currentTimeMillis(), modifiers, 1, 1, clickCount, false); - return new PInputEvent(inputManager, event, camera); + return new PInputEvent(inputManager, event); } } diff --git a/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventTest.java b/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventTest.java index b2cf477..f6a4fd9 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/event/PInputEventTest.java @@ -5,7 +5,10 @@ import java.awt.event.MouseEvent; import junit.framework.TestCase; +import edu.umd.cs.piccolo.PCamera; import edu.umd.cs.piccolo.PCanvas; +import edu.umd.cs.piccolo.util.PBounds; +import edu.umd.cs.piccolo.util.PPickPath; public class PInputEventTest extends TestCase { private PCanvas canvas; @@ -17,12 +20,10 @@ canvas.setPreferredSize(new Dimension(100, 100)); canvas.setBounds(0, 0, 100, 100); swingEvent = buildSwingClick(5, 5); - - mouseEvent = new PInputEvent(canvas.getRoot().getDefaultInputManager(), swingEvent, canvas.getCamera()); - } - - public void testGetCameraUsesInputSourceIfPathIsNull() { - assertEquals(canvas.getCamera(), mouseEvent.getCamera()); + PCamera camera = canvas.getCamera(); + PPickPath pickPath = new PPickPath(camera, new PBounds(0, 0, 10, 10)); + mouseEvent = new PInputEvent(canvas.getRoot().getDefaultInputManager(), swingEvent); + mouseEvent.setPath(pickPath); } public void testInputManagerShouldBeSameAsGivenToConstructor() {