protected int[] getCoordinates(GwtEvent<? extends EventHandler> event) {
   if (event instanceof TouchEvent) {
     return getPositionInTouch((TouchEvent<? extends EventHandler>) event);
   } else if (event instanceof MouseEvent) {
     MouseEvent<? extends EventHandler> me = (MouseEvent<? extends EventHandler>) event;
     return new int[] {me.getRelativeX(canvas.getElement()), me.getRelativeY(canvas.getElement())};
   }
   return null;
 }
示例#2
0
 private Point getMousePosition(MouseEvent event) {
   int x = event.getRelativeX(this.canvas.getElement());
   int y = event.getRelativeY(this.canvas.getElement());
   return new Point(x, y);
 }
 @Override
 public int getScaleTouchPosition(final MouseEvent<?> event) {
   return event.getRelativeX(this.getElement()) - startPosition - drag.getOffsetWidth() / 2;
 }