Java Code Examples for javafx.scene.input.MouseEvent#getSource()

The following examples show how to use javafx.scene.input.MouseEvent#getSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RcmController.java    From ns-usbloader with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void selectPldrPane(MouseEvent mouseEvent) {
    final Node selectedPane = (Node)mouseEvent.getSource();

    switch (selectedPane.getId()){
        case "pldPane1":
            pldrRadio1.fire();
            break;
        case "pldPane2":
            pldrRadio2.fire();
            break;
        case "pldPane3":
            pldrRadio3.fire();
            break;
        case "pldPane4":
            pldrRadio4.fire();
            break;
        case "pldPane5":
            pldrRadio5.fire();
            break;
    }
}
 
Example 2
Source File: CalendarTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
private void checkClick(final MouseEvent EVENT) {
    Label  selectedLabel = ((Label) EVENT.getSource());
    String selectedText  = selectedLabel.getText();
    if (null == selectedText ||
        selectedText.isEmpty() ||
        !Character.isDigit(selectedText.charAt(0))) { return; }
    if (selectedLabel.getBorder() != null && selectedLabel.getBorder().equals(weekBorder)) { return; }
    int selectedNo = Integer.parseInt(selectedText);
    if (selectedNo > 31) { return; }

    List<ChartData>     dataList          = tile.getChartData();
    ZonedDateTime       time              = tile.getTime();
    LocalDate           selectedDate      = LocalDate.of(time.getYear(), time.getMonth(), selectedNo);
    Optional<ChartData> selectedChartData = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(selectedDate)).findAny();

    if (selectedChartData.isPresent()) { tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, selectedChartData.get())); }
}
 
Example 3
Source File: VuMeterSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
private void handleMouseEvent(final MouseEvent EVENT) {        
    if (active && MouseEvent.MOUSE_ENTERED == EVENT.getEventType()) {
        final Region SRC = (Region) EVENT.getSource();            
        if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
            for (int i = 0 ; i < leds.size() ; i++) {
                leds.get(i).getStyleClass().remove("led-on");
                if (i <= leds.indexOf(SRC)) {
                    leds.get(i).getStyleClass().add("led-on");
                }                
            }            
        } else {
            for (int i = 0 ; i < leds.size() ; i++) {
                leds.get(i).getStyleClass().remove("led-on");
                if (i >= leds.indexOf(SRC)) {
                    leds.get(i).getStyleClass().add("led-on");
                }
            }
        }
    }
}
 
Example 4
Source File: TimelineTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void handleMouseEvents(final MouseEvent e) {
    EventType type = e.getEventType();
    Circle    dot  = (Circle) e.getSource();
    ChartData data = dots.entrySet().stream().filter(entry -> entry.getValue().equals(dot)).map(entry -> entry.getKey()).findAny().orElse(null);
    if (MouseEvent.MOUSE_ENTERED.equals(type)) {
        if (null != data) {
            dotTooltip.setX(e.getScreenX());
            dotTooltip.setY(e.getScreenY());
            LocalDateTime localDateTime = LocalDateTime.ofInstant(data.getTimestamp(), tile.getZoneId());
            dotTooltip.setText(String.join("\n", DTF.format(localDateTime), String.format(tile.getLocale(), String.join(" ", formatString, tile.getUnit()), data.getValue())));
            dotTooltip.show(tile.getScene().getWindow());
        }
    } else if (MouseEvent.MOUSE_EXITED.equals(type)) {
        dotTooltip.hide();
    }
}
 
Example 5
Source File: CalendarTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void checkClick(final MouseEvent EVENT) {
    Label  selectedLabel = ((Label) EVENT.getSource());
    String selectedText  = selectedLabel.getText();
    if (null == selectedText ||
        selectedText.isEmpty() ||
        !Character.isDigit(selectedText.charAt(0))) { return; }
    if (selectedLabel.getBorder() != null && selectedLabel.getBorder().equals(weekBorder)) { return; }
    int selectedNo = Integer.parseInt(selectedText);
    if (selectedNo > 31) { return; }

    List<ChartData>     dataList          = tile.getChartData();
    ZonedDateTime       time              = tile.getTime();
    LocalDate           selectedDate      = LocalDate.of(time.getYear(), time.getMonth(), selectedNo);
    Optional<ChartData> selectedChartData = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(selectedDate)).findAny();

    if (selectedChartData.isPresent()) { tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, selectedChartData.get())); }
}
 
