Example usage for com.google.gwt.dom.client NativeEvent getClientY

List of usage examples for com.google.gwt.dom.client NativeEvent getClientY

Introduction

In this page you can find the example usage for com.google.gwt.dom.client NativeEvent getClientY.

Prototype

public final int getClientY() 

Source Link

Document

Gets the mouse y-position within the browser window's client area.

Usage

From source file:annis.gui.widgets.gwt.client.ui.VGripDragComponent.java

License:Apache License

private boolean startDrag(NativeEvent event) {
    VTransferable transferable = new VTransferable();
    transferable.setDragSource(ConnectorMap.get(client).getConnector(this));

    Element targetElement = (Element) event.getEventTarget().cast();

    Paintable paintable;//www  .j ava 2s  . co  m
    Widget w = Util.findWidget(targetElement, null);

    if (!w.getStyleName().contains("drag-source-enabled")) {
        return false;
    }

    while (w != null && !(w instanceof Paintable)) {
        w = w.getParent();
    }
    paintable = (Paintable) w;

    transferable.setData("component", paintable);
    VDragEvent dragEvent = VDragAndDropManager.get().startDrag(transferable, event, true);

    transferable.setData("clientX", event.getClientX());
    transferable.setData("clientY", event.getClientY());

    dragEvent.createDragImage(getElement(), true);

    return true;

}

From source file:asquare.gwt.tests.clientcoords.client.Demo.java

License:Apache License

public void onModuleLoad() {
    RootPanel.get("outer").add(new Label("Event client position"));
    final TextArea output = new TextArea();
    RootPanel.get("outer").add(output);
    Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
        public void onPreviewNativeEvent(NativePreviewEvent event) {
            if (event.getTypeInt() == Event.ONMOUSEDOWN) {
                NativeEvent nativeEvent = event.getNativeEvent();
                output.setText("clientX=" + nativeEvent.getClientX() + ", clientY=" + nativeEvent.getClientY());
            }/*  w  w w . j  av a 2 s. c  o m*/
        }
    });
}

From source file:at.ait.dme.yuma.client.map.tagcloud.RaphaelTag.java

License:EUPL

public RaphaelTag(SemanticTag tag, int x, int y, int fontsize, String hiliteColor, String hAlign, String vAlign,
        Raphael paper, TagSelectionListener listener) {
    this.tag = tag;
    this.fontsize = fontsize;
    this.hiliteCol = hiliteColor;
    this.listener = listener;

    // Text//  w  w w  .j a  va  2s  . c o m
    textEl = paper.text(x, y, tag.getTitle(), TagCloud.FONT, fontsize, hAlign, TagCloud.TAG_TEXT_COLOR, 0);
    bbox = textEl.getBBox();

    // Background
    backgroundEl = paper.rect((int) bbox.getX() - 5, (int) bbox.getY(), (int) bbox.getWidth() + 10,
            (int) bbox.getHeight(), TagCloud.TAG_CORNER_RADIUS, TagCloud.TAG_BACKGROUND_COLOR,
            TagCloud.TAG_BACKGROUND_COLOR, 0);
    backgroundEl.toBack();

    // Foreground (invisible - only for catching mouse events!)
    foregroundEl = paper.rect((int) bbox.getX(), (int) bbox.getY(), (int) bbox.getWidth(),
            (int) bbox.getHeight(), 0, TagCloud.TAG_TEXT_COLOR, TagCloud.TAG_TEXT_COLOR, 0,
            new MouseEventHandler() {
                @Override
                public void onMouseOver(NativeEvent event) {
                    textEl.setFillColor(hiliteCol);
                    tooltip.setPopupPosition(event.getClientX() + 15, event.getClientY());
                    tooltip.show();
                }

                @Override
                public void onMouseMove(NativeEvent event) {
                    tooltip.setPopupPosition(event.getClientX() + 15, event.getClientY());
                }

                @Override
                public void onMouseOut(NativeEvent event) {
                    textEl.setFillColor(TagCloud.TAG_TEXT_COLOR);
                    tooltip.hide();
                }

                @Override
                public void onClick(NativeEvent event) {
                    setSelected(!isSelected);
                }
            });
    foregroundEl.setCursorStyle("pointer");
    foregroundEl.toFront();

    // 'Selected' icon
    iconEl = paper.image(TagCloud.TAG_SELECTED_ICON, (int) bbox.getX() + (int) bbox.getWidth() - 15,
            (int) bbox.getY() + (int) bbox.getHeight() - 30, TagCloud.TAG_SELECTED_ICON_WIDTH,
            TagCloud.TAG_SELECTED_ICON_HEIGHT);
    iconEl.hide();

    // Adjust vertical alignment
    int dy;
    if (vAlign.equals(TagCloud.VALIGN_BOTTOM)) {
        dy = -(int) bbox.getHeight() / 2;
        textEl.translate(0, dy);
        backgroundEl.translate(0, dy);
        foregroundEl.translate(0, dy);
        iconEl.translate(0, dy);
    } else if (vAlign.equals(TagCloud.VALIGN_TOP)) {
        dy = (int) bbox.getHeight() / 2;
        textEl.translate(0, dy);
        backgroundEl.translate(0, dy);
        foregroundEl.translate(0, dy);
        iconEl.translate(0, dy);
    }

    // Tooltip
    tooltip = new PopupPanel();
    tooltip.setStyleName("tooltip");
    tooltip.setWidget(new HTML(tag.getDescription() + "<br/><b>" + tag.getURI()));
    tooltip.hide();
}

