Java 类com.google.gwt.event.dom.client.HumanInputEvent 实例源码

项目:firefly    文件:PopupPane.java   
private void humanStart(HumanInputEvent ev) {
    int x= getAbsoluteX(ev);
    int y= getAbsoluteY(ev);
    PopupRegion r= findRegion(x,y);

    addPreventEvent();
    if (r== PopupRegion.TITLE_BAR) {
        if (_hideOnResizeWidget!=null) {
            GwtUtil.setStyle(_hideOnResizeWidget, "visibility", "hidden");
        }
        ev.preventDefault();
        beginMove(x,y);

    } else if (_expandW!=null) {
        if (r== PopupRegion.SE_CORNER || r== PopupRegion.SW_CORNER) {
            if (_hideOnResizeWidget!=null) {
                GwtUtil.setStyle(_hideOnResizeWidget, "visibility", "hidden");
            }
            ev.preventDefault();
            beginResize(r);
        }
    }
}
项目:firefly    文件:PopupPane.java   
private void humanStop(HumanInputEvent ev) {
        removePreventEvent();
        if (_moving) {
            if (_hideOnResizeWidget!=null) {
                GwtUtil.setStyle(_hideOnResizeWidget, "visibility", "visible");
            }
            ev.preventDefault();
//            DOM.eventPreventDefault(ev);
            endMove();

        }
        else if (_resizing) {
            if (_hideOnResizeWidget!=null) {
                GwtUtil.setStyle(_hideOnResizeWidget, "visibility", "visible");
            }
            ev.preventDefault();
//            DOM.eventPreventDefault(ev);
            endResize();
        }
    }
项目:umlet    文件:EventHandlingUtils.java   
private static void handleMove(final EventHandlingTarget panel, final DragCache storage, HumanInputEvent<?> event) {
    // Notification.showInfo("MOVE " + getPointAbsolute(event));
    if (storage.activePanel != null && DRAG_COMMANDS.contains(storage.dragging)) {
        Point p = getPoint(storage.activePanel, event);
        int diffX = p.x - storage.moveStart.getX();
        int diffY = p.y - storage.moveStart.getY();
        diffX -= diffX % SharedConstants.DEFAULT_GRID_SIZE;
        diffY -= diffY % SharedConstants.DEFAULT_GRID_SIZE;
        if (diffX != 0 || diffY != 0) {
            panel.onMouseMoveDraggingScheduleDeferred(storage.moveStart, diffX, diffY, storage.elementToDrag, event.isShiftKeyDown(), event.isControlKeyDown(), storage.dragging == DragStatus.FIRST);
            storage.dragging = DragStatus.CONTINUOUS; // after FIRST real drag switch to CONTINUOUS
            storage.moveStart = storage.moveStart.copy().move(diffX, diffY); // make copy because otherwise deferred action will act on wrong position
        }
    }
    else if (storage.mouseContainingPanel != null) {
        storage.mouseContainingPanel.onMouseMove(getPoint(storage.mouseContainingPanel, event));
    }
}
项目:geomajas-project-client-gwt    文件:AbstractGraphicsController.java   
@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());
    }
}
项目:geomajas-project-client-gwt    文件:AbstractRectangleController.java   
/**
 * Start dragging, register base for selection rectangle.
 * 
 * @param event
 *            event
 */
