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

项目:drd    文件:ItemArmorController.java   
public void handleSelectImage(MouseEvent mouseEvent) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(imageChooserTitle);
    fileChooser.getExtensionFilters().add(new ExtensionFilter("PNG", "*.png"));
    final File file = fileChooser
        .showOpenDialog(((Node) mouseEvent.getSource()).getScene().getWindow());
    if (file == null) {
        return;
    }

    try {
        final byte[] image = ImageUtils.readImage(file);
        model.imageRaw.set(image);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:marathonv5    文件:RFXButtonBaseTest.java   
@Test public void getText() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
            text.add(rfxButtonBase.getAttribute("text"));
        }
    });
    new Wait("Waiting for button text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Color", text.get(0));
}
项目:charts    文件:HeatMapTest.java   
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(heatMap);

    // Setup a mouse event filter which adds spots to the heatmap as soon as the mouse will be moved across the pane
    pane.addEventFilter(MouseEvent.MOUSE_MOVED, event -> {
        double x = event.getX();
        double y = event.getY();
        if (x < heatMap.getSpotRadius()) x = heatMap.getSpotRadius();
        if (x > pane.getWidth() - heatMap.getSpotRadius()) x = pane.getWidth() - heatMap.getSpotRadius();
        if (y < heatMap.getSpotRadius()) y = heatMap.getSpotRadius();
        if (y > pane.getHeight() - heatMap.getSpotRadius()) y = pane.getHeight() - heatMap.getSpotRadius();

        heatMap.addSpot(x, y);
    });
    pane.widthProperty().addListener((ov, oldWidth, newWidth) -> heatMap.setSize(newWidth.doubleValue(), pane.getHeight()));
    pane.heightProperty().addListener((ov, oldHeight, newHeight) -> heatMap.setSize(pane.getWidth(), newHeight.doubleValue()));

    Scene scene = new Scene(pane, 400, 400);

    stage.setTitle("HeatMap (move mouse over pane)");
    stage.setScene(scene);
    stage.show();
}
项目:shuffleboard    文件:TileDragResizer.java   
private void mousePressed(MouseEvent event) {
  // ignore clicks outside of the draggable margin
  if (!isInDraggableZone(event)) {
    return;
  }

  dragging = true;

  // make sure that the minimum size is set to the current size once;
  // setting a min size that is smaller than the current size will have no effect
  if (!didDragInit) {
    tile.setMinHeight(tile.getHeight());
    tile.setMinWidth(tile.getWidth());
    didDragInit = true;
  }

  lastX = event.getX();
  lastY = event.getY();
  ResizeUtils.setCurrentTile(tile);
  TileLayout layout = tilePane.getTileLayout(tile);
  tilePane.setHighlight(true);
  tilePane.setHighlightSize(layout.size);
  tilePane.setHighlightPoint(layout.origin);
}
项目:fx-animation-editor    文件:SelectionBoxComponent.java   
private void onBackgroundDragged(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && dragActive) {
        double x = event.getX() - panningComponent.panXProperty().get();
        double y = event.getY() - panningComponent.panYProperty().get();

        double minX = Math.min(x, xAtPress);
        double minY = Math.min(y, yAtPress);
        double maxX = Math.max(x, xAtPress);
        double maxY = Math.max(y, yAtPress);

        root.setVisible(true);
        root.setLayoutX(minX);
        root.setLayoutY(minY);
        root.setWidth(maxX - minX);
        root.setHeight(maxY - minY);
    }
}
项目:WebPLP    文件:EmulationWindow.java   
private static void setButtonEffect(Node node)
{
    DropShadow rollOverColor = new DropShadow();
    rollOverColor.setColor(Color.ORANGERED);
    DropShadow clickColor = new DropShadow();
    clickColor.setColor(Color.DARKBLUE);

    node.addEventHandler(MouseEvent.MOUSE_ENTERED,
            (event) -> node.setEffect(rollOverColor));

    // Removing the shadow when the mouse cursor is off
    node.addEventHandler(MouseEvent.MOUSE_EXITED, (event) -> node.setEffect(null));

    // Darken shadow on click
    node.addEventHandler(MouseEvent.MOUSE_PRESSED,
            (event) -> node.setEffect(clickColor));

    // Restore hover style on click end
    node.addEventHandler(MouseEvent.MOUSE_RELEASED,
            (event) -> node.setEffect(rollOverColor));
}
项目:LivroJavaComoProgramar10Edicao    文件:PolyShapesController.java   
@FXML
private void drawingAreaMouseClicked(MouseEvent e)
{
   polyline.getPoints().addAll(e.getX(), e.getY());
   polygon.getPoints().addAll(e.getX(), e.getY());

   // if path is empty, move to first click position and close path
   if (path.getElements().isEmpty())
   {
      path.getElements().add(new MoveTo(e.getX(), e.getY()));
      path.getElements().add(new ClosePath());      
   }
   else // insert a new path segment before the ClosePath element
   {
      // create an arc segment and insert it in the path
      ArcTo arcTo = new ArcTo();
      arcTo.setX(e.getX());
      arcTo.setY(e.getY());
      arcTo.setRadiusX(100.0);
      arcTo.setRadiusY(100.0);
      arcTo.setSweepFlag(sweepFlag);
      sweepFlag = !sweepFlag;
      path.getElements().add(path.getElements().size() - 1, arcTo);
   }
}
项目:lttng-scope    文件:ExampleMouseDrag2.java   
@Override
public void handle(MouseEvent event) {

    double offsetX = event.getSceneX() - dragContext.mouseAnchorX;
    double offsetY = event.getSceneY() - dragContext.mouseAnchorY;

    if( offsetX > 0) {
        rect.setWidth( offsetX);
    } else {
        rect.setX(event.getSceneX());
        rect.setWidth(dragContext.mouseAnchorX - rect.getX());
    }

    if( offsetY > 0) {
        rect.setHeight( offsetY);
    } else {
        rect.setY(event.getSceneY());
        rect.setHeight(dragContext.mouseAnchorY - rect.getY());
    }

    event.consume();

}
项目:WebPLP    文件:ProjectExplorerTree.java   
private void onTreeClick(MouseEvent event)
{
    if (event.getClickCount() == 2)
    {
        if (onFileDoubleClicked != null)
        {
            Pair<Project, ASMFile> selection = getActiveSelection();
            if (selection == null)
                return;

            ASMFile selectedFile = selection.getValue();
            if (selectedFile != null)
                onFileDoubleClicked.accept(selectedFile);
        }
    }
}
项目:UDE    文件:Icon.java   
private void setIconEvents() {
    icon.addEventFilter(MouseEvent.MOUSE_PRESSED,
        new EventHandler<MouseEvent>() {
        @Override public void handle(MouseEvent click) {
            if (click.getClickCount() == 2) {
                click.consume();
                if (isDir == true) {
                    System.out.println(path);
                    setTabView(path, tilePane, txtDirPath);
                } else if (isImage == true) {
                    openImage();
                } else {
                    try {
                        System.out.println(runCommand);
                        pb = Runtime.getRuntime().exec(runCommand);
                    } catch(Throwable imgIOErr) {
                        System.out.println(imgIOErr);
                    }
                }
            }
        }
    });
}
项目:marathonv5    文件:EventQueueDeviceMouseTest.java   
public void testMouseMoveCoordinatesLongLong() {
    EventQueueWait.requestFocus(button);
    final StringBuilder text = new StringBuilder();
    button.addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() {
        @Override public void handle(MouseEvent e) {
            if (e.getEventType() == MouseEvent.MOUSE_DRAGGED) {
                text.append("dragged ");
            }
            if (e.getEventType() == MouseEvent.MOUSE_MOVED) {
                text.append("moved(" + e.getX() + "," + e.getY() + ") ");
            }
        }
    });
    driver.moveto(button, 3, 3);
    driver.moveto(button, 5, 10);
    final String expected = "moved(3.0,3.0) moved(5.0,10.0)";
    new WaitWithoutException() {
        @Override public boolean until() {
            return expected.equals(text.toString().trim());
        }
    }.wait("Text is empty", 3000, 500);
    AssertJUnit.assertEquals(expected, text.toString().trim());
}
项目:dialog-tool    文件:RaiseEventTransitionController.java   
@Override
public void init(Stage stage, Scene scene, Pane pane) {
    addButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            //add transition

            String eventName = eventNameTextField.getText();

            if (eventName.isEmpty()) {
                return;
            }

            RaiseEventTransition transition = new RaiseEventTransition(eventName);
            entry.getTranstionList(index).add(transition);

            //refresh listview
            paneController.refreshListView();

            stage.close();
        }
    });
}
项目:javafx-dataviewer    文件:ImageToggleButton.java   
public ImageToggleButton(String imageurl) {
    setGraphic(new ImageView(new Image(getClass().getResourceAsStream(imageurl))));
    setStyle(STYLE_NORMAL);

    setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (toggle) {
                setStyle(STYLE_NORMAL);
                toggle = false;
            } else {
                setStyle(STYLE_PRESSED);
                toggle = true;
            }
        }
    });
}
项目:JavaFX-EX    文件:ResizeSupport.java   
private void press(MouseEvent e) {
  Node node = get();
  if (isEnable() && e.isConsumed() == false && node != null) {
    Corner corner = calcCorner(e);
    if (corner != Corner.CENTER) {
      pressedCorner = corner;
      startX = e.getScreenX();
      startY = e.getScreenY();
      startWidth = width.get() == -1 ? node.prefWidth(-1) : width.get();
      startHeight = height.get() == -1 ? node.prefHeight(-1) : height.get();
      startPosX = node.getLayoutX();
      startPosY = node.getLayoutY();
      e.consume();
    }
  }
}
项目:Suji    文件:GamePlay.java   
@Override
public void canvasClicked(MouseEvent mouseEvent) {
    DrawCoords mousePosition = new DrawCoords(mouseEvent.getX(), mouseEvent.getY());
    CoordProjector projector = getProjector(boardCanvas);
    Coords boardPos = projector.nearestCoords(mousePosition);

    if ( !projector.isWithinBounds(mousePosition) )
        return;

    if ( game.isLegalMove(play(boardPos, getTurnPlayer())) ) {
        game.playMove(play(boardPos, getTurnPlayer()));
    }
}
项目:dragdropfx    文件:TextDragListenerContext.java   
private EventHandler<MouseEvent> makeOnButtonUpListener(){
    return new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if(event.getButton() == MouseButton.PRIMARY && inClick){
                inClick = false;
                currentSelection = null;
            }
        }
    };
}
项目:GazePlay    文件:Target.java   
public Position getPointerPosition(Event e) {
    double mousePositionX = 0;
    double mousePositionY = 0;
    if (e instanceof MouseEvent) {
        MouseEvent mouseEvent = (MouseEvent) e;
        mousePositionX = mouseEvent.getX();
        mousePositionY = mouseEvent.getY();
    }
    if (e instanceof GazeEvent) {
        GazeEvent gazeEvent = (GazeEvent) e;
        mousePositionX = gazeEvent.getX();
        mousePositionY = gazeEvent.getY();
    }
    return new Position((int) mousePositionX, (int) mousePositionY);
}
项目:FEFEditor    文件:FilledSliderSkin.java   
private void mouseDraggedOnTrack(MouseEvent mouseEvent) {
    if (!thumb.isPressed()) {
        if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) {
            getBehavior().trackPress(mouseEvent, (mouseEvent.getX() / trackLength));
        } else {
            getBehavior().trackPress(mouseEvent, (mouseEvent.getY() / trackLength));
        }
    }
}
项目:JavaFX-EX    文件:DragSupport.java   
public static DragConfig bind(Node node) {
  node.addEventHandler(MouseEvent.MOUSE_PRESSED, press);
  node.addEventHandler(MouseEvent.MOUSE_DRAGGED, drag);
  node.addEventHandler(MouseEvent.MOUSE_RELEASED, release);
  DragHandle dragConfig = new NodeDrag(node);
  map.put(node, dragConfig);
  return dragConfig;
}
项目:Money-Manager    文件:MakeATransactionController.java   
@FXML
private void anchorPaneAction(MouseEvent ev) {
    try {
        gmlblWarningMsg.setText("");
        exlblWarningMsg.setText("");
    } catch (Exception e) {}
}
项目:GazePlay    文件:Circles_points_handler2.java   
private  EventHandler<Event> buildEvent() {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {



            if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                System.out.println("I eggcited");
                entry = (new Date()).getTime();
                indicator.setVisible(true);
                indicator.setOpacity(1);
                circle.setOpacity(0.5);

            }
            else if (e.getEventType() == MouseEvent.MOUSE_MOVED || e.getEventType() == GazeEvent.GAZE_MOVED) {

                System.out.println("I moved");
                indicator.setVisible(true);
                indicator.setOpacity(1);
                circle.setOpacity(0.5);
                long now = (new Date()).getTime();
                indicator.setProgress((now - entry)/min_time);
                System.out.println((now - entry)/min_time);
                if((now - entry)>min_time && entry != -1){
                    createAnimation();
                }

            } else if (e.getEventType() == MouseEvent.MOUSE_EXITED || e.getEventType() == GazeEvent.GAZE_EXITED) {

                entry = -1;
                indicator.setOpacity(1);
                circle.setOpacity(1);

            }
        }
    };

}
项目:hygene    文件:BasicSettingsViewController.java   
/**
 * When the user finishes sliding the panning sensitivity {@link Slider}.
 *
 * @param mouseEvent the {@link MouseEvent}
 */
