Example usage for javafx.scene.control Label setTextFill

List of usage examples for javafx.scene.control Label setTextFill

Introduction

In this page you can find the example usage for javafx.scene.control Label setTextFill.

Prototype

public final void setTextFill(Paint value) 

Source Link

Usage

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// w  ww  . j av  a  2 s .  c  o 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);
    }
}

From source file:view.FXApplicationController.java

public void showLabelsForEpoch() {

    overlay.getChildren().clear();//from   w w w.jav  a  2  s.  c  o m

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

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

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

        Label label = new Label(channelNames[activeChannels.get(i)]);
        label.setTextFill(Color.GRAY);
        label.setStyle("-fx-font-family: sans-serif;");
        label.setLayoutX(1);

        label.layoutYProperty().bind(yAxis.heightProperty().multiply(realOffset).add(yAxis.layoutYProperty()));

        overlay.getChildren().add(label);

    }

}