From source file:at.ait.dme.yuma.suite.apps.image.core.client.tagcloud.RaphaelTag.java

License:EUPL

public RaphaelTag(SemanticTag tag, int x, int y, int fontsize, String hiliteColor, String hAlign, String vAlign,
        Raphael paper, TagSelectionListener listener) {
    this.tag = tag;
    this.fontsize = fontsize;
    this.hiliteCol = hiliteColor;
    this.listener = listener;

    // Text/*from   www.  j  ava  2s. c o  m*/
    textEl = paper.text(x, y, tag.getPrimaryLabel(), TagCloud.FONT, fontsize, hAlign, TagCloud.TAG_TEXT_COLOR,
            0);
    bbox = textEl.getBBox();

    // Background
    backgroundEl = paper.rect((int) bbox.getX() - 5, (int) bbox.getY(), (int) bbox.getWidth() + 10,
            (int) bbox.getHeight(), TagCloud.TAG_CORNER_RADIUS, TagCloud.TAG_BACKGROUND_COLOR,
            TagCloud.TAG_BACKGROUND_COLOR, 0);
    backgroundEl.toBack();

    // Foreground (invisible - only for catching mouse events!)
    foregroundEl = paper.rect((int) bbox.getX(), (int) bbox.getY(), (int) bbox.getWidth(),
            (int) bbox.getHeight(), 0, TagCloud.TAG_TEXT_COLOR, TagCloud.TAG_TEXT_COLOR, 0,
            new MouseEventHandler() {
                @Override
                public void onMouseOver(NativeEvent event) {
                    textEl.setFillColor(hiliteCol);
                    tooltip.setPopupPosition(event.getClientX() + 15, event.getClientY());
                    tooltip.show();
                }

                @Override
                public void onMouseMove(NativeEvent event) {
                    tooltip.setPopupPosition(event.getClientX() + 15, event.getClientY());
                }

                @Override
                public void onMouseOut(NativeEvent event) {
                    textEl.setFillColor(TagCloud.TAG_TEXT_COLOR);
                    tooltip.hide();
                }

                @Override
                public void onClick(NativeEvent event) {
                    setSelected(!isSelected);
                }
            });
    foregroundEl.setCursorStyle("pointer");
    foregroundEl.toFront();

    // 'Selected' icon
    iconEl = paper.image(TagCloud.TAG_SELECTED_ICON, (int) bbox.getX() + (int) bbox.getWidth() - 15,
            (int) bbox.getY() + (int) bbox.getHeight() - 30, TagCloud.TAG_SELECTED_ICON_WIDTH,
            TagCloud.TAG_SELECTED_ICON_HEIGHT);
    iconEl.hide();

    // Adjust vertical alignment
    int dy;
    if (vAlign.equals(TagCloud.VALIGN_BOTTOM)) {
        dy = -(int) bbox.getHeight() / 2;
        textEl.translate(0, dy);
        backgroundEl.translate(0, dy);
        foregroundEl.translate(0, dy);
        iconEl.translate(0, dy);
    } else if (vAlign.equals(TagCloud.VALIGN_TOP)) {
        dy = (int) bbox.getHeight() / 2;
        textEl.translate(0, dy);
        backgroundEl.translate(0, dy);
        foregroundEl.translate(0, dy);
        iconEl.translate(0, dy);
    }

    // Tooltip
    tooltip = new PopupPanel();
    tooltip.setStyleName("tooltip");
    tooltip.setWidget(new HTML(tag.getPrimaryDescription() + "<br/><b>" + tag.getURI()));
    tooltip.hide();
}

From source file:cc.kune.events.client.viewer.CalendarViewerPanel.java

License:GNU Affero Public License

/**
 * Instantiates a new calendar viewer panel.
 *
 * @param gsArmor/*from  ww  w  .jav  a  2s.  c  om*/
 *          the gs armor
 * @param eventBus
 *          the event bus
 * @param i18n
 *          the i18n
 * @param guiProvider
 *          the gui provider
 * @param res
 *          the res
 * @param capabilitiesRegistry
 *          the capabilities registry
 * @param dragController
 *          the drag controller
 * @param contentDropControllerProv
 *          the content drop controller prov
 * @param containerDropControllerProv
 *          the container drop controller prov
 */