Example 6
Source File: CardListView.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	Card card = null;
	for (CardEntry cardEntry : existingCardEntries.values()) {
		if (event.getSource() == cardEntry) {
			card = cardEntry.getCard();
			break;
		}

	}
	if (card != null) {
		NotificationProxy.sendNotification(GameNotification.REMOVE_CARD_FROM_DECK, card);
	}
}
 
Example 7
Source File: PreferencesController.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Handle OK button clicked
 *
 * @param event
 */
@FXML
public void handleOKBtnClicked(final MouseEvent event) {
    Node node = (Node) event.getSource();
    Stage stage = (Stage) node.getScene().getWindow();
    savePreferences(stage);
}
 
Example 8
Source File: HumanMulliganView.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handle(MouseEvent mouseEvent) {
	CardTooltip cardWidget = (CardTooltip) mouseEvent.getSource();
	Card card = cardWidget.getCard();
	MulliganEntry entry = mulliganState.get(card);
	entry.mulligan = !entry.mulligan;
	entry.discardIcon.setVisible(entry.mulligan);
}
 
Example 9
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordRawMouseEvent(final RFXComponent r, MouseEvent e) {
    final JSONObject event = new JSONObject();
    event.put("type", "click_raw");
    int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
    event.put("button", button);
    event.put("clickCount", e.getClickCount());
    event.put("modifiersEx", buildModifiersText(e));
    Node source = (Node) e.getSource();
    Node target = r.getComponent();
    Point2D sts = source.localToScene(new Point2D(e.getX(), e.getY()));
    Point2D tts = target.sceneToLocal(sts);
    event.put("x", tts.getX());
    event.put("y", tts.getY());
    final JSONObject o = new JSONObject();
    o.put("event", event);
    fill(r, o);
    if (e.getClickCount() == 1) {
        clickTimer = new Timer();
        clickTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                sendRecordMessage(o);
            }
        }, timerinterval.intValue());
    } else if (e.getClickCount() == 2) {
        if (clickTimer != null) {
            clickTimer.cancel();
            clickTimer = null;
        }
        sendRecordMessage(o);
    }
}
 
Example 10
Source File: PopOver.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * マウスがこのアンカーノードに入るときに呼び出される関数を定義します。
 *
 * @param event {@link MouseEvent}
 */
protected void setOnMouseEntered(MouseEvent event) {
    Node anchorNode = (Node) event.getSource();
    Popup popup = this.initPopup(anchorNode);
    Bounds screen = anchorNode.localToScreen(anchorNode.getLayoutBounds());
    popup.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_LEFT);
    popup.show(anchorNode.getScene().getWindow(), screen.getMinX(), screen.getMaxY());
    this.setLocation(popup, anchorNode, event);
}
 
Example 11
Source File: CardAppleMouse.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
private void processMouseEvent(MouseEvent event) {
    if (event.getEventType() == MouseEvent.MOUSE_MOVED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        Node source = (Node) event.getSource();
        updateLocation(event.getSceneX(), event.getSceneY(), source.getBoundsInLocal());
        event.consume();
    }
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        mousePressed(event);
        event.consume();
    } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
        mouseReleased(event);
        event.consume();
    }
}
 
Example 12
Source File: RadialColorMenu.java    From RadialFx with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handle(final MouseEvent event) {
    final RadialMenuItem item = (RadialMenuItem) event.getSource();

    if (item == selected) {
	// do close
    } else if (selected != null) {
	// do replace
    } else {
	// do open
    }
    selected = item;
}
 
