Example usage for javafx.scene.input KeyEvent getCode

List of usage examples for javafx.scene.input KeyEvent getCode

Introduction

In this page you can find the example usage for javafx.scene.input KeyEvent getCode.

Prototype

public final KeyCode getCode() 

Source Link

Document

The key code associated with the key in this key pressed or key released event.

Usage

From source file:com.esri.geoevent.test.performance.ui.FixtureController.java

@FXML
public void onNameFieldKeyPressed(final KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        setEditNameState(!isEditingName);
    }/*from  w w  w.  j  a  va 2s . c  o m*/
}

From source file:com.esri.geoevent.test.performance.ui.FixtureController.java

@FXML
public void onAddProducerKeyPressed(final KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        ActionEvent actionEvent = null;
        addProducer(actionEvent);/*from ww w  .ja  va2 s  .c  o m*/
    }
}

From source file:com.esri.geoevent.test.performance.ui.FixtureController.java

@FXML
public void onAddConsumerKeyPressed(final KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        ActionEvent actionEvent = null;
        addConsumer(actionEvent);//from  w ww.ja  va 2 s .co m
    }
}

From source file:genrsa.GenRSAController.java

/**
 * Mtodo usado cuando se pulsa enter al meter los bits de generar de manera automtica una clave   
 * @param keyEvent//  ww w.  j  a  va2s  .co  m
 */
public void processAutomaticGeneration2(KeyEvent keyEvent) {
    if (keyEvent.getCode() == KeyCode.ENTER) {
        processAutomaticGeneration(new ActionEvent());
    }

}

From source file:genrsa.GenRSAController.java

/**
 * Mtodo usado cuando se pulsa enter al meter los primos p y q o la clave pblica   
 * @param keyEvent/*from  ww w .  j a  v a2  s  .c o m*/
 */
public void processManualGeneration2(KeyEvent keyEvent) {
    if (keyEvent.getCode() == KeyCode.ENTER) {
        this.processManualGeneration(new ActionEvent());
    }

}

From source file:view.FXApplicationController.java

public void keyAction(KeyEvent ke) {
    if (ke.getCode() == KeyCode.RIGHT) {
        goToEpoch(currentEpoch + 1);/*from w  ww. j  av  a 2  s  .  co  m*/
    }

    if (ke.getCode() == KeyCode.LEFT) {
        goToEpoch(currentEpoch - 1);
    }

    if (ke.getCode() == KeyCode.H) {
        hypnogramAction();
    }

    if (ke.getCode() == KeyCode.E) {
        showEvaluationWindowAction();
    }

    if (ke.getCode() == KeyCode.L) {
        help1OnAction();
    }

    if (ke.getCode() == KeyCode.K) {
        kComplexOnAction();

    }

    if (ke.getCode() == KeyCode.UP) {
        refreshZoom(+1);
    }

    if (ke.getCode() == KeyCode.DOWN) {
        refreshZoom(-1);
    }

    if (ke.getCode() == KeyCode.W) {
        awakeButtonOnAction();
        if (featureModel.getLabel(currentEpoch) == -1) {
            goToEpoch(currentEpoch + 1);
        }
    }

    if (ke.getCode() == KeyCode.R) {
        remButtonOnAction();
        if (featureModel.getLabel(currentEpoch) == -1) {
            goToEpoch(currentEpoch + 1);
        }
    }

    if (ke.getCode() == KeyCode.DIGIT1) {
        s1ButtonOnAction();
        if (featureModel.getLabel(currentEpoch) == -1) {
            goToEpoch(currentEpoch + 1);
        }
    }

    if (ke.getCode() == KeyCode.DIGIT2) {
        s2ButtonOnAction();
        if (featureModel.getLabel(currentEpoch) == -1) {
            goToEpoch(currentEpoch + 1);
        }
    }

    if (ke.getCode() == KeyCode.DIGIT3) {
        s3ButtonOnAction();
        if (featureModel.getLabel(currentEpoch) == -1) {
            goToEpoch(currentEpoch + 1);
        }
    }

    if (ke.getCode() == KeyCode.A) {
        artefactButtonOnAction();
    }

    if (ke.getCode() == KeyCode.M) {
        arousalButtonOnAction();
    }

    if (ke.getCode() == KeyCode.D) {
        stimulationButtonOnAction();
    }

    if (ke.getCode() == KeyCode.C) {
        clearButtonOnAction();
    }

    if (ke.getCode() == KeyCode.PAGE_DOWN) {
        goToEpoch(currentEpoch - 10);
    }

    if (ke.getCode() == KeyCode.PAGE_UP) {
        goToEpoch(currentEpoch + 10);
    }

    if (ke.getCode() == KeyCode.END) {
        goToEpoch(dataModel.getNumberOf30sEpochs() - 1);
    }

    if (ke.getCode() == KeyCode.HOME) {
        goToEpoch(0);
    }

    if (ke.getCode() == KeyCode.F6) {
        visualizeButtonAction();
    }
    if (ke.getCode() == KeyCode.F7) {
        filterButtonAction();
    }
    if (ke.getCode() == KeyCode.F8) {
        dcRemoveButtonAction();
    }
    if (ke.getCode() == KeyCode.F9) {
        kcMarkersButtonAction();
    }
    if (ke.getCode() == KeyCode.F12) {
        electrodeConfiguratorButtonAction();
    }
}

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

