@Test public void testGetMouseMoveHandler() { final int initialX = 100; final int initialY = 100; final int expectedX = 175; final int expectedY = 175; final MouseMoveHandler handler = abstractDragProxy.getMouseMoveHandler(initialX, initialY, timeout, callback); when(mouseMoveEvent.getX()).thenReturn(150); when(mouseMoveEvent.getY()).thenReturn(150); doReturn(0).when(abstractDragProxy).xDiff(); doReturn(0).when(abstractDragProxy).yDiff(); doReturn(25).when(abstractDragProxy).getXDiff(); doReturn(25).when(abstractDragProxy).getYDiff(); doReturn(true).when(abstractDragProxy).isAttached(); handler.onMouseMove(mouseMoveEvent); verify(abstractDragProxy).setLocation(shapeProxy, expectedX, expectedY); verify(abstractDragProxy).scheduleMove(callback, expectedX, expectedY, timeout); verify(layer, never()).batch(); }
MouseMoveHandler getMouseMoveHandler(final int initialX, final int initialY, final int timeout, final Callback callback) { return mouseMoveEvent -> { if (isAttached()) { if (xDiff() == null) { xDiff = initialX - mouseMoveEvent.getX(); } if (yDiff() == null) { yDiff = initialY - mouseMoveEvent.getY(); } final int x = relativeX(getXDiff() + mouseMoveEvent.getX()); final int y = relativeY(getYDiff() + mouseMoveEvent.getY()); setLocation(shapeProxy, x, y); scheduleMove(callback, x, y, timeout); } }; }
AbstractDragProxy { MouseMoveHandler getMouseMoveHandler(final int initialX, final int initialY, final int timeout, final Callback callback) { return mouseMoveEvent -> { if (isAttached()) { if (xDiff() == null) { xDiff = initialX - mouseMoveEvent.getX(); } if (yDiff() == null) { yDiff = initialY - mouseMoveEvent.getY(); } final int x = relativeX(getXDiff() + mouseMoveEvent.getX()); final int y = relativeY(getYDiff() + mouseMoveEvent.getY()); setLocation(shapeProxy, x, y); scheduleMove(callback, x, y, timeout); } }; } }
AbstractDragProxy { MouseMoveHandler getMouseMoveHandler(final int initialX, final int initialY, final int timeout, final Callback callback) { return mouseMoveEvent -> { if (isAttached()) { if (xDiff() == null) { xDiff = initialX - mouseMoveEvent.getX(); } if (yDiff() == null) { yDiff = initialY - mouseMoveEvent.getY(); } final int x = relativeX(getXDiff() + mouseMoveEvent.getX()); final int y = relativeY(getYDiff() + mouseMoveEvent.getY()); setLocation(shapeProxy, x, y); scheduleMove(callback, x, y, timeout); } }; } AbstractDragProxy(final Layer layer,
                             final T shape,
                             final int x,
                             final int y,
                             final int timeout,
                             final Callback callback); }
AbstractDragProxy { MouseMoveHandler getMouseMoveHandler(final int initialX, final int initialY, final int timeout, final Callback callback) { return mouseMoveEvent -> { if (isAttached()) { if (xDiff() == null) { xDiff = initialX - mouseMoveEvent.getX(); } if (yDiff() == null) { yDiff = initialY - mouseMoveEvent.getY(); } final int x = relativeX(getXDiff() + mouseMoveEvent.getX()); final int y = relativeY(getYDiff() + mouseMoveEvent.getY()); setLocation(shapeProxy, x, y); scheduleMove(callback, x, y, timeout); } }; } AbstractDragProxy(final Layer layer,
                             final T shape,
                             final int x,
                             final int y,
                             final int timeout,
                             final Callback callback); void clear(); void destroy(); }
AbstractDragProxy { MouseMoveHandler getMouseMoveHandler(final int initialX, final int initialY, final int timeout, final Callback callback) { return mouseMoveEvent -> { if (isAttached()) { if (xDiff() == null) { xDiff = initialX - mouseMoveEvent.getX(); } if (yDiff() == null) { yDiff = initialY - mouseMoveEvent.getY(); } final int x = relativeX(getXDiff() + mouseMoveEvent.getX()); final int y = relativeY(getYDiff() + mouseMoveEvent.getY()); setLocation(shapeProxy, x, y); scheduleMove(callback, x, y, timeout); } }; } AbstractDragProxy(final Layer layer,
                             final T shape,
                             final int x,
                             final int y,
                             final int timeout,
                             final Callback callback); void clear(); void destroy();  }