Example 13
Source File: Controller.java    From PoE_Level_Buddy with MIT License 5 votes vote down vote up
public void gemRewardBackward(MouseEvent mouseEvent)
{
    if (mouseEvent.getSource() instanceof ImageView)
    {
        ImageView imgView = (ImageView) mouseEvent.getSource();

        if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_ENTERED))
            imgView.setImage(new Image(getClass().getResource("ico/collapse1_hl.png").toString()));
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_EXITED))
            imgView.setImage(new Image(getClass().getResource("ico/collapse1.png").toString()));
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_CLICKED))
            setGemSelectionData(lastUsedPageHandler(false));
    }
}
 
Example 14
Source File: Controller.java    From PoE_Level_Buddy with MIT License 5 votes vote down vote up
/**
 * Hides the options when pressed.
 */
public void optionsArrow(MouseEvent mouseEvent)
{
    if (mouseEvent.getSource() instanceof ImageView)
    {
        ImageView imgView = (ImageView) mouseEvent.getSource();

        if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_ENTERED))
        {
            imgView.setImage(new Image(getClass().getResource("ico/collapse0_hl.png").toString()));
        }
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_EXITED))
        {
            imgView.setImage(new Image(getClass().getResource("ico/collapse0.png").toString()));
        }
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_CLICKED))
        {
            Settings.getINSTANCE().setBandits(comboBoxThatIsSelected());
            Settings.getINSTANCE().saveData();
            optionsAnchorPane.setVisible(false);
            optionsAnchorPaneMenu.setVisible(false);
            gemSelectorAnchorPane.setVisible(false);
            for (ImageView i : actArray)
                i.setVisible(false);
            inOptions = false;
            HelperZonePane.setVisible(true);
        }
    }
}
 
Example 15
Source File: RadialSettingsMenu.java    From RadialFx with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handle(final MouseEvent event) {
    final RadialMenuItem newSelectedItem = (RadialMenuItem) event
	    .getSource();

    if (selectedItem == newSelectedItem) {
	closeValueSelection(newSelectedItem);

    } else {
	openValueSelection(newSelectedItem);
    }
}
 
Example 16
Source File: Controller.java    From scan with GNU General Public License v3.0 5 votes vote down vote up
@FXML
private void clear(MouseEvent event) {
    Label label = (Label) event.getSource();
    Parent parent = label.getParent().getParent();
    ObservableList<Node> childrenUnmodifiable = parent.getChildrenUnmodifiable();
    for (Node node : childrenUnmodifiable) {
        if (node instanceof ListView) {
            ((ListView) node).getItems().clear();
        }
    }
}
 
Example 17
Source File: ApplicationController.java    From TerasologyLauncher with Apache License 2.0 4 votes vote down vote up
@FXML
protected void handleControlButtonMouseExited(MouseEvent event) {
    final Node source = (Node) event.getSource();
    final Transition t = FXUtils.createScaleTransition(1, source);
    t.playFromStart();
}
 
Example 18
Source File: MetaDeckListView.java    From metastone with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	DeckEntry deckEntry = (DeckEntry) event.getSource();
	NotificationProxy.sendNotification(GameNotification.REMOVE_DECK_FROM_META_DECK, deckEntry.getDeck());
}
 
Example 19
Source File: RadialBargraphSkin.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private void handleMouseEvent(final MouseEvent MOUSE_EVENT) {
    final Object    SRC  = MOUSE_EVENT.getSource();
    final EventType TYPE = MOUSE_EVENT.getEventType();
    if (getSkinnable().isInteractive() && SRC.equals(threshold)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), thresholdRotate);
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC instanceof Marker) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), getSkinnable().getMarkers().get(SRC));
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(minMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(maxMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
 
Example 20
Source File: CardView.java    From metastone with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	CardTooltip source = (CardTooltip) event.getSource();
	Card card = source.getCard();
	NotificationProxy.sendNotification(GameNotification.ADD_CARD_TO_DECK, card);
}