@Inject
public CalendarViewerPanel(final GSpaceArmor gsArmor, final EventBus eventBus,
        final I18nTranslationService i18n, final GuiProvider guiProvider, final CoreResources res,
        final ContentCapabilitiesRegistry capabilitiesRegistry, final KuneDragController dragController,
        final Provider<FolderContentDropController> contentDropControllerProv,
        final Provider<FolderContainerDropController> containerDropControllerProv,
        final InboxToContainerDropController inbDropController) {
    super(gsArmor, eventBus, i18n, capabilitiesRegistry, dragController, contentDropControllerProv,
            containerDropControllerProv, inbDropController);
    calendar = new Calendar();
    calendar.setSettings(setCalendarSettings());
    widget = calendar;
    calendar.sinkEvents(
            Event.ONMOUSEDOWN | Event.ONDBLCLICK | Event.KEYEVENTS | Event.ONMOUSEOVER | Event.ONCLICK);
    Event.addNativePreviewHandler(new NativePreviewHandler() {
        @Override
        public void onPreviewNativeEvent(final NativePreviewEvent eventPrev) {
            // We store click position in onder to show the menu
            final NativeEvent natEvent = eventPrev.getNativeEvent();
            if (Event.getTypeInt(natEvent.getType()) != Event.ONCLICK) {
                clientX = natEvent.getClientX();
                clientY = natEvent.getClientY();
                return;
            }
        }
    });
    contentTitle = new ContentTitleWidget(i18n, gsArmor, capabilitiesRegistry.getIconsRegistry());
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(final ResizeEvent event) {
            resizeCalendar();
        }
    });
    tooltipPanel = new PopupPanel();
    Tooltip.to(tooltipPanel, "FIXME");
    addMouseOverHandler(new MouseOverHandler<Appointment>() {
        @Override
        public void onMouseOver(final MouseOverEvent<Appointment> event) {
            final Element element = (Element) event.getElement();
            tooltipPanel.setPopupPosition(DOM.getAbsoluteLeft(element),
                    DOM.getAbsoluteTop(element) + element.getOffsetHeight());
            tooltipPanel.show();
            if (Tooltip.getTip().isShowing()) {
                tooltipPanel.hide();
                Tooltip.getTip().hide();
            } else {
                Tooltip.getTip().showTemporally(tooltipPanel, tooltipText);
            }
            // NotifyUser.info("On mouse");
        }
    });
}

From source file:ch.unifr.pai.twice.dragndrop.client.MPDragNDrop.java

License:Apache License

/**
 * Helper method to get the y-position of a event (relative to the client)
 * /*from   w w  w  . j  a va  2  s. c om*/
 * @param event
 * @return
 */
int getY(NativeEvent event) {
    return event.getClientY();
}

From source file:co.fxl.gui.gwt.GWTDisplay.java

License:Open Source License

public static void notifyEvent(NativeEvent nativeEvent) {
    lastClickX = nativeEvent.getClientX();
    lastClickY = nativeEvent.getClientY();
}

From source file:com.allen_sauer.gwt.dnd.client.MouseDragHandler.java

License:Apache License

private void synthesizeAsyncMouseUp(MouseUpEvent event) {
    final Element elem = mouseDownWidget.getElement();
    NativeEvent n = event.getNativeEvent();
    // One click, see https://developer.mozilla.org/en-US/docs/DOM/event.detail
    final int detail = 1;
    final int screenX = n.getScreenX();
    final int screenY = n.getScreenY();
    final int clientX = n.getClientX();
    final int clientY = n.getClientY();
    final boolean ctrlKey = n.getCtrlKey();
    final boolean altKey = n.getAltKey();
    final boolean shiftKey = n.getShiftKey();
    final boolean metaKey = n.getMetaKey();
    final int button = n.getButton();

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override/*from   w  w w .  ja v  a2 s . com*/
        public void execute() {
            // TODO determine if we need to set additional event properties
            elem.dispatchEvent(Document.get().createMouseUpEvent(detail, screenX, screenY, clientX, clientY,
                    ctrlKey, altKey, shiftKey, metaKey, button));
        }
    });
}

From source file:com.badlogic.gdx.backends.gwt.GwtInput.java

License:Apache License

/** Kindly borrowed from PlayN. **/
protected int getRelativeY(NativeEvent e, CanvasElement target) {
    float yScaleRatio = target.getHeight() * 1f / target.getClientHeight(); // Correct for canvas CSS scaling
    return Math.round(yScaleRatio * (e.getClientY() - target.getAbsoluteTop() + target.getScrollTop()
            + target.getOwnerDocument().getScrollTop()));
}

From source file:com.centretown.parts.client.application.home.HomePageView.java

License:Apache License

/**
 * Returns the coordinates of a NativeEvent, converted to the SVG coordinate
 * system// w w  w .  j  a  v  a2 s .c o  m
 * 
 * @param e
 *            A NativeEvent
 * @param screenCTM
 *            `
 * @return The coordinates of the mouse event, converted to the SVG
 *         coordinate system
 */
public OMSVGPoint getLocalCoordinates(NativeEvent e, OMSVGMatrix screenCTM) {
    OMSVGPoint p = svgSvg.createSVGPoint(e.getClientX(), e.getClientY());
    OMSVGMatrix m = screenCTM.inverse();
    return p.matrixTransform(m);
}