@FXML
public void handleProjectBrowserKey(KeyEvent evt) {
    if (logger.isDebugEnabled()) {
        logger.debug("[KEY] key={}", evt.getCode());
    }/* w ww. j ava2s . c  o  m*/
    if (StringUtils.isNotEmpty(lvProfiles.getSelectionModel().getSelectedItem())) {

        switch (evt.getCode()) {
        case DELETE:
            if (logger.isDebugEnabled()) {
                logger.debug("[KEY] deleting");
            }
            deleteProfile();
            break;
        case F2:
            int index = lvProfiles.getSelectionModel().getSelectedIndex();
            if (logger.isDebugEnabled()) {
                logger.debug("[KEY] renaming index={}", index);
            }
            lvProfiles.edit(index);

            break;
        default:
            break;
        }
        //evt.consume();
    }
}

From source file:view.FXApplicationController.java

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    System.out.println("initialize called");

    overlay3.addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() {

        @Override//from  ww  w  . j a  v  a  2 s.co  m
        public void handle(MouseEvent mouse) {
            mouseX.set(mouse.getX());
            mouseY.set(mouse.getY());

            if (kComplexFlag) {

                if (mouse.getEventType() == MouseEvent.MOUSE_PRESSED) {
                    Line line = new Line();
                    line.setStyle("-fx-stroke: red;");

                    overlay3.getChildren().add(line);

                    line.setStartX(0);
                    line.setStartY(0);
                    line.setLayoutX(mouseX.get());
                    line.setLayoutY(mouseY.get());

                    lines.add(line);

                }

                if (mouse.isPrimaryButtonDown() && (!lines.isEmpty())) {
                    Line line = lines.getLast();
                    double endXPos = mouseX.get() - line.getLayoutX();
                    double endYPos = mouseY.get() - line.getLayoutY();

                    line.setEndX(endXPos);
                    line.setEndY(endYPos);

                    calculatePercentageKComplex();

                }

            }

            if (help1Flag) {

                double offsetSize = 1. / (activeChannels.size() + 1.);

                double posOnOverlay = mouse.getY();

                double zoom = 1.0;
                for (int i = 0; i < activeChannels.size(); i++) {

                    double realOffset = (1 - (i + 1.) * offsetSize);

                    double upperBound = yAxis.getDisplayPosition(
                            (realOffset - offsetSize / 2.) * yAxis.getUpperBound()) + yAxis.getLayoutY();

                    double lowerBound = yAxis.getDisplayPosition(
                            (realOffset + offsetSize / 2.) * yAxis.getUpperBound()) + yAxis.getLayoutY();

                    if ((posOnOverlay <= upperBound) && (posOnOverlay > lowerBound)) {

                        zoom = getZoomFromChannel(activeChannels.get(i));
                    }
                }

                space.set(75.0 * zoom / yAxis.getUpperBound() * yAxis.getHeight());

                line1.setVisible(true);
                line2.setVisible(true);
            } else {
                line1.setVisible(false);
                line2.setVisible(false);
            }
        }

    });

    //Key Listener
    lineChart.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent ke) {
            keyAction(ke);
        }

    });

    toolBarGoto.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ENTER) {

                int valueTextField = -1;

                try {
                    valueTextField = Integer.parseInt(toolBarGoto.getText());

                } catch (NumberFormatException e) {
                    toolBarGoto.setText((currentEpoch + 1) + "");
                    valueTextField = currentEpoch + 1;

                    Logger.getLogger(this.getClass().getName()).log(Level.INFO,
                            "Error during handling enter key.", e);
                }

                if (valueTextField > dataModel.getNumberOf30sEpochs()) {
                    valueTextField = dataModel.getNumberOf30sEpochs();
                } else if (valueTextField < 1) {
                    valueTextField = 1;
                }

                currentEpoch = valueTextField - 1;

                goToEpoch(currentEpoch);

                if (kComplexFlag) {
                    calculatePercentageKComplex();
                }

            }

        }
    });

    choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            System.out.println(newValue);
            if (newValue != null) {

                featureModel.setFeatureChannel(Arrays.asList(channelNames).indexOf(newValue));

                System.out.println("########" + Arrays.asList(channelNames).indexOf(newValue));

                System.out.println(featureModel.getFeatureChannel());

                featureModel.setTsneComputed(false);
                featureModel.setFeaturesComputed(false);
                featureModel.setClassificationDone(false);
                featureModel.setReadinDone(false);
                classifyButton.setDisable(false);
                recompute = true;

                if (viewModel.isKcMarkersActive()) {
                    computeKCfeatures();
                } else {
                    overlay4.getChildren().clear();
                }
            }
        }
    });

    choiceBoxModel.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            classifier = classifierList.get(newValue.intValue());
            System.out.println(classifier);

            featureModel.setClassificationDone(false);
            featureModel.setReadinDone(false);
            classifyButton.setDisable(false);
            recompute = true;
        }

    });

    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {

        @Override
        public void handle(WindowEvent event) {
            System.out.println("RandomAccessFile closed");
            dataModel.getReader().close();
            Platform.exit();
        }
    });

    kComplexOnAction();

    help1OnAction();
}

