com.google.gwt.event.dom.client.MouseEvent.getX()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中com.google.gwt.event.dom.client.MouseEvent.getX()方法的一些代码示例,展示了MouseEvent.getX()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MouseEvent.getX()方法的具体详情如下:
包路径:com.google.gwt.event.dom.client.MouseEvent
类名称:MouseEvent
方法名:getX

MouseEvent.getX介绍

[英]Gets the mouse x-position relative to the event's current target element.
[中]获取鼠标相对于事件当前目标元素的x位置。

代码示例

代码示例来源:origin: com.ahome-it/lienzo-core

public void down(final MouseEvent<? extends EventHandler> event)
{
  if ((getSelectionShape() != null) && !m_selectionShapeProvider.isMultipleSelection(event))
  {
    // if the mousedown is any where other than the rectangle, and shift was not held,  clear it.
    // this way, if necessary, a new selection can begin
    final Node<?> node = m_layer.getViewport().findShapeAtPoint(event.getX(), event.getY());
    if (node != getSelectionShape())
    {
      clearIfSelection();
    }
  }
}

代码示例来源:origin: ahome-it/lienzo-core

public void down(final MouseEvent<? extends EventHandler> event)
{
  if ((getSelectionShape() != null) && !m_selectionShapeProvider.isMultipleSelection(event))
  {
    // if the mousedown is any where other than the rectangle, and shift was not held,  clear it.
    // this way, if necessary, a new selection can begin
    final Node<?> node = m_layer.getViewport().findShapeAtPoint(event.getX(), event.getY());
    if (node != getSelectionShape())
    {
      clearIfSelection();
    }
  }
}

代码示例来源:origin: ahome-it/lienzo-core

public void down(final MouseEvent<? extends EventHandler> event)
{
  if ((getSelectionShape() != null) && !m_selectionShapeProvider.isMultipleSelection(event))
  {
    // if the mousedown is any where other than the rectangle, and shift was not held,  clear it.
    // this way, if necessary, a new selection can begin
    final Node<?> node = m_layer.getViewport().findShapeAtPoint(event.getX(), event.getY());
    if (node != getSelectionShape())
    {
      clearIfSelection();
    }
  }
}

代码示例来源:origin: ahome-it/lienzo-core

void drawSelectionShape(final MouseEvent<? extends EventHandler> event)
{
  final double relativeStartX = getSelectionManager().relativeStartX();
  final double relativeStartY = getSelectionManager().relativeStartY();
  final Point2D untransformedPoint = getSelectionManager().getUntransformedPoint(new Point2D(event.getX(), event.getY()));
  final double relativeEventX = untransformedPoint.getX();
  final double relativeEventY = untransformedPoint.getY();
  final Layer overLayer = m_layer.getViewport().getOverLayer();
  double width = relativeEventX - relativeStartX;
  double height = relativeEventY - relativeStartY;
  // if either width or height is zero, you won't see the line being drawn, so ensure at least 1px separation
  if ( width == 0 )
  {
    width += 1;
  }
  if ( height == 0 )
  {
    height += 1;
  }
  getSelectionManager().drawSelectionShape(relativeStartX, relativeStartY, width, height, overLayer);
  overLayer.draw();
}

代码示例来源:origin: com.ahome-it/lienzo-core

void drawSelectionShape(final MouseEvent<? extends EventHandler> event)
{
  final double relativeStartX = getSelectionManager().relativeStartX();
  final double relativeStartY = getSelectionManager().relativeStartY();
  final Point2D untransformedPoint = getSelectionManager().getUntransformedPoint(new Point2D(event.getX(), event.getY()));
  final double relativeEventX = untransformedPoint.getX();
  final double relativeEventY = untransformedPoint.getY();
  final Layer overLayer = m_layer.getViewport().getOverLayer();
  double width = relativeEventX - relativeStartX;
  double height = relativeEventY - relativeStartY;
  // if either width or height is zero, you won't see the line being drawn, so ensure at least 1px separation
  if ( width == 0 )
  {
    width += 1;
  }
  if ( height == 0 )
  {
    height += 1;
  }
  getSelectionManager().drawSelectionShape(relativeStartX, relativeStartY, width, height, overLayer);
  overLayer.draw();
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-javascript-api

public Coordinate getLocation(HumanInputEvent<?> event, String renderSpace) {
  Element el = DOM.getElementById(map.getHtmlElementId()).getFirstChildElement();
  Coordinate location = null;
  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;
}

代码示例来源:origin: ahome-it/lienzo-core

void drawSelectionShape(final MouseEvent<? extends EventHandler> event)
{
  final double relativeStartX = getSelectionManager().relativeStartX();
  final double relativeStartY = getSelectionManager().relativeStartY();
  final Point2D untransformedPoint = getSelectionManager().getUntransformedPoint(new Point2D(event.getX(), event.getY()));
  final double relativeEventX = untransformedPoint.getX();
  final double relativeEventY = untransformedPoint.getY();
  final Layer overLayer = m_layer.getViewport().getOverLayer();
  double width = relativeEventX - relativeStartX;
  double height = relativeEventY - relativeStartY;
  // if either width or height is zero, you won't see the line being drawn, so ensure at least 1px separation
  if ( width == 0 )
  {
    width += 1;
  }
  if ( height == 0 )
  {
    height += 1;
  }
  getSelectionManager().drawSelectionShape(relativeStartX, relativeStartY, width, height, overLayer);
  overLayer.draw();
}

相关文章