List of usage examples for com.google.gwt.event.dom.client MouseEvent getY
public int getY()
From source file:com.ait.lienzo.client.core.shape.wires.EventMockUtils.java
License:Open Source License
private static void setUpMouseEvent(final MouseEvent<?> mouseEvent, final double x, final double y) { final int _x = (int) x; final int _y = (int) y; when(mouseEvent.getX()).thenReturn(_x); when(mouseEvent.getClientX()).thenReturn(_x); when(mouseEvent.getRelativeX(any(Element.class))).thenReturn(_x); when(mouseEvent.getRelativeY(any(Element.class))).thenReturn(_y); when(mouseEvent.getY()).thenReturn(_y); when(mouseEvent.getClientY()).thenReturn(_y); when(mouseEvent.isAltKeyDown()).thenReturn(false); when(mouseEvent.isControlKeyDown()).thenReturn(false); when(mouseEvent.isMetaKeyDown()).thenReturn(false); when(mouseEvent.isShiftKeyDown()).thenReturn(false); }
From source file:com.lushprojects.circuitjs1.client.CirSim.java
License:Open Source License
public void mouseSelect(MouseEvent<?> e) { // The following is in the original, but seems not to work/be needed for GWT // if (e.getNativeButton()==NativeEvent.BUTTON_LEFT) // return; CircuitElm newMouseElm = null;// w w w . ja v a 2 s . c o m mouseCursorX = e.getX(); mouseCursorY = e.getY(); int sx = e.getX(); int sy = e.getY(); int gx = inverseTransformX(sx); int gy = inverseTransformY(sy); // console("Settingd draggridx in mouseEvent"); dragGridX = snapGrid(gx); dragGridY = snapGrid(gy); dragScreenX = sx; dragScreenY = sy; draggingPost = -1; int i; // CircuitElm origMouse = mouseElm; mousePost = -1; plotXElm = plotYElm = null; if (mouseIsOverSplitter(sx, sy)) { setMouseElm(null); return; } if (mouseElm != null && (mouseElm.getHandleGrabbedClose(gx, gy, POSTGRABSQ, MINPOSTGRABSIZE) >= 0)) { newMouseElm = mouseElm; } else { int bestDist = 100000000; int bestArea = 100000000; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.boundingBox.contains(gx, gy)) { int j; int area = ce.boundingBox.width * ce.boundingBox.height; int jn = ce.getPostCount(); if (jn > 2) jn = 2; for (j = 0; j != jn; j++) { Point pt = ce.getPost(j); int dist = Graphics.distanceSq(gx, gy, pt.x, pt.y); // if multiple elements have overlapping bounding boxes, // we prefer selecting elements that have posts close // to the mouse pointer and that have a small bounding // box area. if (dist <= bestDist && area <= bestArea) { bestDist = dist; bestArea = area; newMouseElm = ce; } } if (ce.getPostCount() == 0) newMouseElm = ce; } } // for } scopeSelected = -1; if (newMouseElm == null) { for (i = 0; i != scopeCount; i++) { Scope s = scopes[i]; if (s.rect.contains(sx, sy)) { newMouseElm = s.getElm(); if (s.plotXY) { plotXElm = s.getXElm(); plotYElm = s.getYElm(); } scopeSelected = i; } } // // the mouse pointer was not in any of the bounding boxes, but we // // might still be close to a post for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (mouseMode == MODE_DRAG_POST) { if (ce.getHandleGrabbedClose(gx, gy, POSTGRABSQ, 0) > 0) { newMouseElm = ce; break; } } int j; int jn = ce.getPostCount(); for (j = 0; j != jn; j++) { Point pt = ce.getPost(j); // int dist = Graphics.distanceSq(x, y, pt.x, pt.y); if (Graphics.distanceSq(pt.x, pt.y, gx, gy) < 26) { newMouseElm = ce; mousePost = j; break; } } } } else { mousePost = -1; // look for post close to the mouse pointer for (i = 0; i != newMouseElm.getPostCount(); i++) { Point pt = newMouseElm.getPost(i); if (Graphics.distanceSq(pt.x, pt.y, gx, gy) < 26) mousePost = i; } } // if (mouseElm != origMouse) // cv.repaint(); setMouseElm(newMouseElm); }
From source file:com.ponysdk.core.terminal.ui.PTWidget.java
License:Apache License
protected void triggerMouseEvent(final DomHandlerType domHandlerType, final MouseEvent<?> event) { final PTInstruction eventInstruction = buildEventInstruction(domHandlerType); final JSONArray eventInfo = new JSONArray(); eventInfo.set(0, new JSONNumber(event.getClientX())); eventInfo.set(1, new JSONNumber(event.getClientY())); eventInfo.set(2, new JSONNumber(event.getX())); eventInfo.set(3, new JSONNumber(event.getY())); eventInfo.set(4, new JSONNumber(event.getNativeButton())); eventInfo.set(5, JSONBoolean.getInstance(event.isControlKeyDown())); eventInfo.set(6, JSONBoolean.getInstance(event.isAltKeyDown())); eventInfo.set(7, JSONBoolean.getInstance(event.isShiftKeyDown())); eventInfo.set(8, JSONBoolean.getInstance(event.isMetaKeyDown())); eventInstruction.put(ClientToServerModel.EVENT_INFO, eventInfo); final JSONArray widgetInfo = new JSONArray(); widgetInfo.set(0, new JSONNumber(uiObject.getAbsoluteLeft())); widgetInfo.set(1, new JSONNumber(uiObject.getAbsoluteTop())); widgetInfo.set(2, new JSONNumber(uiObject.getOffsetHeight())); widgetInfo.set(3, new JSONNumber(uiObject.getOffsetWidth())); eventInstruction.put(ClientToServerModel.WIDGET_POSITION, widgetInfo); uiBuilder.sendDataToServer(uiObject, eventInstruction); preventOrStopEvent(event);//ww w . jav a 2 s . c o m }
From source file:com.preferanser.client.geom.Point.java
License:Open Source License
public static Point FromMouseEventRelative(MouseEvent event) { return new Point(event.getX(), event.getY()); }
From source file:edu.caltech.ipac.firefly.visualize.PVMouse.java
private ScreenPt makeScreenPt(MouseEvent ev) { // return new ScreenPt(_pv.getScrollX()+ev.getX(),_pv.getScrollY()+ev.getY()); // return new ScreenPt(_pv.getScrollX()+ev.getX(),_pv.getScrollY()+ev.getY()); int vpX = _pv.getPrimaryPlot().getViewPortX(); int vpY = _pv.getPrimaryPlot().getViewPortY(); return new ScreenPt(vpX + ev.getX(), vpY + ev.getY()); }
From source file:gwt.g2d.client.input.MouseManager.java
License:Apache License
/** * Notifies this MouseManager that a MouseEvent is being handled. * Stores the mouse position and prevent the default action from taking * place if isPreventDefault() is true.//from w w w . j a va 2 s .co m * * @param <H> * @param event */ private <H extends EventHandler> void handleMouseEvent(MouseEvent<H> event) { clientX = event.getClientX(); clientY = event.getClientY(); screenX = event.getScreenX(); screenY = event.getScreenY(); x = event.getX(); y = event.getY(); handleEvent(event); }
From source file:org.geomajas.gwt.client.util.GwtEventUtil.java
License:Open Source License
/** * Get the position of a mouse event.//from w w w . j a va2s . com * * @param event * The mouse event itself. * @return Returns a coordinate holding the event's X and Y ordinate, where the origin is the upper left corner of * the DOM element catching the event. If used in a * {@link org.geomajas.gwt.client.controller.GraphicsController}, these are screen coordinates. */ public static Coordinate getPosition(MouseEvent<?> event) { return new Coordinate(event.getX(), event.getY()); }
From source file:org.geomajas.gwt.client.util.GwtEventUtil.java
License:Open Source License
/** * Get the position of a mouse event.//from w w w . j av a2s . c o m * * @param event * The mouse event itself. * @param offsetX * An extra value to be added to the X axis. * @param offsetY * An extra value to be added to the Y axis. * @return Returns a coordinate holding the event's X and Y ordinate, where the origin is the upper left corner of * the DOM element catching the event. If used in a * {@link org.geomajas.gwt.client.controller.GraphicsController}, these are screen coordinates. */ public static Coordinate getPosition(MouseEvent<?> event, int offsetX, int offsetY) { return new Coordinate(event.getX() + offsetX, event.getY() + offsetY); }
From source file:org.geomajas.javascript.gwt2.impl.client.util.JsGwtUtilImpl.java
License:Open Source License
/** * Returns the {@link org.geomajas.geometry.Coordinate} of a * {@link com.google.gwt.event.dom.client.HumanInputEvent}. * @param mapPresenter//w ww . j a v a 2s . c om * @param event * @param renderSpace * @return */ @Override public Coordinate getLocation(JsMapPresenter mapPresenter, HumanInputEvent<?> event, JsRenderSpace renderSpace) { Element mapElement = ((JsMapPresenterImpl) mapPresenter).getMapAsWidget().asWidget().getElement(); Coordinate location = null; if (event instanceof MouseEvent) { MouseEvent<?> mEvent = (MouseEvent<?>) event; event.setRelativeElement(mapElement); location = new Coordinate(mEvent.getX(), mEvent.getY()); } else if (event instanceof TouchEvent) { TouchEvent<?> tEvent = (TouchEvent<?>) event; if (tEvent.getTouches().length() > 0) { location = new Coordinate(tEvent.getTouches().get(0).getRelativeX(mapElement), tEvent.getTouches().get(0).getRelativeY(mapElement)); } } if (location == null) { location = new Coordinate(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); } if (JsRenderSpace.WORLD.equals(renderSpace)) { return mapPresenter.getViewPort().getTransformationService().transform(location, JsRenderSpace.SCREEN, renderSpace); } return location; }
From source file:org.geomajas.plugin.jsapi.client.map.controller.MapController.java
License:Open Source License
public Coordinate getLocation(HumanInputEvent<?> event, String renderSpace) { Element el = DOM.getElementById(map.getHtmlElementId()).getFirstChildElement(); Coordinate location = null;// ww w .j av a 2s . c o m if (event instanceof MouseEvent) { MouseEvent<?> mEvent = (MouseEvent<?>) event; event.setRelativeElement(el); location = new Coordinate(mEvent.getX(), mEvent.getY()); } else if (event instanceof TouchEvent) { TouchEvent<?> tEvent = (TouchEvent<?>) event; if (tEvent.getTouches().length() > 0) { location = new Coordinate(tEvent.getTouches().get(0).getRelativeX(el), tEvent.getTouches().get(0).getRelativeY(el)); } } if (location == null) { location = new Coordinate(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); } if ("world".equalsIgnoreCase(renderSpace)) { return map.getViewPort().transform(location, "screen", renderSpace); } return location; }