From source file:com.panemu.tiwulfx.table.TableControl.java

public TableControl(Class<R> recordClass) {
    this.recordClass = recordClass;
    initControls();//from w  w w  .  j ava  2 s.c o m

    tblView.getSortOrder().addListener(new ListChangeListener<TableColumn<R, ?>>() {
        @Override
        public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) {
            reload();
        }
    });

    btnAdd.disableProperty().bind(mode.isEqualTo(Mode.EDIT));
    btnEdit.disableProperty().bind(mode.isNotEqualTo(Mode.READ));
    btnSave.disableProperty().bind(mode.isEqualTo(Mode.READ));
    btnDelete.disableProperty().bind(new BooleanBinding() {
        {
            super.bind(mode, tblView.getSelectionModel().selectedItemProperty(), lstChangedRow);
        }

        @Override
        protected boolean computeValue() {
            if ((mode.get() == Mode.INSERT && lstChangedRow.size() < 2)
                    || tblView.getSelectionModel().selectedItemProperty().get() == null
                    || mode.get() == Mode.EDIT) {
                return true;
            }
            return false;
        }
    });
    tblView.editableProperty().bind(mode.isNotEqualTo(Mode.READ));
    tblView.getSelectionModel().cellSelectionEnabledProperty().bind(tblView.editableProperty());
    mode.addListener(new ChangeListener<Mode>() {
        @Override
        public void changed(ObservableValue<? extends Mode> ov, Mode t, Mode t1) {
            if (t1 == Mode.READ) {
                directEdit = false;
            }
        }
    });

    tblView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
            lblRowIndex
                    .setText(TiwulFXUtil.getLiteral("row.param", (page * maxResult.get() + t1.intValue() + 1)));
        }
    });

    tblView.getFocusModel().focusedCellProperty().addListener(new ChangeListener<TablePosition>() {
        @Override
        public void changed(ObservableValue<? extends TablePosition> observable, TablePosition oldValue,
                TablePosition newValue) {
            if (tblView.isEditable() && directEdit && agileEditing.get()) {
                tblView.edit(newValue.getRow(), newValue.getTableColumn());
            }
        }
    });

    tblView.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ESCAPE) {
                directEdit = false;
            } else if (event.getCode() == KeyCode.ENTER && mode.get() == Mode.READ) {
                getController().doubleClick(getSelectionModel().getSelectedItem());
            }
        }
    });

    /**
     * Define policy for TAB key press
     */
    tblView.addEventFilter(KeyEvent.KEY_PRESSED, tableKeyListener);
    /**
     * In INSERT mode, only inserted row that is focusable
     */
    tblView.getFocusModel().focusedCellProperty().addListener(tableFocusListener);

    tblView.setOnMouseReleased(tableRightClickListener);

    if (Platform.isFxApplicationThread()) {
        cm = new ContextMenu();
        cm.setAutoHide(true);
        setToolTips();
        /**
         * create custom row factory that can intercept double click on grid row
         */
        tblView.setRowFactory(new Callback<TableView<R>, TableRow<R>>() {
            @Override
            public TableRow<R> call(TableView<R> param) {
                return new TableRowControl(TableControl.this);
            }
        });
    }

    columns.addListener(new ListChangeListener<TableColumn<R, ?>>() {
        @Override
        public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) {
            while (change.next()) {
                if (change.wasAdded()) {
                    for (TableColumn<R, ?> column : change.getAddedSubList()) {
                        initColumn(column);
                    }
                }
                lastColumnIndex = getLeafColumns().size() - 1;
            }
        }
    });
    attachWindowVisibilityListener();
}

