Example usage for com.google.gwt.event.dom.client MouseEvent getRelativeX

List of usage examples for com.google.gwt.event.dom.client MouseEvent getRelativeX

Introduction

In this page you can find the example usage for com.google.gwt.event.dom.client MouseEvent getRelativeX.

Prototype

public int getRelativeX(Element target) 

Source Link

Document

Gets the mouse x-position relative to a given element.

Usage

From source file:co.fxl.gui.canvas.gwt.GWTCanvas.java

License:Open Source License

private int x(MouseEvent<?> event) {
    return event.getRelativeX(container.widget.getElement());
}

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.moesol.gwt.maps.client.controls.MapPanZoomControl.java

License:Open Source License

@SuppressWarnings("rawtypes")
private void updateVelocity(MouseEvent e) {
    int eventRelativeX = e.getRelativeX(panButton.getElement());
    int eventRelativeY = e.getRelativeY(panButton.getElement());

    final int panButtonWidth = panButton.getOffsetWidth();
    final int panButtonHeight = panButton.getOffsetHeight();

    if (eventRelativeX > 0 && eventRelativeX < panButtonWidth && eventRelativeY > 0
            && eventRelativeY < panButtonHeight) {
        final Style clickHighlightStyle = clickHighlight.getStyle();
        clickHighlightStyle.setDisplay(Display.BLOCK);
        clickHighlightStyle.setLeft(eventRelativeX - (clickHighlight.getClientWidth() / 3), Unit.PX);
        clickHighlightStyle.setTop(eventRelativeY - (clickHighlight.getClientHeight() / 3), Unit.PX);

        m_dx = m_presenter.calculateDelta(panButtonWidth, eventRelativeX, m_maxPanPixels);
        m_dy = -m_presenter.calculateDelta(panButtonHeight, eventRelativeY, m_maxPanPixels);
    }/*  w  ww. ja  va 2s  .  co  m*/
}

From source file:com.moesol.gwt.maps.client.controls.MapPanZoomControlLegacy.java

License:Open Source License

@SuppressWarnings("rawtypes")
private void updateVelocity(MouseEvent e) {
    int eventRelativeX = e.getRelativeX(panButton.getElement());
    int eventRelativeY = e.getRelativeY(panButton.getElement());

    final int panButtonWidth = panButton.getOffsetWidth();
    final int panButtonHeight = panButton.getOffsetHeight();

    if (eventRelativeX > 0 && eventRelativeX < panButtonWidth && eventRelativeY > 0
            && eventRelativeY < panButtonHeight) {
        final Style clickHighlightStyle = clickHighlight.getElement().getStyle();
        clickHighlightStyle.setDisplay(Display.BLOCK);
        clickHighlightStyle.setLeft(eventRelativeX - (clickHighlight.getElement().getClientWidth() / 3),
                Unit.PX);/*w  ww. ja  v a2s  .co m*/
        clickHighlightStyle.setTop(eventRelativeY - (clickHighlight.getElement().getClientHeight() / 3),
                Unit.PX);

        m_dx = m_presenter.calculateDelta(panButtonWidth, eventRelativeX, m_maxPanPixels);
        m_dy = -m_presenter.calculateDelta(panButtonHeight, eventRelativeY, m_maxPanPixels);
    }
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setColour(MouseEvent event, Canvas targetCanvas, VerticalPanel targetPanel) {
    setColour(event.getRelativeX(targetCanvas.getElement()), event.getRelativeY(targetCanvas.getElement()),
            targetCanvas, targetPanel);/*ww w .  j av  a  2  s  .  c  om*/
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setHue(MouseEvent event, Canvas targetCanvas) {
    setHue(event.getRelativeX(targetCanvas.getElement()), event.getRelativeY(targetCanvas.getElement()),
            targetCanvas);/*from   w ww . j  av a  2 s .com*/
}

From source file:org.geomajas.gwt2.plugin.graphicsediting.example.client.annotation.AnnotationContainer.java

License:Open Source License

@Override
public Coordinate getScreenCoordinate(MouseEvent<?> event) {
    Element screenElement = mapPresenter.asWidget().getElement();
    return new Coordinate(event.getRelativeX(screenElement), event.getRelativeY(screenElement));
}