@Override
public void onDown(HumanInputEvent<?> event) {
    if (dragging && leftWidget) {
        // mouse was moved outside of widget
        doSelect(event);

    } else if (!isRightMouseButton(event)) {
        // no point trying to select when there is no active layer
        dragging = true;
        leftWidget = false;
        timestamp = new Date().getTime();
        begin = getLocation(event, RenderSpace.SCREEN);
        bounds = new Bbox(begin.getX(), begin.getY(), 0.0, 0.0);
        shift = event.isShiftKeyDown();
        rectangle = new Rectangle("selectionRectangle");
        rectangle.setStyle(rectangleStyle);
        rectangle.setBounds(bounds);
        mapWidget.render(rectangle, RenderGroup.SCREEN, RenderStatus.UPDATE);
    }
}
项目:geomajas-project-client-gwt    文件:AbstractRectangleController.java   
private void updateRectangle(HumanInputEvent<?> event) {
    Coordinate pos = getLocation(event, RenderSpace.SCREEN);
    double x = begin.getX();
    double y = begin.getY();
    double width = pos.getX() - x;
    double height = pos.getY() - y;
    if (width < 0) {
        x = pos.getX();
        width = -width;
    }
    if (height < 0) {
        y = pos.getY();
        height = -height;
    }
    bounds.setX(x);
    bounds.setY(y);
    bounds.setWidth(width);
    bounds.setHeight(height);
}
项目:geomajas-project-client-gwt    文件:ZoomSliderController.java   
@Override
public void onDown(HumanInputEvent<?> event) {
    SliderArea sliderArea = zoomSlider.getSliderArea();
    event.stopPropagation();
    double y = getLocation(event, RenderSpace.SCREEN).getY();
    double x = getLocation(event, RenderSpace.SCREEN).getX();
    Bbox sliderAreaBounds = sliderArea.getAddonBounds();
    Coordinate origin = sliderAreaBounds.getOrigin();
    Coordinate endPoint = sliderAreaBounds.getEndPoint();
    if (origin.getX() < x && endPoint.getX() > x &&
        origin.getY() < y && endPoint.getY() > y) {
        dragging = true;
        sliderArea.drawMapRectangle();
    }
    event.preventDefault();
}
项目:swarm    文件:Magnifier.java   
private void onDraggerMouseUp(HumanInputEvent event, double relativeY)
{
    if( m_isMouseDown )
    {
        Event.releaseCapture(Magnifier.this.m_dragger.getElement());
        event.preventDefault();

        //--- DRK > Pretty hacky, but I can't figure out how to "forward" the event up the DOM so tooltip can get it.
        if( event instanceof MouseUpEvent )
        {
            m_viewContext.toolTipMngr.onMouseUp((MouseUpEvent)event);
        }

        double mouseY = relativeY;
        Magnifier.this.setDraggerPositionFromMouse(mouseY + m_mouseDownOffset);

        m_isMouseDown = false;
    }
}
项目:geomajas-project-client-gwt2    文件:GeometryIndexInsertController.java   
public void onUp(HumanInputEvent<?> event) {
    // Only insert when service is in the correct state:
    if (service.getEditingState() == GeometryEditState.INSERTING) {
        try {
            if (isDoubleClick(event)) {
                stopInserting();                    
            } else {
                // Insert the location at the given index:
                GeometryIndex insertIndex = service.getInsertIndex();
                Coordinate location = getSnappedLocationWithinMaxBounds(event);
                service.insert(Collections.singletonList(insertIndex),
                        Collections.singletonList(Collections.singletonList(location)));

                String geometryType = service.getGeometry().getGeometryType();
                if (geometryType.equals(Geometry.POINT) || geometryType.equals(Geometry.MULTI_POINT)) {
                    stopInserting();
                }
            }
        } catch (GeometryOperationFailedException e) {
            logger.log(Level.WARNING, "Operation failed", e);
        }
    }
}
项目:geomajas-project-client-gwt2    文件:GeometryIndexInsertController.java   
private boolean isDoubleClick(HumanInputEvent<?> event) {
    Coordinate clickPosition = getLocation(event, RenderSpace.SCREEN);
    boolean doubleClicked = false;
    if (lastClickedPosition != null) {
        int distance = (int) Math.hypot(clickPosition.getX() - lastClickedPosition.getX(), clickPosition.getY()
                - lastClickedPosition.getY());
        if (distance < MIN_DOUBLECLICK_DISTANCE) {
            doubleClicked = true;
        } 
    } 
    if (doubleClicked) {
        lastClickedPosition = null;
        return true;
    } else {
        lastClickedPosition = clickPosition;
        return false;
    }
}
项目:geomajas-project-client-gwt2    文件:GeometryIndexSelectHandler.java   
public void onDown(HumanInputEvent<?> event) {
    if (service.getEditingState() == GeometryEditState.IDLE) {
        if (event.isShiftKeyDown()) {
            // Add to or remove from selection:
            if (service.getIndexStateService().isSelected(index)) {
                service.getIndexStateService().deselect(Collections.singletonList(index));
                event.stopPropagation();
            } else {
                service.getIndexStateService().select(Collections.singletonList(index));
            }
        } else {
            // Deselect all and select only this index:
            service.getIndexStateService().deselectAll();
            service.getIndexStateService().select(Collections.singletonList(index));                
        }
    }
}
项目:geomajas-project-client-gwt2    文件:AbstractCircleController.java   
@Override
public void onDown(HumanInputEvent<?> event) {
    if (!isRightMouseButton(event)) {
        dragging = true;
        begin = getLocation(event, RenderSpace.SCREEN);
        shift = event.isShiftKeyDown();

        circle = new Circle((int) begin.getX(), (int) begin.getY(), 0);
        circle.setFillColor(fillColor);
        circle.setFillOpacity(fillOpacity);
        circle.setStrokeColor(strokeColor);
        circle.setStrokeWidth(strokeWidth);
        getContainer().add(circle);

        line = new Line((int) begin.getX(), (int) begin.getY(), (int) begin.getX(), (int) begin.getY());
        line.setStrokeColor(strokeColor);
        line.setStrokeWidth(strokeWidth);
        getContainer().add(line);
    }
}
项目:geomajas-project-client-gwt2    文件:AbstractCircleController.java   
@Override
public void onUp(HumanInputEvent<?> event) {
    // Assure dragging or clicking started inside this widget
    if (dragging) {
        shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
        updateCircle(event);

        Geometry geometry = new Geometry(Geometry.POINT, 0, -1);
        Coordinate[] coordinates = new Coordinate[]{new Coordinate(circle.getUserX(), circle.getUserY())};
        geometry.setCoordinates(coordinates);

        ViewPort viewPort = mapPresenter.getViewPort();
        execute(viewPort.getTransformationService().transform(geometry, RenderSpace.SCREEN, RenderSpace.WORLD), 
                circle.getRadius() * viewPort.getResolution());

        stopDragging();
        dragging = false;
    }
}
项目:geomajas-project-client-gwt2    文件:AbstractCircleController.java   
private void updateCircle(HumanInputEvent<?> event) {
    Coordinate pos = getLocation(event, RenderSpace.SCREEN);
    double x = begin.getX();
    double y = begin.getY();
    double currentX = pos.getX();
    double currentY = pos.getY();

    double deltaX = currentX - x;
    double deltaY = currentY - y;
    radius = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));

    circle.setRadius((int) radius);

    line.setUserX2(currentX);
    line.setUserY2(currentY);
}
项目:firefly    文件:PopupPane.java   
private void humanMove(HumanInputEvent ev) {
        int x= getAbsoluteX(ev);
        int y= getAbsoluteY(ev);
        if (_moving) {
//            DOM.eventPreventDefault(ev.getNativeEvent());
            ev.preventDefault();
            doMove(x,y);
        }
        else if (_resizing) {
//            DOM.eventPreventDefault(ev);
            ev.preventDefault();
            moveResize(x,y);
        }
    }