@FXML
void panningSensitivitySliderDone(final MouseEvent mouseEvent) {
    settings.addRunnable(() -> {
        final double newValue = ((Slider) mouseEvent.getSource()).getValue();
        graphMovementCalculator.getPanningSensitivityProperty().setValue(newValue);
        LOGGER.info("Panning sensitivity has been set to " + newValue + ".");
    });
}
项目:Curriculum-design-of-data-structure    文件:ShowMazeController.java   
@FXML
        private void okAction(MouseEvent e){
//            findWay = false;
//            byte[][] temp = maze.mazeDataCopy();
//
//            if(maze.findPath()){
                findAccess(labyrinth, 0, 0);
                findAccess = false;
//        }
//        else{
//            showDialog("该迷宫无法找出出路");
//        }
    }
项目:fxexperience2    文件:RotatorControl.java   
@FXML void rotatorMouseDragged(MouseEvent e) {
    final Parent p = rotator_dial.getParent();
    final Bounds b = rotator_dial.getLayoutBounds();
    final Double centerX = b.getMinX() + (b.getWidth() / 2);
    final Double centerY = b.getMinY() + (b.getHeight() / 2);
    final Point2D center = p.localToParent(centerX, centerY);
    final Point2D mouse = p.localToParent(e.getX(), e.getY());
    final Double deltaX = mouse.getX() - center.getX();
    final Double deltaY = mouse.getY() - center.getY();
    final Double radians = Math.atan2(deltaY, deltaX);
    rotate(Math.toDegrees(radians));
}
项目:Hive_Game    文件:ControllerButtonPiece.java   
@Override
public void handle(MouseEvent t) {
    if(!gameController.isFreeze() && gameController.getCore().getState() == Consts.WAIT_FOR_INPUT){
        /* Ajout */
        gameController.resetPiece();
        gameController.getInventoryGroup().getToggles().get(indexOfButtonInInventory).setSelected(true);
        /**/
        gameController.setPieceToChoose(indexPiece);
        gameController.getHighlighted().setListTohighlight(gameController.getCore().getPossibleAdd(gameController.getCore().getCurrentPlayer()));
}
}
项目:fx-animation-editor    文件:RotatorDialComponent.java   
private void updateRotation(MouseEvent event) {
    if (!value.isBound()) {
        double mouseToCenterX = event.getX() - button.getWidth() / 2;
        double mouseToCenterY = event.getY() -  button.getHeight() / 2;
        double angle = Math.round(Math.toDegrees(Math.atan2(mouseToCenterY, mouseToCenterX)));
        double positiveAngle = angle < 0 ? angle + 360 : angle;
        setValue(positiveAngle);
        if (onChange != null) {
            onChange.run();
        }
    }
}
项目:GazePlay    文件:Bubble.java   
public Bubble(GameContext gameContext, BubbleType type, Stats stats, boolean useBackgroundImage) {
    this.gameContext = gameContext;
    this.type = type;
    this.stats = stats;
    this.image = useBackgroundImage;

    photos = Utils.images(Utils.getImagesFolder() + "portraits" + Utils.FILESEPARATOR);

    if (useBackgroundImage) {
        gameContext.getScene().setFill(new ImagePattern(new Image("data/bubble/images/underwater-treasures.jpg")));
    }

    gameContext.getChildren().add(this);

    this.fragments = buildFragments(type);

    this.getChildren().addAll(fragments);

    enterEvent = new EventHandler<Event>() {
        @Override
        public void handle(Event e) {

            if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                // log.info(e.getEventType());
                enter((Circle) e.getTarget());
                stats.incNbGoals();
                stats.start();
            }
        }
    };

}
项目:lttng-scope    文件:ExampleMouseDrag.java   
@Override
public void handle(MouseEvent t) {
    orgSceneX = t.getSceneX();
    orgSceneY = t.getSceneY();
    orgTranslateX = ((Circle)(t.getSource())).getTranslateX();
    orgTranslateY = ((Circle)(t.getSource())).getTranslateY();
}
项目:lttng-scope    文件:ExampleMouseDrag.java   
@Override
public void handle(MouseEvent t) {
    double offsetX = t.getSceneX() - orgSceneX;
    double offsetY = t.getSceneY() - orgSceneY;
    double newTranslateX = orgTranslateX + offsetX;
    double newTranslateY = orgTranslateY + offsetY;

    ((Circle)(t.getSource())).setTranslateX(newTranslateX);
    ((Circle)(t.getSource())).setTranslateY(newTranslateY);
}
项目:dialog-tool    文件:TransitionPaneController.java   
@Override
public void init(Stage stage, Scene scene, Pane pane) {
    this.stage = stage;

    //create list with all transition types
    ObservableList<String> list = FXCollections.observableArrayList();

    for (String typeName : Transition.listTransitionTypeNames()) {
        list.add(typeName);
    }

    //set transition types to choice box
    typeChoiceBox.setItems(list);
    typeChoiceBox.getSelectionModel().select(0);

    addTransitionButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            String selectedType = typeChoiceBox.getSelectionModel().getSelectedItem();

            try {
                addTransition(Transition.getTransitionByTitle(selectedType).getType());
            } catch (Exception e) {
                JavaFXUtils.showErrorDialog("Cannot create transition", "Cannot create transition, maybe transition isnt supported yet. Please contact developers!");

                return;
            }
        }
    });

    Platform.runLater(() -> {
        refreshListView();
    });
}
项目:dotmatrix    文件:DotMatrix.java   
private void checkForClick(final MouseEvent EVT) {
    double spacerPlusPixelWidthMinusDoubleSpacer  = spacer + dotWidthMinusDoubleSpacer;
    double spacerPlusPixelHeightMinusDoubleSpacer = spacer + dotHeightMinusDoubleSpacer;
    for (int y = 0; y < rows; y++) {
        for (int x = 0; x < cols; x++) {
            if (isInRectangle(EVT.getX(), EVT.getY(), x * dotWidth + spacer, y * dotHeight + spacer, x * dotWidth + spacerPlusPixelWidthMinusDoubleSpacer, y * dotHeight + spacerPlusPixelHeightMinusDoubleSpacer)) {
                fireDotMatrixEvent(new DotMatrixEvent(x, y, EVT.getScreenX(), EVT.getScreenY()));
                break;
            }
        }
    }
}
项目:Mafia-TCoS-CS319-Group2A    文件:LaunderingController.java   
public void buyClicked(MouseEvent mouseEvent) {
    JFXButton button = (JFXButton) mouseEvent.getSource();
    JFXRadioButton selectedRadio = (JFXRadioButton)group.getSelectedToggle();
    String launderingTool = selectedRadio.getText();
    if ((button).getText().equals("Buy!")){
        for(int i = 0; i < crimeSize; i++)
        {
            if(selectedRadio.getText().equals(GameEngine.getCrimes.get(i).getDescription()))
            {
                GameEngine.purchaseAsset(GameEngine.getCrimes.get(i));
            }
        }
    }
}
项目:GazePlay    文件:Target.java   
private void enter() {

        this.removeEventHandler(MouseEvent.MOUSE_ENTERED, enterEvent);

        hand.fireEvent(new net.gazeplay.games.creampie.event.TouchEvent(getCenterX(), getCenterY()));

        Timeline timeline = new Timeline();
        Timeline timeline2 = new Timeline();

        timeline.getKeyFrames()
                .add(new KeyFrame(new Duration(2000), new KeyValue(radiusProperty(), getInitialRadius() * 1.6)));
        timeline.getKeyFrames()
                .add(new KeyFrame(new Duration(2000), new KeyValue(rotateProperty(), getRotate() + (360 * 3))));
        timeline.getKeyFrames().add(new KeyFrame(new Duration(2000), new KeyValue(visibleProperty(), false)));

        timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(radiusProperty(), radius)));

        Position newPosition = randomPositionGenerator.newRandomPosition(getInitialRadius());

        timeline2.getKeyFrames()
                .add(new KeyFrame(new Duration(1), new KeyValue(centerXProperty(), newPosition.getX())));
        timeline2.getKeyFrames()
                .add(new KeyFrame(new Duration(1), new KeyValue(centerYProperty(), newPosition.getY())));
        timeline2.getKeyFrames().add(new KeyFrame(new Duration(1),
                new KeyValue(fillProperty(), new ImagePattern(pickRandomImage(availableImages), 0, 0, 1, 1, true))));
        timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(rotateProperty(), 0)));
        timeline2.getKeyFrames().add(new KeyFrame(new Duration(1000), new KeyValue(visibleProperty(), true)));

        SequentialTransition sequence = new SequentialTransition(timeline, timeline2);
        sequence.play();
        sequence.setOnFinished(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

                anniOff = true;
                stats.start();
            }
        });
    }
