本文整理汇总了Java中com.google.gwt.event.dom.client.MouseEvent类的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent类的具体用法?Java MouseEvent怎么用?Java MouseEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MouseEvent类属于com.google.gwt.event.dom.client包,在下文中一共展示了MouseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeTarget
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
@Override
protected boolean changeTarget(Widget aMovableTarget, Widget aResizableTarget, int dx, int dy, MouseEvent<?> aEvent) {
if (isNresizable()) {
double newTop = targetScrollTop + dy;
aMovableTarget.getElement().getStyle().setTop(newTop >= 0 ? newTop : 0, Style.Unit.PX);
if (newTop >= 0) {
aResizableTarget.getElement().getStyle().setHeight(targetHeight - dy, Style.Unit.PX);
/*
if (aResizableTarget instanceof RequiresResize) {
((RequiresResize) aResizableTarget).onResize();
}
*/
}
return true;
} else {
return false;
}
}
示例2: getMouseInfo
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private static Map<String,String> getMouseInfo(MouseEvent event) {
Map<String,String> mouseInfo = new HashMap<String,String>();
int posX = -1;
int posY = -1;
try {
// In QTree class a SelectionEvent is translated to a ClickEvent,
// so position X and Y are not present (nativeEvent is null, is used to get the clientX and clientY)
posX = event.getClientX();
posY = event.getClientY();
} catch (Exception e) {
// Ignore
}
mouseInfo.put(EventDataI.MOUSE_X, String.valueOf(posX));
mouseInfo.put(EventDataI.MOUSE_Y, String.valueOf(posY));
return mouseInfo;
}
示例3: getLocation
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
@Override
public Coordinate getLocation(HumanInputEvent<?> event, RenderSpace renderSpace) {
switch (renderSpace) {
case WORLD:
Coordinate screen = getLocation(event, RenderSpace.SCREEN);
return mapWidget.getMapModel().getMapView().getWorldViewTransformer().viewToWorld(screen);
case SCREEN:
default:
if (event instanceof MouseEvent<?>) {
Element element = mapWidget.getDOM();
double offsetX = ((MouseEvent<?>) event).getRelativeX(element);
double offsetY = ((MouseEvent<?>) event).getRelativeY(element);
return new Coordinate(offsetX, offsetY);
} else if (event instanceof TouchEvent<?>) {
Touch touch = ((TouchEvent<?>) event).getTouches().get(0);
return new Coordinate(touch.getClientX(), touch.getClientY());
}
return new Coordinate(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
}
}
示例4: createTempLines
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
protected void createTempLines(FeatureTransaction featureTransaction, MouseEvent<?> event) {
if (featureTransaction.getNewFeatures() != null && featureTransaction.getNewFeatures().length > 0
&& tempLine1 == null) {
Coordinate position = getPanPosition(event);
Geometry geom = getGeometryIndex().getGeometry(featureTransaction);
LineString lineString = geom.getGeometryFactory().createLineString(new Coordinate[] { position, position });
tempLine1 = new GfxGeometry("LineStringEditController.updateLine1");
tempLine1.setGeometry(lineString);
tempLine1.setStyle(new ShapeStyle("#FFFFFF", 0, "#FF3322", 1, 1));
mapWidget.render(tempLine1, RenderGroup.VECTOR, RenderStatus.ALL);
tempLine2 = new GfxGeometry("LineStringEditController.updateLine2");
tempLine2.setGeometry(lineString);
tempLine2.setStyle(new ShapeStyle("#FFFFFF", 0, "#FF3322", 1, 1));
mapWidget.render(tempLine2, RenderGroup.VECTOR, RenderStatus.ALL);
}
}
示例5: PressCancelEvent
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
public PressCancelEvent(MouseEvent<MouseOutHandler> sourceEvent) {
super(sourceEvent);
clientXPos = sourceEvent.getClientX();
clientYPos = sourceEvent.getClientY();
screenXPos = sourceEvent.getScreenX();
screenYPos = sourceEvent.getScreenY();
}
示例6: handleClickEvent
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private void handleClickEvent(MouseEvent clickEvent) {
Element clickedTarget = Element.as(clickEvent.getNativeEvent().getEventTarget());
if (clickedTarget.getClassName().contains("cr-component-cell") ||
clickedTarget.getClassName().contains("v-layout"))
{
NativeEvent event = cloneClickEvent(clickEvent);
clickedTarget.getParentElement().dispatchEvent(event);
} else {
clickEvent.stopPropagation();
}
}
示例7: cloneClickEvent
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private NativeEvent cloneClickEvent(MouseEvent clickEvent) {
return Document.get().createClickEvent(SINGLE_CLICK,
clickEvent.getNativeEvent().getScreenX(),
clickEvent.getNativeEvent().getScreenY(),
clickEvent.getNativeEvent().getClientX(),
clickEvent.getNativeEvent().getClientY(),
clickEvent.getNativeEvent().getCtrlKey(),
clickEvent.getNativeEvent().getAltKey(),
clickEvent.getNativeEvent().getShiftKey(),
clickEvent.getNativeEvent().getMetaKey());
}
示例8: getAbsoluteX
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private int getAbsoluteX(HumanInputEvent ev) {
if (ev instanceof MouseEvent) {
return ((MouseEvent)ev).getClientX()+Window.getScrollLeft();
}
if (ev instanceof TouchEvent) {
JsArray<Touch> tAry= ((TouchEvent)ev).getTargetTouches();
return tAry.get(0).getClientX()+Window.getScrollLeft();
}
return 0;
}
示例9: getAbsoluteY
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private int getAbsoluteY(HumanInputEvent ev) {
if (ev instanceof MouseEvent) {
return ((MouseEvent)ev).getClientY()+ Window.getScrollTop();
}
if (ev instanceof TouchEvent) {
JsArray<Touch> tAry= ((TouchEvent)ev).getTargetTouches();
return tAry.get(0).getClientY() + Window.getScrollTop();
}
return 0;
}
示例10: getPoint
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private static Point getPoint(EventHandlingTarget drawPanelCanvas, HumanInputEvent<?> event) {
Element e = drawPanelCanvas.getElement();
if (event instanceof MouseEvent<?>) {
return new Point(((MouseEvent<?>) event).getRelativeX(e), ((MouseEvent<?>) event).getRelativeY(e));
}
else if (event instanceof TouchEndEvent) {
return new Point(((TouchEvent<?>) event).getChangedTouches().get(0).getRelativeX(e), ((TouchEvent<?>) event).getChangedTouches().get(0).getRelativeY(e));
}
else if (event instanceof TouchEvent<?>) {
return new Point(((TouchEvent<?>) event).getTouches().get(0).getRelativeX(e), ((TouchEvent<?>) event).getTouches().get(0).getRelativeY(e));
}
else {
throw new RuntimeException("Unknown Event Type: " + event);
}
}
示例11: getPointAbsolute
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
private static Point getPointAbsolute(HumanInputEvent<?> event) {
if (event instanceof MouseEvent<?>) {
return new Point(((MouseEvent<?>) event).getClientX(), ((MouseEvent<?>) event).getClientY());
}
else if (event instanceof TouchEndEvent) {
return new Point(((TouchEvent<?>) event).getChangedTouches().get(0).getPageX(), ((TouchEvent<?>) event).getChangedTouches().get(0).getPageY());
}
else if (event instanceof TouchEvent<?>) {
return new Point(((TouchEvent<?>) event).getTouches().get(0).getPageX(), ((TouchEvent<?>) event).getTouches().get(0).getPageY());
}
else {
throw new RuntimeException("Unknown Event Type: " + event);
}
}
示例12: findAtomicNodeForMouseEvent
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Node findAtomicNodeForMouseEvent(MouseEvent me) {
double x = (((double) me.getX()) / ((double) _gc.width()));
double y = (((double) me.getY()) / ((double) _gc.height()));
return _graph.findAtomicNodeAt(new Point(x, y));
}
示例13: getCellForEvent
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
/**
* Given a click event, return the Cell that was clicked, or null if the event
* did not hit this table. The cell can also be null if the click event does
* not occur on a specific cell.
*
* @param event A click event of indeterminate origin
* @return The appropriate cell, or null
*/
public Cell getCellForEvent(MouseEvent<? extends EventHandler> event) {
Element td = getEventTargetCell(Event.as(event.getNativeEvent()));
if (td == null) {
return null;
}
int row = TableRowElement.as(td.getParentElement()).getSectionRowIndex();
int column = TableCellElement.as(td).getCellIndex();
return new Cell(row, column);
}
示例14: updateTempLineAfterMove
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
protected void updateTempLineAfterMove(MouseEvent<?> event) {
if (tempLine == null) {
updateTempLineAfterClick();
}
if (currentLineStringCoordinates != null && currentLineStringCoordinates.length > 0) {
Coordinate[] newCoords = new Coordinate[currentLineStringCoordinates.length + 1];
System.arraycopy(currentLineStringCoordinates, 0, newCoords, 0, currentLineStringCoordinates.length);
newCoords[currentLineStringCoordinates.length] = getPanPosition(event);
LineString lineString = geometry.getGeometryFactory().createLineString(newCoords);
tempLine.setGeometry(lineString);
mapWidget.render(tempLine, RenderGroup.VECTOR, RenderStatus.UPDATE);
}
}
示例15: updateTempLineAfterMove
import com.google.gwt.event.dom.client.MouseEvent; //导入依赖的package包/类
@Override
protected void updateTempLineAfterMove(MouseEvent<?> event) {
if (tempPolygon == null) {
updateTempLineAfterClick();
}
Polygon polygon = (Polygon) geometry;
if (polygon != null && polygon.getCoordinates() != null && polygon.getCoordinates().length > 0) {
LinearRing ring = geometry.getGeometryFactory().createLinearRing(polygon.getCoordinates());
if (ring != null && geometry.getCoordinates().length > 0) {
Coordinate[] coordinates = ring.getCoordinates();
Coordinate firstCoordinate = coordinates[0];
Coordinate lastCoordinate = coordinates[coordinates.length - 2];
LineString lineStringPan = geometry.getGeometryFactory().createLineString(new Coordinate[] {
getTransformer().worldToPan(lastCoordinate),
getPanPosition(event),
getTransformer().worldToPan(firstCoordinate) });
tempLine.setGeometry(lineStringPan);
mapWidget.render(tempLine, RenderGroup.VECTOR, RenderStatus.ALL);
}
}
}