本文整理匯總了Java中javafx.scene.input.MouseEvent.getScreenX方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseEvent.getScreenX方法的具體用法?Java MouseEvent.getScreenX怎麽用?Java MouseEvent.getScreenX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.input.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.getScreenX方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: press
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
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();
}
}
}
示例2: drag
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void drag(MouseEvent e) {
Node node = get();
if (isEnable() && pressedCorner != null && e.isConsumed() == false && node != null) {
double dx = e.getScreenX() - startX;
if (pressedCorner.horizontal == HorizontalDirection.RIGHT) {
width.set(MathUtil.toRange(startWidth + dx, minWidth.get(), maxWidth.get()));
} else if (pressedCorner.horizontal == HorizontalDirection.LEFT) {
width.set(MathUtil.toRange(startWidth - dx, minWidth.get(), maxWidth.get()));
node.setLayoutX(startWidth + startPosX - width.get());
}
double dy = e.getScreenY() - startY;
if (pressedCorner.vertical == VerticalDirection.DOWN) {
height.set(MathUtil.toRange(startHeight + dy, minHeight.get(), maxHeight.get()));
} else if (pressedCorner.vertical == VerticalDirection.UP) {
height.set(MathUtil.toRange(startHeight - dy, minHeight.get(), maxHeight.get()));
node.setLayoutY(startHeight + startPosY - height.get());
}
e.consume();
}
}
示例3: onPressed
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onPressed(MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
xAtPress = resizerComponent.xProperty().get();
yAtPress = resizerComponent.yProperty().get();
widthAtPress = resizerComponent.widthProperty().get();
heightAtPress = resizerComponent.heightProperty().get();
screenXAtPress = event.getScreenX();
screenYAtPress = event.getScreenY();
lastScreenX = screenXAtPress;
lastScreenY = screenYAtPress;
panXAtPress = panningComponent.panXProperty().get();
panYAtPress = panningComponent.panYProperty().get();
dragActive = true;
if (onResizeStarted != null) {
onResizeStarted.run();
}
event.consume();
}
}
示例4: onMousePressed
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onMousePressed(MouseEvent event) {
// Don't start drag if shortcut is down because the node might be about to be deselected.
if (event.getButton() == MouseButton.PRIMARY && !event.isShortcutDown()) {
screenXAtPress = event.getScreenX();
screenYAtPress = event.getScreenY();
lastScreenX = screenXAtPress;
lastScreenY = screenYAtPress;
panXAtPress = panningComponent.panXProperty().get();
panYAtPress = panningComponent.panYProperty().get();
xAtPress = node.getLayoutX();
yAtPress = node.getLayoutY();
dragActive = true;
inertiaOvercome = false;
if (onDragStarted != null) {
onDragStarted.run();
}
event.consume();
}
}
示例5: onPressed
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onPressed(Node dragged, MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
dragActive = true;
inertiaOvercome = false;
nodeXOnPress = dragged.getLayoutX();
mouseXOnPress = event.getScreenX();
minWidthBackup = container.getMinWidth();
prefWidthBackup = container.getPrefWidth();
maxWidthBackup = container.getMaxWidth();
container.setMinWidth(container.getWidth());
container.setPrefWidth(container.getWidth());
container.setMaxWidth(container.getWidth());
translates = moveableChildren().collect(Collectors.toMap(Function.identity(), child -> new TranslateAnimation(child, dragged)));
moveableChildren().forEach(child -> child.setManaged(false));
// Move dragged node temporarily to front. Reset to original index on mouse release.
dragged.toFront();
}
}
示例6: press
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
@Override
public void press(MouseEvent e) {
Node node = get();
if (isEnable() && e.isConsumed() == false && node != null) {
Bounds boundsInLocal = node.getBoundsInLocal();
if (canDrag(node.screenToLocal(e.getScreenX(), e.getScreenY()), boundsInLocal.getMaxX(), boundsInLocal.getMaxY())) {
startX = e.getScreenX() - node.getLayoutX();
startY = e.getScreenY() - node.getLayoutY();
e.consume();
pressed = true;
}
}
}
示例7: onDragged
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onDragged(MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
if (dragActive) {
lastScreenX = event.getScreenX();
lastScreenY = event.getScreenY();
if (onResized != null && event.getSource() instanceof Region) {
Rectangle2D result = calculateNewSize((Region) event.getSource());
if (result != null) {
onResized.accept(result);
}
}
}
event.consume();
}
}
示例8: onMouseDragged
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onMouseDragged(MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
if (dragActive && (inertiaOvercome || isDraggedFarEnoughToOvercomeInertia(event.getScreenX(), event.getScreenY()))) {
inertiaOvercome = true;
lastScreenX = event.getScreenX();
lastScreenY = event.getScreenY();
if (onDragged != null) {
onDragged.accept(calculateDragDelta());
}
panIfOutsideAxisBounds(event);
}
event.consume();
}
}
示例9: panIfOutsideAxisBounds
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void panIfOutsideAxisBounds(MouseEvent event) {
Point2D rootOriginInScreen = panningComponent.getRoot().localToScreen(0, 0);
double mouseXRelativeToComponent = event.getScreenX() - rootOriginInScreen.getX();
double mouseYRelativeToComponent = event.getScreenY() - rootOriginInScreen.getY();
if (mouseXRelativeToComponent <= 0) {
if (!isRunning(timelineX)) {
startPanAnimation(-getAnimationSpeed(), timelineX, animatedPanX, panningComponent.panXProperty());
}
} else if (mouseXRelativeToComponent >= panningComponent.getRoot().getWidth()) {
if (!isRunning(timelineX)) {
startPanAnimation(getAnimationSpeed(), timelineX, animatedPanX, panningComponent.panXProperty());
}
} else {
timelineX.stop();
}
if (mouseYRelativeToComponent <= 0) {
if (!isRunning(timelineY)) {
startPanAnimation(-getAnimationSpeed(), timelineY, animatedPanY, panningComponent.panYProperty());
}
} else if (mouseYRelativeToComponent >= panningComponent.getRoot().getHeight()) {
if (!isRunning(timelineY)) {
startPanAnimation(getAnimationSpeed(), timelineY, animatedPanY, panningComponent.panYProperty());
}
} else {
timelineY.stop();
}
}
示例10: onMousePressed
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onMousePressed(MouseEvent event) {
if (event.getButton() == MouseButton.SECONDARY) {
contentXAtPress = view.getContent().getLayoutX();
contentYAtPress = view.getContent().getLayoutY();
screenXAtPress = event.getScreenX();
screenYAtPress = event.getScreenY();
setSceneCursor(Cursor.MOVE);
panningActive = true;
}
}
示例11: onMouseDragged
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void onMouseDragged(MouseEvent event) {
if (event.getButton() == MouseButton.SECONDARY && panningActive) {
double deltaX = event.getScreenX() - screenXAtPress;
double deltaY = event.getScreenY() - screenYAtPress;
view.getContent().setLayoutX(contentXAtPress + deltaX);
view.getContent().setLayoutY(contentYAtPress + deltaY);
}
}
示例12: handle
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
@Override
public void handle(MouseEvent event)
{
x = stage.getX() - event.getScreenX();
y = stage.getY() - event.getScreenY();
}
示例13: handleSingleClick
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void handleSingleClick(MouseEvent evt, Node node, LocalDate date) {
if (!(evt.getButton() == MouseButton.PRIMARY)) {
return;
}
YearMonthView view = getSkinnable();
switch (view.getClickBehaviour()) {
case NONE:
break;
case SHOW_DETAILS:
Callback<DateDetailsParameter, Boolean> callback = view.getDateDetailsCallback();
DateDetailsParameter param = new DateDetailsParameter(evt, view, node, date, evt.getScreenX(), evt.getScreenY());
callback.call(param);
break;
case PERFORM_SELECTION:
boolean multiSelect = evt.isShiftDown() || evt.isShortcutDown();
if (!multiSelect || (view.getSelectionMode().equals(SINGLE)
&& !evt.isControlDown())) {
view.getSelectedDates().clear();
}
if (evt.isShiftDown()) {
if (lastSelectedDate != null) {
LocalDate st = lastSelectedDate;
LocalDate et = date;
if (date.isBefore(st)) {
st = date;
et = lastSelectedDate;
}
do {
view.getSelectedDates().add(st);
st = st.plusDays(1);
} while (!et.isBefore(st));
} else {
view.getSelectedDates().clear();
view.getSelectedDates().add(date);
}
} else {
if (view.getSelectedDates().contains(date)) {
view.getSelectedDates().remove(date);
} else {
view.getSelectedDates().add(date);
}
}
lastSelectedDate = date;
if (!date.getMonth().equals(view.getYearMonth().getMonth())) {
view.setDate(date);
}
break;
default:
break;
}
}
示例14: calculateGap
import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
/**
* Calculating gap of location between the mouse and the stage on <i>Mouse Moving Event</i>.
* @param event
* @param stage
*/
private void calculateGap(MouseEvent event, Stage stage) {
gap_x = event.getScreenX() - stage.getX();
gap_y = event.getScreenY() - stage.getY();
}