项目:stvs    文件:TimingDiagramCollectionController.java   
/**
 * Handles drag events on xAxis.
 *
 * @param event mouse event
 */
private void mouseDraggedHandler(MouseEvent event) {
  Point2D point2D = getView().sceneToLocal(event.getSceneX(), event.getScreenY());
  double newXPosition = point2D.getX();
  double delta = newXPosition - dragState.startXPosition;
  double deltaAsAxis = delta * dragState.screenDistanceToAxisRatio;
  if (dragState.startLowerBound - deltaAsAxis < 0) {
    deltaAsAxis = dragState.startLowerBound;
  }
  NumberAxis xaxis = getView().getXaxis();
  xaxis.setLowerBound(Math.max(dragState.startLowerBound - deltaAsAxis, 0));
  xaxis.setUpperBound(Math.max(dragState.startUpperBound - deltaAsAxis, visibleRange.get()));
}
项目:H-Uppaal    文件:EdgeController.java   
@FXML
public void edgePressed(final MouseEvent event) {
    if (!event.isShiftDown()) {
        event.consume();

        if (event.isShortcutDown()) {
            SelectHelper.addToSelection(this);
        } else {
            SelectHelper.select(this);
        }
    }
}
项目:jmonkeybuilder    文件:AbstractListCell.java   
public AbstractListCell() {
    this.content = new HBox();
    this.text = new Label();
    this.visibleIcon = new ImageView();
    this.visibleIcon.addEventFilter(MouseEvent.MOUSE_RELEASED, this::processHide);
    this.visibleIcon.setOnMouseReleased(this::processHide);
    this.visibleIcon.setPickOnBounds(true);

    FXUtils.addToPane(visibleIcon, content);
    FXUtils.addToPane(text, content);

    setEditable(false);

    FXUtils.addClassTo(content, CSSClasses.DEF_HBOX);
}
项目:GazePlay    文件:Card.java   
private EventHandler<Event> buildEvent() {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {

            if (turned)
                return;

            if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                progressIndicator.setOpacity(1);
                progressIndicator.setProgress(0);

                Timeline timelineCard = new Timeline();

                timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.xProperty(), card.getX() - (initWidth * zoom_factor - initWidth) / 2)));
                timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.yProperty(), card.getY() - (initHeight * zoom_factor - initHeight) / 2)));
                timelineCard.getKeyFrames().add(
                        new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth * zoom_factor)));
                timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.heightProperty(), initHeight * zoom_factor)));

                timelineProgressBar = new Timeline();

                timelineProgressBar.getKeyFrames().add(new KeyFrame(new Duration(fixationlength),
                        new KeyValue(progressIndicator.progressProperty(), 1)));

                timelineCard.play();

                timelineProgressBar.play();

                timelineProgressBar.setOnFinished(new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent actionEvent) {

                        turned = true;

                        card.setFill(new ImagePattern(image, 0, 0, 1, 1, true));

                        card.removeEventFilter(MouseEvent.ANY, enterEvent);
                        card.removeEventFilter(GazeEvent.ANY, enterEvent);

                        if (winner) {
                            onCorrectCardSelected();
                        } else {// bad card
                            onWrongCardSelected();
                        }
                    }
                });
            } else if (e.getEventType() == MouseEvent.MOUSE_EXITED || e.getEventType() == GazeEvent.GAZE_EXITED) {

                Timeline timeline = new Timeline();

                timeline.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.xProperty(), card.getX() + (initWidth * zoom_factor - initWidth) / 2)));
                timeline.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.yProperty(), card.getY() + (initHeight * zoom_factor - initHeight) / 2)));
                timeline.getKeyFrames()
                        .add(new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth)));
                timeline.getKeyFrames()
                        .add(new KeyFrame(new Duration(1), new KeyValue(card.heightProperty(), initHeight)));

                timeline.play();

                timelineProgressBar.stop();

                progressIndicator.setOpacity(0);
                progressIndicator.setProgress(0);
            }
        }
    };
}
项目:JavaFX-EX    文件:DragSupport.java   
public static DragConfig bind(Window window) {
  window.addEventHandler(MouseEvent.MOUSE_PRESSED, press);
  window.addEventHandler(MouseEvent.MOUSE_DRAGGED, drag);
  window.addEventHandler(MouseEvent.MOUSE_RELEASED, release);
  DragHandle dragConfig = new WindowDrag(window);
  map.put(window, dragConfig);
  return dragConfig;
}
项目:WebPLP    文件:OutlineView.java   
private void onTreeClick(MouseEvent event)
{
    if (event.getClickCount() == 2)
    {
        if (onAction != null)
        {
            PLPLabel selection = getActiveSelection();
            if (selection == null)
                return;
            else
                onAction.accept(selection);
        }
    }
}
项目:CalendarFX    文件:AutoScrollPane.java   
/**
 * Constructs a new scrollpane for the given content node.
 *
 * @param content the content node
 */
public AutoScrollPane(Node content) {
    super(content);

    // regular drag, e.g. of an entry view
    addEventFilter(MouseEvent.MOUSE_DRAGGED, this::autoscrollIfNeeded);
    addEventFilter(MouseEvent.MOUSE_RELEASED, evt -> stopAutoScrollIfNeeded());

    // drag and drop from the outside
    addEventFilter(MouseEvent.DRAG_DETECTED, this::startDrag);
    addEventFilter(DragEvent.DRAG_OVER, this::autoscrollIfNeeded);
    addEventFilter(DragEvent.DRAG_EXITED, evt -> stopAutoScrollIfNeeded());
    addEventFilter(DragEvent.DRAG_DROPPED, evt -> stopAutoScrollIfNeeded());
    addEventFilter(DragEvent.DRAG_DONE, evt -> stopAutoScrollIfNeeded());
}