项目:firefly    文件:PopupPane.java   
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;
}
项目:firefly    文件:PopupPane.java   
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;
}
项目:umlet    文件:EventHandlingUtils.java   
private static void handleEnd(EventHandlingTarget panel, final DragCache storage, HumanInputEvent<?> event) {
    // Notification.showInfo("UP");
    if (DRAG_COMMANDS.contains(storage.dragging)) {
        panel.onMouseDragEnd(storage.elementToDrag, getPoint(storage.activePanel, event));
    }
    storage.dragging = DragStatus.NO;
}
项目:umlet    文件:EventHandlingUtils.java   
private static void handleStart(EventHandlingTarget[] panels, final DragCache storage, FocusPanel handlerTarget, HumanInputEvent<?> event, Point p) {
    // Notification.showInfo("DOWN " + p.x);
    handlerTarget.setFocus(true);

    event.preventDefault(); // necessary to avoid showing textcursor and selecting proppanel in chrome AND to avoid scrolling with touch move (problem is it also avoids scrolling with 2 fingers)
    storage.moveStart = new Point(p.x, p.y);
    storage.dragging = DragStatus.FIRST;
    storage.elementToDrag = storage.activePanel.getGridElementOnPosition(storage.moveStart);
    storage.activePanel.onMouseDownScheduleDeferred(storage.elementToDrag, event.isControlKeyDown());
}
项目:umlet    文件:EventHandlingUtils.java   
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);
    }
}
项目:umlet    文件:EventHandlingUtils.java   
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);
    }
}
项目:gef-gwt    文件:Widget.java   
private static void addStateMasks(HumanInputEvent event, MouseEvent me) {
    if (event.isShiftKeyDown()) {
        me.stateMask |= SWT.SHIFT;
    }
    if (event.isControlKeyDown()) {
        me.stateMask |= SWT.CONTROL;
    }
    if (event.isAltKeyDown()) {
        me.stateMask |= SWT.ALT;
    }
}
项目:geomajas-gwt2-quickstart-application    文件:FeatureClickedListener.java   
/**
 * Is the event at the same location as the "down" event?
 *
 * @param event The event to check.
 * @return true or false.
 */
