Java 类javafx.scene.input.TouchEvent 实例源码

项目:octoBubbles    文件:CreateNodeController.java   
public void onTouchPressed(TouchEvent event){
    Rectangle dragRectangle = new Rectangle();
    dragRectangle.setFill(null);
    dragRectangle.setStroke(Color.BLACK);

    if(event.getSource() instanceof AbstractNodeView){
        dragRectangle.setX(event.getTouchPoint().getX() + ((AbstractNodeView) event.getSource()).getX());
        dragRectangle.setY(event.getTouchPoint().getY() + ((AbstractNodeView) event.getSource()).getY());
        dragStarts.put(event.getTouchPoint().getId(), new Point2D(
                event.getTouchPoint().getX() + ((AbstractNodeView) event.getSource()).getX()
                , event.getTouchPoint().getY() + ((AbstractNodeView) event.getSource()).getY()));

    } else {
        dragRectangle.setX(event.getTouchPoint().getX());
        dragRectangle.setY(event.getTouchPoint().getY());
        dragStarts.put(event.getTouchPoint().getId(), new Point2D(event.getTouchPoint().getX(), event.getTouchPoint().getY()));
    }

    dragRectangles.put(event.getTouchPoint().getId(), dragRectangle);
    aDrawPane.getChildren().add(dragRectangle);
}
项目:octoBubbles    文件:CreateNodeController.java   
public void onTouchDragged(TouchEvent event){
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    Point2D startPoint = dragStarts.get(event.getTouchPoint().getId());

    if(event.getSource() instanceof AbstractNodeView){
        dragRectangle.setWidth(Math.abs(((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX() - startPoint.getX()));
        dragRectangle.setHeight(Math.abs(((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY() - startPoint.getY()));
        dragRectangle.setX(Math.min(startPoint.getX(), ((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX()));
        dragRectangle.setY(Math.min(startPoint.getY(), ((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY()));


    } else {
        dragRectangle.setWidth(Math.abs(startPoint.getX() - event.getTouchPoint().getX()));
        dragRectangle.setHeight(Math.abs(startPoint.getY() - event.getTouchPoint().getY()));
        dragRectangle.setX(Math.min(startPoint.getX(), event.getTouchPoint().getX()));
        dragRectangle.setY(Math.min(startPoint.getY(), event.getTouchPoint().getY()));

    }
}
项目:OctoUML    文件:CreateNodeController.java   
public void onTouchPressed(TouchEvent event){
    Rectangle dragRectangle = new Rectangle();
    dragRectangle.setFill(null);
    dragRectangle.setStroke(Color.BLACK);

    if(event.getSource() instanceof AbstractNodeView){
        dragRectangle.setX(event.getTouchPoint().getX() + ((AbstractNodeView) event.getSource()).getX());
        dragRectangle.setY(event.getTouchPoint().getY() + ((AbstractNodeView) event.getSource()).getY());
        dragStarts.put(event.getTouchPoint().getId(), new Point2D(
                event.getTouchPoint().getX() + ((AbstractNodeView) event.getSource()).getX()
                , event.getTouchPoint().getY() + ((AbstractNodeView) event.getSource()).getY()));

    } else {
        dragRectangle.setX(event.getTouchPoint().getX());
        dragRectangle.setY(event.getTouchPoint().getY());
        dragStarts.put(event.getTouchPoint().getId(), new Point2D(event.getTouchPoint().getX(), event.getTouchPoint().getY()));
    }

    dragRectangles.put(event.getTouchPoint().getId(), dragRectangle);
    aDrawPane.getChildren().add(dragRectangle);
}
项目:OctoUML    文件:CreateNodeController.java   
public void onTouchDragged(TouchEvent event){
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    Point2D startPoint = dragStarts.get(event.getTouchPoint().getId());

    if(event.getSource() instanceof AbstractNodeView){
        dragRectangle.setWidth(Math.abs(((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX() - startPoint.getX()));
        dragRectangle.setHeight(Math.abs(((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY() - startPoint.getY()));
        dragRectangle.setX(Math.min(startPoint.getX(), ((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX()));
        dragRectangle.setY(Math.min(startPoint.getY(), ((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY()));


    } else {
        dragRectangle.setWidth(Math.abs(startPoint.getX() - event.getTouchPoint().getX()));
        dragRectangle.setHeight(Math.abs(startPoint.getY() - event.getTouchPoint().getY()));
        dragRectangle.setX(Math.min(startPoint.getX(), event.getTouchPoint().getX()));
        dragRectangle.setY(Math.min(startPoint.getY(), event.getTouchPoint().getY()));

    }
}
项目:viskell    文件:CircleMenu.java   
/**
 * @param name of the button
 * @param image node shown on the button
 */
private MenuButton(String name, Node image) {
    super();
    Circle backing = new Circle(0, 0, 32, Color.GOLD);
    backing.setEffect(new DropShadow(20, 5, 5, Color.BLACK));
    backing.setStroke(Color.BLACK);
    backing.setStrokeWidth(1);
    this.getChildren().addAll(backing, image);
    this.setPrefSize(64, 64);
    this.setPickOnBounds(false);

    this.wasPressed = false;

    this.addEventHandler(MouseEvent.MOUSE_PRESSED, this::onPress);
    this.addEventHandler(TouchEvent.TOUCH_PRESSED, this::onPress);
    this.addEventHandler(MouseEvent.MOUSE_RELEASED, this::onRelease);
    this.addEventHandler(TouchEvent.TOUCH_RELEASED, this::onRelease);
}
项目:viskell    文件:DrawWire.java   
private void handleTouchRelease(TouchEvent event) {
    this.dragStarted = false;
    long fingerCount = event.getTouchPoints().stream().filter(tp -> tp.belongsTo(this)).count();

    if (fingerCount == 1 && DrawWire.this.menu == null) {
        Node picked = event.getTouchPoint().getPickResult().getIntersectedNode();
        DrawWire.this.handleReleaseOn(picked);
    } else if (DrawWire.this.menu != null || this.touchID < 0) {
        // avoid accidental creation of (more) menus
    } else if (fingerCount == 2) {
        DrawWire.this.showMenu(false);
        // a delay to avoid the background picking up jitter from this event
        Timeline delay = new Timeline(new KeyFrame(Duration.millis(250), e -> this.makeVisible()));
        delay.play();
    }

    event.consume();
}
项目:viskell    文件:SliderBlock.java   
/**
 * Constructs a new SliderBlock
 * @param pane The parent pane this Block resides on.
 * @param isIntegral wWhether this slider represent an integral value.
 */
public SliderBlock(ToplevelPane pane, boolean isIntegral) {
    super("SliderBlock", pane, pane.getEnvInstance().buildType(isIntegral ? "Num a => a" : "Fractional a => a"));

    this.isIntegral = isIntegral;
    this.baseValue = 0;
    this.slider.setValue(0);
    this.updateValue();

    slider.getStyleClass().add("inactive");
    slider.setOnMousePressed(e -> slider.getStyleClass().removeAll("inactive"));
    slider.setOnMouseReleased(e -> slider.getStyleClass().add("inactive"));
    slider.setOnTouchPressed(e -> slider.getStyleClass().removeAll("inactive"));
    slider.setOnTouchReleased(e -> slider.getStyleClass().add("inactive"));

    slider.valueProperty().addListener(ev -> this.updateValue());
    slider.valueChangingProperty().addListener(ev -> this.toggleSliding());

    slider.addEventHandler(TouchEvent.TOUCH_MOVED, Event::consume);
}
项目:viskell    文件:ConnectionAnchor.java   
/**
 * @param block The block this ConnectionAnchor belongs to.
 */
public ConnectionAnchor(Block block) {
    this.block = block;
    this.wireInProgress = null;
    this.eventRedirectionTarget = null;

    this.addEventHandler(MouseEvent.MOUSE_PRESSED, this::handleMousePress);
    this.addEventHandler(MouseEvent.MOUSE_DRAGGED, event -> {
        if (this.eventRedirectionTarget != null && !event.isSynthesized()) {
            this.eventRedirectionTarget.handleMouseDrag(event);
        }
        event.consume();
    });
    this.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> {
        if (this.eventRedirectionTarget != null && !event.isSynthesized()) {
            this.eventRedirectionTarget.handleMouseRelease(event);
            this.eventRedirectionTarget = null;
        }
        event.consume();
    });

    this.addEventHandler(TouchEvent.TOUCH_PRESSED, this::handleTouchPress);
}
项目:FXImgurUploader    文件:HeatControlSkin.java   
private void handleTouchEvent(final TouchEvent TOUCH_EVENT) {
    final Object    SRC  = TOUCH_EVENT.getSource();
    final EventType TYPE = TOUCH_EVENT.getEventType();
    if (SRC.equals(targetIndicator)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getTarget()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(),
                        targetIndicatorRotate);
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            getSkinnable().setTarget(Double.parseDouble(value.getText()));
            fadeBack();
        }
    }
}
项目:Augendiagnose    文件:SizableImageView.java   
/**
 * Handle a touch event.
 *
 * @param event
 *            The touch event.
 */
private void handleTouchEvent(final TouchEvent event) {
    if (event.getEventType().equals(TouchEvent.TOUCH_PRESSED)) {
        mTouchCount = event.getTouchCount();
    }
    else if (event.getEventType().equals(TouchEvent.TOUCH_RELEASED)) {
        // getTouchCount gives the number of touch points before the release.
        mTouchCount = event.getTouchCount() - 1;
    }

    if (mTouchCount > 1) {
        List<TouchPoint> touchPoints = event.getTouchPoints();
        double sumX = 0;
        double sumY = 0;
        for (TouchPoint point : touchPoints) {
            sumX += point.getX();
            sumY += point.getY();
        }
        mTouchXProperty.set(sumX / touchPoints.size());
        mTouchYProperty.set(sumY / touchPoints.size());
    }
}
项目:Enzo    文件:HeatControlSkin.java   
private void handleTouchEvent(final TouchEvent TOUCH_EVENT) {
    final Object    SRC  = TOUCH_EVENT.getSource();
    final EventType TYPE = TOUCH_EVENT.getEventType();
    if (SRC.equals(targetIndicator)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getTarget()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(),
                        targetIndicatorRotate);
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            getSkinnable().setTarget(Double.parseDouble(value.getText()));
            fadeBack();
        }
    }
}
项目:octoBubbles    文件:CreateNodeController.java   
public void onTouchReleasedClass(TouchEvent event)
{
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    diagramController.createNodeView(new ClassNode(dragRectangle.getX(), dragRectangle.getY(),
            dragRectangle.getWidth(), dragRectangle.getHeight()), false);
    finish(dragRectangle);

}
项目:octoBubbles    文件:CreateNodeController.java   
public void onTouchReleasedEnumeration(TouchEvent event)
{
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    diagramController.createNodeView(new EnumerationNode(dragRectangle.getX(), dragRectangle.getY(),
            dragRectangle.getWidth(), dragRectangle.getHeight()), false);
    finish(dragRectangle);

}
项目:octoBubbles    文件:CreateNodeController.java   
/**
 * @kaanburaksener
 * This method has to be reviewed!
 * createNodeView should take PackageNode as a parameter NOT ClassNode.
 */
public void onTouchReleasedPackage(TouchEvent event)
{
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    diagramController.createNodeView(new PackageNode(dragRectangle.getX(), dragRectangle.getY(),
            dragRectangle.getWidth(), dragRectangle.getHeight()), false);
    finish(dragRectangle);
}
项目:octoBubbles    文件:SketchController.java   
public void onTouchPressed(InputEvent event) {
    Sketch sketch = new Sketch();
    mController.addSketch(sketch, false, false);

    double x, y;
    if(event instanceof TouchEvent){
        x = ((TouchEvent) event).getTouchPoint().getX();
        y = ((TouchEvent) event).getTouchPoint().getY();
    } else { //event instanceof mouseevent
        x = ((MouseEvent)event).getX();
        y = ((MouseEvent)event).getY();
    }

    double xPoint;
    double yPoint;
    if(event.getSource() instanceof AbstractNodeView){
        xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + x;
        yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + y;
    } else {
        xPoint = x;
        yPoint = y;
    }
    sketch.setColor(color);
    sketch.setStart(xPoint, yPoint);

    if(event instanceof TouchEvent) {
        currentSketches.put(((TouchEvent)event).getTouchPoint().getId(), sketch);
    } else { //event instanceof mouseevent
        currentSketch = sketch;
    }
}
项目:octoBubbles    文件:SketchController.java   
public void onTouchMoved(InputEvent event) {
    Sketch sketch;
    double xPoint;
    double yPoint;

    if(event instanceof TouchEvent){
        sketch = currentSketches.get(((TouchEvent)event).getTouchPoint().getId());

        if(event.getSource() instanceof AbstractNodeView){
            xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((TouchEvent)event).getTouchPoint().getX();
            yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((TouchEvent)event).getTouchPoint().getY();
        } else {
            xPoint = ((TouchEvent)event).getTouchPoint().getX();
            yPoint = ((TouchEvent)event).getTouchPoint().getY();
        }
    } else { //event instanceof mouseevent
        sketch = currentSketch;

        if(event.getSource() instanceof AbstractNodeView){
            xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((MouseEvent)event).getX();
            yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((MouseEvent)event).getY();
        } else {
            xPoint = ((MouseEvent)event).getX();
            yPoint = ((MouseEvent)event).getY();
        }
    }

    sketch.addPoint(xPoint, yPoint);
}
项目:OctoUML    文件:CreateNodeController.java   
public void onTouchReleasedClass(TouchEvent event)
{
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    diagramController.createNodeView(new ClassNode(dragRectangle.getX(), dragRectangle.getY(),
            dragRectangle.getWidth(), dragRectangle.getHeight()), false);
    finish(dragRectangle);

}
项目:OctoUML    文件:CreateNodeController.java   
public void onTouchReleasedPackage(TouchEvent event)
{
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    diagramController.createNodeView(new PackageNode(dragRectangle.getX(), dragRectangle.getY(),
            dragRectangle.getWidth(), dragRectangle.getHeight()), false);
    finish(dragRectangle);

}
项目:OctoUML    文件:SketchController.java   
public void onTouchPressed(InputEvent event) {
    Sketch sketch = new Sketch();
    mController.addSketch(sketch, false, false);

    double x, y;
    if(event instanceof TouchEvent){
        x = ((TouchEvent) event).getTouchPoint().getX();
        y = ((TouchEvent) event).getTouchPoint().getY();
    } else { //event instanceof mouseevent
        x = ((MouseEvent)event).getX();
        y = ((MouseEvent)event).getY();
    }

    double xPoint;
    double yPoint;
    if(event.getSource() instanceof AbstractNodeView){
        xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + x;
        yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + y;
    } else {
        xPoint = x;
        yPoint = y;
    }
    sketch.setColor(color);
    sketch.setStart(xPoint, yPoint);

    if(event instanceof TouchEvent) {
        currentSketches.put(((TouchEvent)event).getTouchPoint().getId(), sketch);
    } else { //event instanceof mouseevent
        currentSketch = sketch;
    }
}
项目:OctoUML    文件:SketchController.java   
public void onTouchMoved(InputEvent event) {
    Sketch sketch;
    double xPoint;
    double yPoint;

    if(event instanceof TouchEvent){
        sketch = currentSketches.get(((TouchEvent)event).getTouchPoint().getId());

        if(event.getSource() instanceof AbstractNodeView){
            xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((TouchEvent)event).getTouchPoint().getX();
            yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((TouchEvent)event).getTouchPoint().getY();
        } else {
            xPoint = ((TouchEvent)event).getTouchPoint().getX();
            yPoint = ((TouchEvent)event).getTouchPoint().getY();
        }
    } else { //event instanceof mouseevent
        sketch = currentSketch;

        if(event.getSource() instanceof AbstractNodeView){
            xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((MouseEvent)event).getX();
            yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((MouseEvent)event).getY();
        } else {
            xPoint = ((MouseEvent)event).getX();
            yPoint = ((MouseEvent)event).getY();
        }
    }

    sketch.addPoint(xPoint, yPoint);
}
项目:viskell    文件:TouchContext.java   
public TouchContext(BlockContainer container, boolean willPanTouchArea) {
    super();
    this.container = container;
    this.willPanTouchArea = willPanTouchArea;

    this.lastPanPosition = Point2D.ZERO;
    this.panning = false;
    this.panningAction = null;

    container.asNode().addEventHandler(MouseEvent.MOUSE_PRESSED, this::handleMousePress);
    container.asNode().addEventHandler(MouseEvent.MOUSE_DRAGGED, this::handleMouseDrag);
    container.asNode().addEventHandler(MouseEvent.MOUSE_RELEASED, this::handleMouseRelease);
    container.asNode().addEventHandler(TouchEvent.TOUCH_PRESSED, this::handleTouchPress);
    container.asNode().addEventHandler(ScrollEvent.SCROLL, this::handleScrollGesture);
}
项目:viskell    文件:TouchContext.java   
/**
 * @param touchPoint that is the center of new active touch area.
 */
private TouchArea(TouchPoint touchPoint) {
    super();
    this.toplevel = TouchContext.this.container.getToplevel();
    this.touchID = touchPoint.getId();
    this.dragStarted = false;
    this.menuCreated = false;

    Point2D pos = this.toplevel.sceneToLocal(touchPoint.getSceneX(), touchPoint.getSceneY());
    this.setCenterX(pos.getX());
    this.setCenterY(pos.getY());
    this.setRadius(100);
    this.setFill(Color.TRANSPARENT);

    this.removeDelay = new Timeline(new KeyFrame(Duration.millis(250), this::remove));
    this.menuDelay = new Timeline(new KeyFrame(Duration.millis(200), this::finishMenu));

    this.wireCutter = new Line(pos.getX(), pos.getY(), pos.getX(), pos.getY());
    this.wireCutter.setStroke(Color.YELLOW);
    this.wireCutter.setStrokeWidth(3);
    this.wireCutter.setVisible(false);
    this.toplevel.addUpperTouchArea(this.wireCutter);

    touchPoint.grab(this);
    this.addEventHandler(TouchEvent.TOUCH_RELEASED, this::handleRelease);
    this.addEventHandler(TouchEvent.TOUCH_PRESSED, this::handlePress);
    this.addEventHandler(TouchEvent.TOUCH_MOVED, this::handleDrag);
}
项目:viskell    文件:TouchContext.java   
private void handlePress(TouchEvent event) {
    // this might have been a drag glitch, so halt release actions
    this.removeDelay.stop();
    if (event.getTouchPoints().stream().filter(tp -> tp.belongsTo(this)).count() == 2) {
        this.menuDelay.stop();
        this.removeCutter();
    }
    event.consume();
}
项目:viskell    文件:TouchContext.java   
private void handleRelease(TouchEvent event) {
    long fingerCount = event.getTouchPoints().stream().filter(tp -> tp.belongsTo(this)).count();

    if (fingerCount == 1) {
        // trigger area removal timer
        this.removeDelay.play();
    } else if (this.dragStarted || this.menuCreated) {
        // avoid accidental creation of (more) menus
    } else if (fingerCount == 2) {
        // trigger menu creation timer
        this.menuDelay.play();
    }

    event.consume();
}
项目:viskell    文件:TouchContext.java   
private void handleDrag(TouchEvent event) {
    TouchPoint touchPoint = event.getTouchPoint();

    if (event.getTouchPoint().getId() != this.touchID) {
        // we use only primary finger for drag movement
    } else if (event.getTouchPoints().stream().filter(tp -> tp.belongsTo(this)).count() < 2) {
        // not a multi finger drag
        this.updateCutter(this.toplevel.sceneToLocal(touchPoint.getSceneX(), touchPoint.getSceneY()));
    } else {
        double deltaX = touchPoint.getX() - this.getCenterX();
        double deltaY = touchPoint.getY() - this.getCenterY();

        if (Math.abs(deltaX) + Math.abs(deltaY) < 2) {
            // ignore very small movements
        } else if ((deltaX*deltaX + deltaY*deltaY) > 10000) {
            // FIXME: ignore too large movements
        } else if (this.dragStarted || (deltaX*deltaX + deltaY*deltaY) > 63) {
            this.dragStarted = true;
            if (TouchContext.this.panningAction != null) {
                TouchContext.this.panningAction.accept(deltaX, deltaY);
                if (!TouchContext.this.willPanTouchArea) {
                    this.setLayoutX(this.getLayoutX() + deltaX);
                    this.setLayoutY(this.getLayoutY() + deltaY);
                }
            }
        }
    }

    event.consume();
}
项目:viskell    文件:LambdaBlock.java   
public void editSignature() {
    String input = this.definitionName.getText().isEmpty() ? "example" : this.definitionName.getText();
    if (this.explicitSignature.isPresent()) {
        input += " :: " + this.explicitSignature.get().prettyPrint();
    }

    TextInputDialog dialog = new TextInputDialog(input);
    dialog.setTitle("Edit lambda signature");
    dialog.setHeaderText("Set the name and optionally the type");

    Optional<String> result = dialog.showAndWait();
    result.ifPresent(signature -> {
        if (! this.definitionName.isVisible()) {
            this.definitionName.addEventHandler(MouseEvent.MOUSE_RELEASED, this::createFunctionUseBlock);
            this.definitionName.addEventHandler(TouchEvent.TOUCH_RELEASED, this::createFunctionUseBlock);
        }

        List<String> parts = Splitter.on(" :: ").splitToList(signature);
        if (parts.size() < 2) {
            this.definitionName.setText(signature);
            this.definitionName.setVisible(true);
        } else {
            this.definitionName.setText(parts.get(0));
            this.definitionName.setVisible(true);
            // FIXME: what to do in case type parsing fail?
            Type type = this.getToplevel().getEnvInstance().buildType(parts.get(1));
            if (type.countArguments() >= this.body.argCount()) {
                this.explicitSignature = Optional.of(type);
                this.signature.setText(type.prettyPrint());
                this.body.enforceExplicitType(type);
                this.initiateConnectionChanges();
            }
        }
    });
}
项目:viskell    文件:DrawWire.java   
/**
 * @param touchPoint that is the center of new active touch area, or null if the mouse
 */
private TouchArea(TouchPoint touchPoint) {
    super();
    this.setLayoutX(DrawWire.this.getEndX());
    this.setLayoutY(DrawWire.this.getEndY());

    this.touchID = touchPoint == null ? -1 : touchPoint.getId();
    this.dragStarted = true;
    this.nearbyAnchors = new ArrayList<>();
    this.lastNearbyUpdate = Point2D.ZERO;

    this.disapperance = new Timeline(new KeyFrame(Duration.millis(2000),
            e -> DrawWire.this.remove(),
            new KeyValue(this.opacityProperty(), 0.3),
            new KeyValue(DrawWire.this.opacityProperty(), 0.2)));

    // a circle with hole is built from a path of round arcs with a very thick stroke
    ArcTo arc1 = new ArcTo(100, 100, 0, 100, 0, true, true);
    ArcTo arc2 = new ArcTo(100, 100, 0, -100, 0, true, true);
    this.getElements().addAll(new MoveTo(-100, 0), arc1, arc2, new ClosePath());
    this.setStroke(Color.web("#0066FF"));
    this.setStrokeType(StrokeType.INSIDE);
    this.setStrokeWidth(90);
    this.setStroke(Color.web("#0066FF"));
    this.setStrokeType(StrokeType.INSIDE);
    this.setOpacity(0);

    if (touchPoint != null) { 
        touchPoint.grab(this);
    }

    this.addEventHandler(TouchEvent.TOUCH_PRESSED, this::handleTouchPress);
    this.addEventHandler(TouchEvent.TOUCH_MOVED, this::handleTouchDrag);
    this.addEventHandler(TouchEvent.TOUCH_RELEASED, this::handleTouchRelease);
    this.addEventHandler(MouseEvent.MOUSE_PRESSED, this::handleMousePress);
    this.addEventHandler(MouseEvent.MOUSE_DRAGGED, this::handleMouseDrag);
    this.addEventHandler(MouseEvent.MOUSE_RELEASED, this::handleMouseRelease);
}
项目:viskell    文件:DrawWire.java   
private void handleTouchPress(TouchEvent event) {
    if (!this.dragStarted) {
        this.touchID = event.getTouchPoint().getId();
        this.disapperance.stop();
        this.makeVisible();
    }
    event.consume();
}
项目:viskell    文件:DrawWire.java   
private void handleTouchDrag(TouchEvent event) {
    double scaleFactor = this.getScaleX();
    double deltaX = event.getTouchPoint().getX() * scaleFactor;
    double deltaY = event.getTouchPoint().getY() * scaleFactor;

    if (event.getTouchPoint().getId() != this.touchID) {
        // we use only primary finger for drag movement
        if (this.dragStarted && Math.abs(deltaX) > 175) {
            this.horizontalSplittingAction(event);
        } else if (this.dragStarted && Math.abs(deltaY) > 150){
            this.verticalSplittingAction(event);
        }
    } else {

        if ((deltaX*deltaX + deltaY*deltaY) > 10000) {
            // FIXME: ignore too large movements
        } else if (this.dragStarted || (deltaX*deltaX + deltaY*deltaY) > 63) {
            if (!this.dragStarted) {
                this.handleDragStart();
            }

            double newX = this.getLayoutX() + deltaX;
            double newY = this.getLayoutY() + deltaY;
            this.dragTo(newX, newY, event.getTouchPoint().getPickResult().getIntersectedNode());
        }
    }

    event.consume();
}
项目:robovm-samples    文件:DialogPopup.java   
private void installDismissEventHandler(Window window) {
    oldEventDispatcher = window.getEventDispatcher();
    window.setEventDispatcher((event, tail) -> {
        EventType<?> eventType = event.getEventType();
        if (eventType == MouseEvent.MOUSE_PRESSED 
                || eventType == TouchEvent.TOUCH_PRESSED) {
            // Dismiss
            hide();
        } else {
            // Event in the popup window.
            tail.dispatchEvent(event);
        }
        return null;
    });
}
项目:Fishification    文件:RefreshButton.java   
@Override
public void handle(Event event) {

    EventType eventType = event.getEventType();
    if (eventType != MouseEvent.MOUSE_PRESSED && eventType != TouchEvent.TOUCH_PRESSED) {
        return;
    }

    // remove contents
    m_fishWorld.clearAll();

    // load contents
    m_fishWorld.loadFishContents();
}
项目:octoBubbles    文件:SketchController.java   
public void onTouchReleased(InputEvent event) {
    if(event instanceof TouchEvent) {
        currentSketches.remove(((TouchEvent) event).getTouchPoint().getId());
    }
}
项目:OctoUML    文件:CreateNodeController.java   
public void onTouchReleasedLifeline(TouchEvent event){
     Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
     diagramController.createNodeView(new SequenceObject(dragRectangle.getX(), dragRectangle.getY(),
             dragRectangle.getWidth(), dragRectangle.getHeight()), false);
     finish(dragRectangle);
}
项目:OctoUML    文件:SketchController.java   
public void onTouchReleased(InputEvent event) {
    if(event instanceof TouchEvent) {
        currentSketches.remove(((TouchEvent) event).getTouchPoint().getId());
    }
}
项目:viskell    文件:DragContext.java   
/** Make the attached Node stop acting on drag actions by removing drag event handlers */
public void removeDragEventHandlers() {
    node.removeEventHandler(TouchEvent.ANY, touchHandler);
    node.removeEventHandler(MouseEvent.ANY, mouseHandler);
}
项目:viskell    文件:TouchContext.java   
private void handleTouchPress(TouchEvent e) {
    this.container.getToplevel().addLowerTouchArea(new TouchArea(e.getTouchPoint()));
    e.consume();
}
项目:viskell    文件:ConnectionAnchor.java   
private void handleTouchPress(TouchEvent event) {
    if (this.wireInProgress == null) {
        DrawWire.initiate(this, event.getTouchPoint());
    }
    event.consume();
}
项目:FXImgurUploader    文件:RadialBargraphSkin.java   
private void handleTouchEvent(final TouchEvent TOUCH_EVENT) {
    final Object    SRC  = TOUCH_EVENT.getSource();
    final EventType TYPE = TOUCH_EVENT.getEventType();
    if (SRC.equals(threshold)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(), thresholdRotate);
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC instanceof Marker) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(), getSkinnable().getMarkers().get(SRC));
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC.equals(minMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (SRC.equals(maxMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
项目:FXImgurUploader    文件:GaugeSkin.java   
private void handleTouchEvent(final TouchEvent TOUCH_EVENT) {
    final Object    SRC  = TOUCH_EVENT.getSource();
    final EventType TYPE = TOUCH_EVENT.getEventType();
    if (SRC.equals(threshold)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(), thresholdRotate);
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC instanceof Marker) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(), getSkinnable().getMarkers().get(SRC));
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC.equals(minMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (SRC.equals(maxMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
项目:Enzo    文件:RadialBargraphSkin.java   
private void handleTouchEvent(final TouchEvent TOUCH_EVENT) {
    final Object    SRC  = TOUCH_EVENT.getSource();
    final EventType TYPE = TOUCH_EVENT.getEventType();
    if (SRC.equals(threshold)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(), thresholdRotate);
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC instanceof Marker) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_MOVED == TYPE) {
            touchRotate(TOUCH_EVENT.getTouchPoint().getSceneX() - getSkinnable().getLayoutX(), TOUCH_EVENT.getTouchPoint().getSceneY() - getSkinnable().getLayoutY(), getSkinnable().getMarkers().get(SRC));
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (SRC.equals(minMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (SRC.equals(maxMeasuredValue)) {
        if (TouchEvent.TOUCH_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (TouchEvent.TOUCH_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}