use of javafx.scene.input.KeyEvent in project jabref by JabRef.
the class KeyBindingsDialogViewModelTest method testInvalidKeyBindingIsNotSaved.
@Test
public void testInvalidKeyBindingIsNotSaved() {
setKeyBindingViewModel(KeyBinding.COPY);
KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_RELEASED, "Q", "Q", KeyCode.Q, false, false, false, false);
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent));
model.setNewBindingForCurrent(shortcutKeyEvent);
KeyCombination combination = KeyCombination.keyCombination(keyBindingRepository.get(KeyBinding.COPY).get());
assertFalse(keyBindingRepository.checkKeyCombinationEquality(combination, shortcutKeyEvent));
model.saveKeyBindings();
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent));
}
use of javafx.scene.input.KeyEvent in project jabref by JabRef.
the class KeyBindingsDialogViewModelTest method testKeyBindingCategory.
@Test
public void testKeyBindingCategory() {
KeyBindingViewModel bindViewModel = new KeyBindingViewModel(keyBindingRepository, KeyBindingCategory.FILE);
model.selectedKeyBindingProperty().set(bindViewModel);
KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "M", "M", KeyCode.M, true, true, true, false);
assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent));
model.setNewBindingForCurrent(shortcutKeyEvent);
assertNull(model.selectedKeyBindingProperty().get().getKeyBinding());
}
use of javafx.scene.input.KeyEvent in project Minesweeper3D by SethDamiani.
the class Main method createCube.
private void createCube(Group cubeGroup, Group gX, Group gY, Scene scene, Stage stage) {
cubeGroup.setTranslateZ(-200);
sideB.setTranslateX(200);
sideB.setTranslateZ(200);
sideB.setRotationAxis(new Point3D(0, 1, 0));
sideB.setRotate(90);
sideC.setTranslateZ(200);
sideC.setTranslateX(-200);
sideC.setRotationAxis(new Point3D(0, 1, 0));
sideC.setRotate(90);
sideD.setTranslateZ(400);
sideE.setRotationAxis(new Point3D(1, 0, 0));
sideE.setRotate(90);
sideE.setTranslateY(200);
sideE.setTranslateZ(200);
sideF.setRotationAxis(new Point3D(1, 0, 0));
sideF.setRotate(90);
sideF.setTranslateY(-200);
sideF.setTranslateZ(200);
RotateTransition rightRotate = new RotateTransition(Duration.millis(10000), gY);
rightRotate.setAxis(Rotate.Y_AXIS);
rightRotate.setByAngle(-1000);
rightRotate.setInterpolator(Interpolator.LINEAR);
RotateTransition leftRotate = new RotateTransition(Duration.millis(10000), gY);
leftRotate.setAxis(Rotate.Y_AXIS);
leftRotate.setByAngle(1000);
leftRotate.setInterpolator(Interpolator.LINEAR);
RotateTransition upRotate = new RotateTransition(Duration.millis(10000), gX);
upRotate.setAxis(Rotate.X_AXIS);
upRotate.setByAngle(-1000);
upRotate.setInterpolator(Interpolator.LINEAR);
RotateTransition downRotate = new RotateTransition(Duration.millis(10000), gX);
downRotate.setAxis(Rotate.X_AXIS);
downRotate.setByAngle(1000);
downRotate.setInterpolator(Interpolator.LINEAR);
EventHandler<KeyEvent> KeyPressHandler = event -> {
if (event.getCode() == KeyCode.ESCAPE) {
timeTask.pause();
stage.setScene(confirmExit);
} else if (event.getCode() == KeyCode.D || event.getCode() == KeyCode.RIGHT)
rightRotate.play();
else if (event.getCode() == KeyCode.A || event.getCode() == KeyCode.LEFT)
leftRotate.play();
else if (event.getCode() == KeyCode.W || event.getCode() == KeyCode.UP)
upRotate.play();
else if (event.getCode() == KeyCode.S || event.getCode() == KeyCode.DOWN)
downRotate.play();
};
scene.addEventHandler(KeyEvent.KEY_PRESSED, KeyPressHandler);
EventHandler<KeyEvent> KeyReleaseHandler = event -> {
if (event.getCode() == KeyCode.D || event.getCode() == KeyCode.RIGHT)
rightRotate.stop();
else if (event.getCode() == KeyCode.A || event.getCode() == KeyCode.LEFT)
leftRotate.stop();
else if (event.getCode() == KeyCode.W || event.getCode() == KeyCode.UP)
upRotate.stop();
else if (event.getCode() == KeyCode.S || event.getCode() == KeyCode.DOWN)
downRotate.stop();
};
scene.addEventHandler(KeyEvent.KEY_RELEASED, KeyReleaseHandler);
}
use of javafx.scene.input.KeyEvent in project trex-stateless-gui by cisco-system-traffic-generator.
the class TextFieldTableViewCell method call.
@Override
public TableCell call(TableColumn param) {
return new TableCell<S, T>() {
private TextField textField;
{
textField = new TextField();
textField.setPrefSize(158, 22);
textField.setOnKeyPressed((KeyEvent event) -> {
if (event.getCode().equals(KeyCode.ENTER)) {
commitEdit((T) textField.getText());
}
});
textField.focusedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (!newValue) {
commitEdit((T) textField.getText());
}
});
textField.textProperty().bindBidirectional(textProperty());
}
@Override
public void updateItem(final T item, final boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
setGraphic(textField);
setText((String) getItem());
}
}
@Override
public void commitEdit(T item) {
if (!isEditing() && !item.equals(getItem())) {
TableView<S> table = getTableView();
if (table != null) {
TableColumn<S, T> column = getTableColumn();
CellEditEvent<S, T> event = new CellEditEvent<>(table, new TablePosition<S, T>(table, getIndex(), column), TableColumn.editCommitEvent(), item);
Event.fireEvent(column, event);
}
}
super.commitEdit(item);
}
};
}
use of javafx.scene.input.KeyEvent in project jgnash by ccavanaugh.
the class JasperViewerDialogController method initialize.
@FXML
private void initialize() {
busyPane = new BusyPane();
stackPane.getChildren().add(busyPane);
screenResolution = Screen.getPrimary().getDpi();
saveButton.disableProperty().bind(jasperPrint.isNull());
printButton.disableProperty().bind(jasperPrint.isNull());
reportFormatButton.disableProperty().bind(jasperPrint.isNull());
fontSizeSpinner.disableProperty().bind(jasperPrint.isNull());
firstButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
previousButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
nextButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
lastButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
fitPageButton.disableProperty().bind(jasperPrint.isNull());
fitHeightButton.disableProperty().bind(jasperPrint.isNull());
fitWidthButton.disableProperty().bind(jasperPrint.isNull());
zoomComboBox.disableProperty().bind(jasperPrint.isNull());
zoomInButton.disableProperty().bind(jasperPrint.isNull().or(zoomProperty.greaterThanOrEqualTo(DEFAULT_ZOOMS[DEFAULT_ZOOMS.length - 1] / 100)));
zoomOutButton.disableProperty().bind(jasperPrint.isNull().or(zoomProperty.lessThanOrEqualTo(DEFAULT_ZOOMS[0] / 100)));
fitPageButton.setSelected(true);
firstButton.prefHeightProperty().bind(saveButton.heightProperty());
previousButton.prefHeightProperty().bind(saveButton.heightProperty());
nextButton.prefHeightProperty().bind(saveButton.heightProperty());
lastButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomInButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomOutButton.prefHeightProperty().bind(saveButton.heightProperty());
fitHeightButton.prefHeightProperty().bind(saveButton.heightProperty());
fitWidthButton.prefHeightProperty().bind(saveButton.heightProperty());
fitPageButton.prefHeightProperty().bind(saveButton.heightProperty());
fontSizeSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(5, 15, 7));
report.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
jasperPrint.set(newValue.createJasperPrint(false));
fontSizeSpinner.valueFactoryProperty().get().setValue(newValue.getBaseFontSize());
newValue.refreshCallBackProperty().set(() -> createJasperPrint(newValue));
} else {
jasperPrint.set(null);
}
});
jasperPrint.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
pageCount.set(newValue.getPages().size());
} else {
pageCount.set(0);
}
Platform.runLater(this::refresh);
});
reportControllerPaneProperty.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
reportControllerPane.getChildren().addAll(newValue);
}
});
fontSizeSpinner.valueProperty().addListener((observable, oldValue, newValue) -> {
report.get().setBaseFontSize(newValue);
Platform.runLater(() -> createJasperPrint(report.get()));
});
pagePane.setSpacing(PAGE_BORDER);
pagePane.setPadding(new Insets(PAGE_BORDER));
pagePane.setAlignment(Pos.CENTER);
scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
if (fitWidthButton.isSelected()) {
handleFitPageWidthAction();
}
scrollPane.setFitToWidth(pagePane.prefWidth(-1) < newValue.getWidth());
scrollPane.setFitToHeight(pagePane.prefHeight(-1) < newValue.getHeight());
});
scrollPane.vvalueProperty().addListener((ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
final double interval = 1d / (double) pageCount.get();
double low = pageIndex.get() * interval;
double hi = low + interval;
int newPageIndex = pageIndex.get();
if (hi < newValue.doubleValue() && pageIndex.get() < pageCount.get()) {
while (hi < newValue.doubleValue()) {
newPageIndex++;
hi += interval;
}
// increase the page index to match the scroll position
setPageIndex(newPageIndex);
} else if (low > newValue.doubleValue() && pageIndex.get() > 0) {
while (low > newValue.doubleValue()) {
newPageIndex--;
low -= interval;
}
// decrease the page index to match the scroll position
setPageIndex(newPageIndex);
}
});
for (int zoom : DEFAULT_ZOOMS) {
zoomComboBox.getItems().add(zoom + "%");
}
zoomComboBox.getSelectionModel().select(DEFAULT_ZOOM_INDEX);
zoomComboBox.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (e.getCode() == KeyCode.ENTER) {
handleZoomChangedAction();
}
});
setZoomRatio(1);
}
Aggregations