Java Code Examples for javafx.scene.input.MouseEvent

The following are top voted examples for showing how to use javafx.scene.input.MouseEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: drd   File: ItemArmorController.java   Source Code and License 9 votes vote down vote up
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();
    }
}
 
Example 2
Project: WebPLP   File: EmulationWindow.java   Source Code and License 8 votes vote down vote up
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));
}
 
Example 3
Project: marathonv5   File: RFXButtonBaseTest.java   Source Code and License 6 votes vote down vote up
@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));
}
 
Example 4
Project: charts   File: HeatMapTest.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 5
Project: shuffleboard   File: TileDragResizer.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 6
Project: fx-animation-editor   File: SelectionBoxComponent.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 7
Project: LivroJavaComoProgramar10Edicao   File: PolyShapesController.java   Source Code and License 6 votes vote down vote up
@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);
   }
}
 
Example 8
Project: lttng-scope   File: ExampleMouseDrag2.java   Source Code and License 6 votes vote down vote up
@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();

}
 
Example 9
Project: WebPLP   File: ProjectExplorerTree.java   Source Code and License 6 votes vote down vote up
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);
		}
	}
}
 
Example 10
Project: UDE   File: Icon.java   Source Code and License 6 votes vote down vote up
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);
                    }
                }
            }
        }
    });
}
 
Example 11
Project: marathonv5   File: EventQueueDeviceMouseTest.java   Source Code and License 6 votes vote down vote up
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());
}
 
Example 12
Project: dialog-tool   File: RaiseEventTransitionController.java   Source Code and License 6 votes vote down vote up
@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();
        }
    });
}
 
Example 13
Project: javafx-dataviewer   File: ImageToggleButton.java   Source Code and License 6 votes vote down vote up
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;
			}
		}
	});
}
 
Example 14
Project: JavaFX-EX   File: ResizeSupport.java   Source Code and License 6 votes vote down vote up
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();
    }
  }
}
 
Example 15
Project: Suji   File: GamePlay.java   Source Code and License 5 votes vote down vote up
@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()));
	}
}
 
Example 16
Project: dragdropfx   File: TextDragListenerContext.java   Source Code and License 5 votes vote down vote up
private EventHandler<MouseEvent> makeOnButtonUpListener(){
	return new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			if(event.getButton() == MouseButton.PRIMARY && inClick){
				inClick = false;
				currentSelection = null;
			}
		}
	};
}
 
Example 17
Project: GazePlay   File: Target.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 18
Project: FEFEditor   File: FilledSliderSkin.java   Source Code and License 5 votes vote down vote up
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));
        }
    }
}
 
Example 19
Project: JavaFX-EX   File: DragSupport.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 20
Project: Money-Manager   File: MakeATransactionController.java   Source Code and License 5 votes vote down vote up
@FXML
private void anchorPaneAction(MouseEvent ev) {
	try {
		gmlblWarningMsg.setText("");
		exlblWarningMsg.setText("");
	} catch (Exception e) {}
}
 
Example 21
Project: GazePlay   File: Circles_points_handler2.java   Source Code and License 5 votes vote down vote up
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);

            }
        }
    };

}
 
