当前位置: 首页>>代码示例>>Java>>正文


Java InputEvent.getSource方法代码示例

本文整理汇总了Java中javafx.scene.input.InputEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java InputEvent.getSource方法的具体用法?Java InputEvent.getSource怎么用?Java InputEvent.getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.input.InputEvent的用法示例。


在下文中一共展示了InputEvent.getSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTouchPressed

import javafx.scene.input.InputEvent; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:32,代码来源:SketchController.java

示例2: onTouchMoved

import javafx.scene.input.InputEvent; //导入方法依赖的package包/类
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);
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:30,代码来源:SketchController.java


注:本文中的javafx.scene.input.InputEvent.getSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。