private boolean isDownPosition(HumanInputEvent<?> event) {
    if (clickedPosition != null) {
        Coordinate location = getLocation(event, RenderSpace.SCREEN);
        if (MathService.distance(clickedPosition, location) < clickDelta) {
            return true;
        }
    }
    return false;
}
项目:geomajas-project-client-gwt    文件:DeleteRingBtn.java   
public void onUp(HumanInputEvent<?> event) {
    if (service.getIndexStateService().isMarkedForDeletion(index)) {
        try {
            service.remove(Collections.singletonList(index));
        } catch (GeometryOperationFailedException e) {
            Window.alert("Error occurred while deleting the inner ring: " + e.getMessage());
        }
        resumeNormalBehavior();
        setSelected(false);
    }
}
项目:geomajas-project-client-gwt    文件:CompositeGeometryIndexController.java   
public void onDown(HumanInputEvent<?> event) {
    if (!isRightMouseButton(event)) {
        for (MapDownHandler handler : downHandlers) {
            handler.onDown(event);
        }
    }
}
项目:geomajas-project-client-gwt    文件:CompositeGeometryIndexController.java   
public void onUp(HumanInputEvent<?> event) {
    if (service.getIndexStateService().isEnabled(index)) {
        for (MapUpHandler handler : upHandlers) {
            handler.onUp(event);
        }
    }
}
项目:geomajas-project-client-gwt    文件:CompositeGeometryIndexController.java   
public void onDrag(HumanInputEvent<?> event) {
    if (service.getIndexStateService().isEnabled(index)) {
        for (MapDragHandler handler : dragHandlers) {
            handler.onDrag(event);
        }
    }
}
项目:geomajas-project-client-gwt    文件:EditGeometryBaseController.java   
public void onDown(HumanInputEvent<?> event) {
    if (service.getEditingState() == GeometryEditState.IDLE) {
        // No shift key down, because we don't want to pan when deselecting vertices.
        // TODO remove the shift check somehow... (now replaced with a event.stopPropagation in selection handler)
        idleController.onDown(event);
    } else if (service.getEditingState() == GeometryEditState.DRAGGING) {
        dragController.onDown(event);
    } else if (service.getEditingState() == GeometryEditState.INSERTING) {
        insertController.onDown(event);
    }
}
项目:geomajas-project-client-gwt    文件:EditGeometryBaseController.java   
public void onDrag(HumanInputEvent<?> event) {
    if (service.getEditingState() == GeometryEditState.IDLE) {
        idleController.onDrag(event);
    } else if (service.getEditingState() == GeometryEditState.DRAGGING) {
        dragController.onDrag(event);
    } else if (service.getEditingState() == GeometryEditState.INSERTING) {
        insertController.onDrag(event);
    }
}
项目:geomajas-project-client-gwt    文件:EditGeometryBaseController.java   
public void onUp(HumanInputEvent<?> event) {
    if (service.getEditingState() == GeometryEditState.IDLE) {
        idleController.onUp(event);
    } else if (service.getEditingState() == GeometryEditState.DRAGGING) {
        dragController.onUp(event);
    } else if (service.getEditingState() == GeometryEditState.INSERTING) {
        insertController.onUp(event);
    }
}
项目:geomajas-project-client-gwt    文件:PanController.java   
@Override
public void onDown(HumanInputEvent<?> event) {
    if (event.isControlKeyDown() || event.isShiftKeyDown()) {
        zooming = true;
        zoomToRectangleController.onDown(event);
    } else if (!isRightMouseButton(event)) {
        panning = true;
        mapWidget.getMapModel().getMapView().setPanDragging(true);
        begin = getLocation(event, RenderSpace.SCREEN);
        if (!isShowCursorOnMove()) {
            mapWidget.setCursor(Cursor.MOVE);
        }
    }
    lastClickPosition = getLocation(event, RenderSpace.WORLD);
}
项目:geomajas-project-client-gwt    文件:PanController.java   
@Override
public void onUp(HumanInputEvent<?> event) {
    if (zooming) {
        zoomToRectangleController.onUp(event);
        zooming = false;
    } else if (panning) {
        stopPanning(event);
    }
}
项目:geomajas-project-client-gwt    文件:PanController.java   
@Override
public void onDrag(HumanInputEvent<?> event) {
    if (zooming) {
        zoomToRectangleController.onDrag(event);
    } else if (panning) {
        if (!moving && isShowCursorOnMove()) {
            mapWidget.setCursor(Cursor.MOVE);
        }
        moving = true;
        updateView(event);
    }
}
项目:geomajas-project-client-gwt    文件:PanController.java   
private void stopPanning(HumanInputEvent<?> event) {
    mapWidget.getMapModel().getMapView().setPanDragging(false);
    panning = false;
    moving = false;
    mapWidget.setCursorString(mapWidget.getDefaultCursorString());
    if (null != event) {
        updateView(event);
    }
}
项目:geomajas-project-client-gwt    文件:PanController.java   
private void updateView(HumanInputEvent<?> event) {
    Coordinate end = getLocation(event, RenderSpace.SCREEN);
    Coordinate beginWorld = getTransformer().viewToWorld(begin);
    Coordinate endWorld = getTransformer().viewToWorld(end);
    mapWidget.getMapModel().getMapView()
            .translate(beginWorld.getX() - endWorld.getX(), beginWorld.getY() - endWorld.getY());
    begin = end;
}
项目:geomajas-project-client-gwt    文件:AbstractGraphicsController.java   
@Override
public Element getTarget(HumanInputEvent<?> event) {
    EventTarget target = event.getNativeEvent().getEventTarget();
    if (Element.is(target)) {
        return Element.as(target);
    }
    return null;
}
项目:geomajas-project-client-gwt    文件:SingleSelectionController.java   
/**
 * Toggle selection at the event location.
 * 
 * @param event
 *            event
 */