Example 22
Project: hygene   File: BasicSettingsViewController.java   Source Code and License 5 votes vote down vote up
/**
 * 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 + ".");
    });
}
 
Example 23
Project: GazePlay   File: GameContext.java   Source Code and License 5 votes vote down vote up
public HomeButton createHomeButtonInGameScreen(@NonNull GazePlay gazePlay, @NonNull Stats stats) {
    HomeButton homeButton = new HomeButton();

    EventHandler<Event> homeEvent = new EventHandler<javafx.event.Event>() {
        @Override
        public void handle(javafx.event.Event e) {

            if (e.getEventType() == MouseEvent.MOUSE_CLICKED) {

                scene.setCursor(Cursor.WAIT); // Change cursor to wait style

                stats.stop();
                GazeUtils.clear();

                log.info("stats = " + stats);

                Runnable asynchronousStatsPersistTask = new Runnable() {
                    @Override
                    public void run() {
                        stats.saveStats();
                    }
                };
                Thread asynchronousStatsPersistThread = new Thread(asynchronousStatsPersistTask);
                asynchronousStatsPersistThread.start();

                StatsContext statsContext = StatsContext.newInstance(gazePlay, stats);

                gazePlay.onDisplayStats(statsContext);

                scene.setCursor(Cursor.DEFAULT); // Change cursor to default style
            }
        }
    };

    homeButton.addEventHandler(MouseEvent.MOUSE_CLICKED, homeEvent);

    // homeButton.recomputeSizeAndPosition(scene);
    menuHBox.getChildren().add(homeButton);

    return homeButton;
}
 
Example 24
Project: Curriculum-design-of-data-structure   File: ShowMazeController.java   Source Code and License 5 votes vote down vote up
@FXML
        private void okAction(MouseEvent e){
//            findWay = false;
//            byte[][] temp = maze.mazeDataCopy();
//
//            if(maze.findPath()){
                findAccess(labyrinth, 0, 0);
                findAccess = false;
//        }
//        else{
//            showDialog("该迷宫无法找出出路");
//        }
    }
 
Example 25
Project: fxexperience2   File: RotatorControl.java   Source Code and License 5 votes vote down vote up
@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));
}
 
Example 26
Project: Hive_Game   File: ControllerButtonPiece.java   Source Code and License 5 votes vote down vote up
@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()));
}
}
 
Example 27
Project: fx-animation-editor   File: RotatorDialComponent.java   Source Code and License 5 votes vote down vote up
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();
        }
    }
}
 
Example 28
Project: GazePlay   File: Bubble.java   Source Code and License 5 votes vote down vote up
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();
            }
        }
    };

}
 
Example 29
Project: lttng-scope   File: ExampleMouseDrag.java   Source Code and License 5 votes vote down vote up
@Override
public void handle(MouseEvent t) {
    orgSceneX = t.getSceneX();
    orgSceneY = t.getSceneY();
    orgTranslateX = ((Circle)(t.getSource())).getTranslateX();
    orgTranslateY = ((Circle)(t.getSource())).getTranslateY();
}
 
Example 30
Project: lttng-scope   File: ExampleMouseDrag.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 31
Project: dialog-tool   File: TransitionPaneController.java   Source Code and License 5 votes vote down vote up
@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();
    });
}
 
Example 32
Project: dotmatrix   File: DotMatrix.java   Source Code and License 5 votes vote down vote up
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;
            }
        }
    }
}
 
Example 33
Project: Mafia-TCoS-CS319-Group2A   File: LaunderingController.java   Source Code and License 5 votes vote down vote up
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));
            }
        }
    }
}
 
Example 34
Project: GazePlay   File: Target.java   Source Code and License 5 votes vote down vote up
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();
            }
        });
    }
 
Example 35
Project: stvs   File: TimingDiagramCollectionController.java   Source Code and License 5 votes vote down vote up
/**
 * 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()));
}
 
Example 36
Project: H-Uppaal   File: EdgeController.java   Source Code and License 5 votes vote down vote up
@FXML
public void edgePressed(final MouseEvent event) {
    if (!event.isShiftDown()) {
        event.consume();

        if (event.isShortcutDown()) {
            SelectHelper.addToSelection(this);
        } else {
            SelectHelper.select(this);
        }
    }
}
 
Example 37
Project: jmonkeybuilder   File: AbstractListCell.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 38
Project: GazePlay   File: Card.java   Source Code and License 5 votes vote down vote up
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);
            }
        }
    };
}
 
Example 39
Project: JavaFX-EX   File: DragSupport.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 40
Project: WebPLP   File: OutlineView.java   Source Code and License 5 votes vote down vote up
private void onTreeClick(MouseEvent event)
{
	if (event.getClickCount() == 2)
	{
		if (onAction != null)
		{
			PLPLabel selection = getActiveSelection();
			if (selection == null)
				return;
			else
				onAction.accept(selection);
		}
	}
}