@Override public void clear() { if (null != this.proxy) { this.proxy.clear(); } }
@Override public void destroy() { if (null != this.proxy) { this.proxy.destroy(); this.proxy = null; } this.layer = null; }
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); } }; }
void create(final int initialX, final int initialY, final int timeout, final Callback callback) { if (!attached) { addToLayer(layer, shapeProxy); setLocation(shapeProxy, relativeX(initialX), relativeY(initialY)); attached = true; callback.onStart(initialX, initialY); } handlerRegs[0] = RootPanel.get().addDomHandler(getMouseMoveHandler(initialX, initialY, timeout, callback), MouseMoveEvent.getType()); handlerRegs[1] = RootPanel.get().addDomHandler(mouseDownEvent -> { mouseDownEvent.stopPropagation(); mouseDownEvent.preventDefault(); }, MouseDownEvent.getType()); handlerRegs[2] = RootPanel.get().addDomHandler(getMouseUpHandler(callback), MouseUpEvent.getType()); }
public AbstractDragProxy(final Layer layer, final T shape, final int x, final int y, final int timeout, final Callback callback) { this.timer = makeTimer(); this.timer.schedule(timeout); this.xDiff = null; this.yDiff = null; this.layer = layer; this.shapeProxy = shape; create(x, y, timeout, callback); }
int relativeY(final int y) { final Double relativeY = ((y) - getViewportTransform().getTranslateY()) / getViewportTransform().getScaleY(); return relativeY.intValue(); }
int relativeX(final int x) { final Double relativeX = ((x) - getViewportTransform().getTranslateX()) / getViewportTransform().getScaleX(); return relativeX.intValue(); }
public void destroy() { clear(); this.timer = null; this.layer = null; this.shapeProxy = null; }
@Override public void destroy() { if (null != this.proxy) { this.proxy.destroy(); this.proxy = null; } this.layer = null; } }
@Override public void clear() { if (null != this.proxy) { this.proxy.clear(); this.layer.draw(); } }