public void onUp(HumanInputEvent<?> event) {
    if (!isRightMouseButton(event)) {
        ToggleSelectionAction action = new ToggleSelectionAction(mapWidget, pixelTolerance);
        action.setPriorityToSelectedLayer(priorityToSelectedLayer);
        action.toggleSingle(getLocation(event, RenderSpace.SCREEN));
    }
}
项目:geomajas-project-client-gwt    文件:AbstractRectangleController.java   
/**
 * Finish selection using rectangle.
 * 
 * @param event
 *            event
 */
@Override
public void onUp(HumanInputEvent<?> event) {
    // assure dragging or clicking started inside this widget
    if (dragging) {
        doSelect(event);
    }
}
项目:geomajas-project-client-gwt    文件:AbstractRectangleController.java   
private void doSelect(HumanInputEvent<?> event) {
    dragging = false;
    shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
    updateRectangle(event);

    WorldViewTransformer transformer = new WorldViewTransformer(mapWidget.getMapModel().getMapView());
    Bbox worldBounds = transformer.viewToWorld(bounds);
    selectRectangle(worldBounds);

    mapWidget.render(rectangle, RenderGroup.SCREEN, RenderStatus.DELETE);
}
项目:geomajas-project-client-gwt    文件:AbstractRectangleController.java   
@Override
public void onDrag(HumanInputEvent<?> event) {
    if (dragging) {
        updateRectangle(event);
        mapWidget.render(rectangle, RenderGroup.SCREEN, RenderStatus.UPDATE);
    }
}