From source file:snpviewer.SnpViewer.java

public void refreshView(String chrom, boolean forceRedraw) {
    //if forceRedraw is false look for existing png files for each snpFile
    if (chrom == null) {
        /*if null is passed then select/reselect chromosome from 
         * chromosomeSelector, return and let chromosomeSelector's 
         * listener refire this method/*from  www . j  a va  2s  .co m*/
         */
        if (chromosomeSelector.getSelectionModel().isEmpty()) {
            chromosomeSelector.getSelectionModel().selectFirst();
        } else {
            int sel = chromosomeSelector.getSelectionModel().getSelectedIndex();
            chromosomeSelector.getSelectionModel().clearSelection();
            chromosomeSelector.getSelectionModel().select(sel);
        }
        return;
    }
    int totalFiles = affFiles.size() + unFiles.size();
    if (totalFiles < 1) {
        return;
    }
    ArrayList<Pane> panesToAdd = new ArrayList<>();
    ArrayList<ScrollPane> labelsToAdd = new ArrayList<>();
    clearSplitPanes();

    setProgressMode(true);
    nextChromMenu.setDisable(false);
    nextChromMenu.setDisable(false);
    for (final SnpFile f : affFiles) {
        Pane sPane = new Pane();
        sPane.setMinHeight(chromSplitPane.getHeight() / totalFiles);
        sPane.setMinWidth(chromSplitPane.getWidth());
        sPane.setVisible(true);
        panesToAdd.add(sPane);
        ScrollPane labelPane = new ScrollPane();
        Label fileLabel = new Label(f.inputFile.getName() + "\n(Affected)");
        fileLabel.setTextFill(Color.WHITE);
        labelPane.setMinHeight(labelSplitPane.getHeight() / totalFiles);
        labelPane.setPrefWidth(labelSplitPane.getWidth());
        labelPane.minHeightProperty().bind(labelSplitPane.heightProperty().divide(totalFiles));
        VBox vbox = new VBox();
        vbox.setSpacing(10);
        vbox.getChildren().add(fileLabel);
        final TextField textField = new TextField();
        textField.setStyle("-fx-text-fill: white; -fx-background-color: "
                + "rgba(90%,90%,90%,0.3); -fx-border-color:white");
        textField.setPromptText("Sample Name");
        if (f.getSampleName() != null) {
            textField.setText(f.getSampleName());
        }
        textField.setFocusTraversable(true);
        textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent ke) {
                if (ke.getCode().equals(KeyCode.ENTER)) {
                    if (!textField.getText().isEmpty()) {
                        String name = textField.getText().trim();
                        if (name.length() > 0) {
                            f.setSampleName(name);
                        }
                        textField.getParent().requestFocus();
                        saveProject();
                    }
                }
            }
        });
        textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                    Boolean newValue) {
                if (!textField.isFocused()) {
                    if (!textField.getText().isEmpty()) {
                        String name = textField.getText().trim();
                        if (name.length() > 0) {
                            f.setSampleName(name);
                        }
                        saveProject();
                    }
                }
            }
        });
        vbox.getChildren().add(textField);
        Label noCalls = new Label();
        if (f.getPercentNoCall() != null) {
            noCalls.setText("No Calls: " + DecimalFormat.getInstance().format(f.getPercentNoCall()) + " %");
        } else {
            noCalls.setText("No Calls: none");
        }
        Label meanQual = new Label();
        if (f.getMeanQuality() != null) {
            meanQual.setText("Av. Call Conf: "
                    + DecimalFormat.getInstance().format(100 - (f.getMeanQuality() * 100)) + " %");
        } else {
            meanQual.setText("No Call Confidence Data");
        }
        vbox.getChildren().add(noCalls);
        vbox.getChildren().add(meanQual);
        labelPane.setContent(vbox);
        //            labelPane.getChildren().add(fileLabel);
        //            labelPane.getChildren().add(new TextField());
        labelsToAdd.add(labelPane);
    }
    for (final SnpFile f : unFiles) {
        Pane sPane = new Pane();
        sPane.setMinHeight(chromSplitPane.getHeight() / totalFiles);
        sPane.setMinWidth(chromSplitPane.getWidth());
        sPane.setVisible(true);
        panesToAdd.add(sPane);
        ScrollPane labelPane = new ScrollPane();
        Label fileLabel = new Label(f.inputFile.getName() + "\n(Unaffected)");
        fileLabel.setStyle("-fx-text-fill: black");
        labelPane.setMinHeight(labelSplitPane.getHeight() / totalFiles);
        labelPane.setPrefWidth(labelSplitPane.getWidth());
        labelPane.minHeightProperty().bind(labelSplitPane.heightProperty().divide(totalFiles));
        VBox vbox = new VBox();
        vbox.setSpacing(10);
        vbox.getChildren().add(fileLabel);
        final TextField textField = new TextField();
        textField.setStyle("-fx-text-fill: black; " + "-fx-background-color: rgba(90%,90%,90%,0.3);"
                + " -fx-border-color:white");
        textField.setPromptText("Sample Name");
        if (f.getSampleName() != null) {
            textField.setText(f.getSampleName());
        }
        textField.setFocusTraversable(true);
        textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent ke) {
                if (ke.getCode().equals(KeyCode.ENTER)) {
                    if (!textField.getText().isEmpty()) {
                        f.setSampleName(textField.getText());
                        textField.getParent().requestFocus();
                        saveProject();
                    }
                }
            }
        });
        textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                    Boolean newValue) {
                if (!textField.isFocused()) {
                    if (!textField.getText().isEmpty()) {
                        f.setSampleName(textField.getText());
                        saveProject();
                    }
                }
            }
        });
        vbox.getChildren().add(textField);
        Label noCalls = new Label();
        if (f.getPercentNoCall() != null) {
            noCalls.setText("No Calls: " + DecimalFormat.getInstance().format(f.getPercentNoCall()) + " %");
        } else {
            noCalls.setText("No Calls: none");
        }
        Label meanQual = new Label();
        if (f.getMeanQuality() != null) {
            meanQual.setText("Av. Call Conf: "
                    + DecimalFormat.getInstance().format(100 - (f.getMeanQuality() * 100)) + " %");
        } else {
            meanQual.setText("No Call Confidence Data");
        }
        vbox.getChildren().add(noCalls);
        vbox.getChildren().add(meanQual);
        labelPane.setContent(vbox);
        //            labelPane.getChildren().add(fileLabel);
        labelsToAdd.add(labelPane);
    }
    if (panesToAdd.size() > 0) {
        chromSplitPane.getItems().addAll(panesToAdd);
        labelSplitPane.getItems().addAll(labelsToAdd);

        ArrayList<SnpFile> bothFiles = new ArrayList<>(affFiles);
        bothFiles.addAll(unFiles);
        final Iterator<SnpFile> fileIter = bothFiles.iterator();
        final Iterator<Pane> paneIter = panesToAdd.iterator();
        SnpFile firstFileToProcess = fileIter.next();
        Pane firstPaneToProcess = paneIter.next();
        String pngPath = null;
        if (qualityFilter != null) {
            Integer percent = new Integer(100 - (int) (qualityFilter * 100));
            pngPath = percent.toString();
        }
        drawWithIterator(firstFileToProcess, firstPaneToProcess, pngPath, fileIter, paneIter, 1, totalFiles,
                chrom, forceRedraw, chromSplitPane);
    } else {
        setProgressMode(false);
    }
}