Example usage for javafx.scene.control Label getText

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

Introduction

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

Prototype

public final String getText() 

Source Link

Usage

From source file:de.micromata.mgc.javafx.FXGuiUtils.java

/**
 * Computes the required height of the label to fully render its text.
 * //w  w  w. j  ava  2  s  .c  o  m
 * @param width used if the {@link Label#wrapTextProperty()} is true. Then this value is the max line width when the
 *          text needs to be wrapped.
 * @param msg the label.
 * @return required height.
 */
public static double computeLabelHeight(double width, Label msg) {
    final Font font = msg.getFont();
    final String str = msg.getText();
    return computeTextHeight(font, str, msg.isWrapText() ? width : 0);
}

From source file:hd3gtv.as5kpc.Serverchannel.java

void appCue(TextField mediaid, Label takenum, TextField showname, Button btncue, Button btnrec) {
    int id;//from   w  w w .  j a  v a  2 s .c o  m
    int take;
    try {
        id = Integer.parseInt(mediaid.getText());
        take = Integer.valueOf(takenum.getText());
    } catch (Exception e) {
        Alert alert = new Alert(AlertType.WARNING);
        alert.setTitle("Media ID");
        alert.setHeaderText("Erreur lors de la rcupration de l'ID, seuls des chiffres sont autoriss.");
        alert.setContentText("Dtail: " + e.getMessage());
        alert.showAndWait();
        return;
    }

    GetFreeClipIdBackgound gfip = getFreeClipIdBackgound(id + getVtrIndex(), take);

    gfip.setOnSucceeded((WorkerStateEvent ev) -> {
        takenum.setText(gfip.getValue().get("take"));
        String first_name = gfip.getValue().get("first_name");
        if (first_name != null) {
            final String _first_name = first_name.substring("00-00 ".length());
            showname.setText(_first_name);
            if (_first_name.endsWith(getServerLabel())) {
                showname.setText(
                        _first_name.substring(0, _first_name.length() - getServerLabel().length()).trim());
            }
        }

        btncue.setDisable(false);
        mediaid.setDisable(false);
        showname.setDisable(false);
        btnrec.setDisable(false);
    });

    gfip.setOnFailed((WorkerStateEvent ev) -> {
        Alert alert = new Alert(AlertType.WARNING);
        alert.setTitle("Cue");
        alert.setHeaderText("Impossible de rcuperer un tat");
        alert.setContentText("La rcupration du statut de l'Id " + id + " n'a pas fonctionn.");
        alert.showAndWait();

        mediaid.setDisable(false);
        showname.setDisable(false);
    });

    gfip.start();

}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid sanctions/*  w w  w .  j  av  a 2s. co  m*/
 * @param eleve
 * @param rowIndex 
 */
private void drawSanctions(Eleve eleve, int rowIndex) {
    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);

    drawEleveName(sanctionsGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    HBox punitionsBox = new HBox();
    punitionsBox.setAlignment(Pos.CENTER_LEFT);
    TextFlow nbPunitions = new TextFlow();
    Label nbPunitionLabel = new Label(
            "" + eleve.getPunitions().stream().filter(p -> p.getSeance() == seanceSelect.getValue()).count());
    nbPunitionLabel.setPrefHeight(20);
    nbPunitions.getChildren().add(new Label(" ("));
    nbPunitions.getChildren().add(nbPunitionLabel);
    nbPunitions.getChildren().add(new Label(")"));

    nbPunitions.visibleProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0"));
    nbPunitions.managedProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0"));

    Button punitionBtn = Btns.punitionBtn();
    punitionBtn.setOnAction((event) -> {
        if (openPunitionDialog(eleve)) {
            int nbPunition = Integer.parseInt(nbPunitionLabel.getText());
            nbPunitionLabel.setText("" + (nbPunition + 1));
        }
    });
    punitionsBox.getChildren().add(punitionBtn);
    punitionsBox.getChildren().add(nbPunitions);

    sanctionsGrid.add(punitionsBox, 3, rowIndex, HPos.LEFT);

    CheckBox motCarnet = new CheckBox();
    Label cumulMot = new Label();
    motCarnet.setSelected(model.getMotForSeance(eleve, seanceSelect.getValue()) != null);
    motCarnet.selectedProperty().addListener((ob, o, checked) -> {
        Mot mot = model.getMotForSeance(eleve, seanceSelect.getValue());
        if (checked && mot == null) {
            model.createMot(eleve, seanceSelect.getValue());
        } else if (mot != null) {
            model.delete(mot);
        }
        writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3);
    });
    sanctionsGrid.add(motCarnet, 4, rowIndex, null);
    writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3);
    sanctionsGrid.add(cumulMot, 5, rowIndex, null);

    CheckBox exclus = new CheckBox();
    TextField motif = new TextField();
    Bindings.bindBidirectional(exclus.selectedProperty(), eleveData.exclusProperty());
    sanctionsGrid.add(exclus, 6, rowIndex, null);
    exclus.selectedProperty().addListener((o, oldV, newV) -> {
        if (!newV && StringUtils.isNotBlank(motif.getText())
                && ModalUtil.confirm("Effacer le motif ?", "Effacer le motif ?")) {
            motif.clear();
        }
    });

    Bindings.bindBidirectional(motif.textProperty(), eleveData.MotifProperty());
    motif.textProperty().addListener((o, oldV, newV) -> {
        if (StringUtils.isNotBlank(newV)) {
            exclus.setSelected(true);
        }
    });
    GridPane.setMargin(motif, new Insets(0, 10, 0, 0));
    sanctionsGrid.add(motif, 7, rowIndex, HPos.LEFT);

}

From source file:com.chart.SwingChart.java

/**
 * /*from w  ww.  ja va  2s. c  o m*/
 * @param axis Axis name to wich the new series belongs
 * @param cs Series Coinfiguration
 */
@Override
public final void addSeries(String axis, SimpleSeriesConfiguration cs) {
    for (int i = 0; i < axes.size(); i++) {
        if (axes.get(i).getName().equals(axis)) {
            String strColor;
            javafx.scene.paint.Color color;
            int indice = seriesList.size();
            if (cs.getColor() == null) {
                color = getColor(indice);
            } else {
                color = cs.getColor();
            }
            strColor = color.toString();

            XYSeriesCollection dataset = datasetList.get(i);
            Series series = new Series(cs.getName(), "color: " + strColor + ";width: "
                    + String.valueOf(cs.getLineWidth()) + ";shape: " + cs.getShapeName() + ";", i,
                    dataset.getSeriesCount());
            dataset.addSeries(series);

            XYItemRenderer renderer = plot.getRenderer(i);
            renderer.setSeriesPaint(dataset.getSeriesCount() - 1, scene2awtColor(color));

            SeriesShape simb = new SeriesShape(cs.getShapeName(),
                    javafx.scene.paint.Color.web(strColor.replace("#", "0x")));

            if (cs.getLineWidth() > 0) {
                ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(dataset.getSeriesCount() - 1, true);
                renderer.setSeriesStroke(dataset.getSeriesCount() - 1, new BasicStroke(cs.getLineWidth()));
            } else {
                ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(dataset.getSeriesCount() - 1, false);
            }

            if (cs.getShapeName().equals("null")) {
                renderer.setSeriesShape(dataset.getSeriesCount() - 1, null);
                ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(dataset.getSeriesCount() - 1, false);
            } else {
                renderer.setSeriesShape(dataset.getSeriesCount() - 1, simb.getShapeAWT());
                ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(dataset.getSeriesCount() - 1, true);
                if (cs.getShapeName().contains("empty")) {
                    ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(dataset.getSeriesCount() - 1,
                            false);
                } else {
                    ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(dataset.getSeriesCount() - 1,
                            true);
                }
            }

            if (i == 0) {
                plot.setRenderer(renderer);
            } else {
                plot.setRenderer(i, renderer);
            }

            seriesList.add(series);

            final LegendAxis le = getLegendAxis(axis);
            final Label label = new Label(cs.toString());
            Platform.runLater(() -> {
                label.setStyle("fondo: " + strChartBackgroundColor
                        + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                        + String.valueOf(fontSize) + "px");
            });

            label.setOnMouseClicked((MouseEvent t) -> {
                if (t.getClickCount() == 2) {
                    for (int i1 = 0; i1 < seriesList.size(); i1++) {
                        if (seriesList.get(i1).getKey().toString().equals(label.getText())) {
                            editSeries(seriesList.get(i1));
                            break;
                        }
                    }
                }
            });
            label.setOnMouseExited((MouseEvent t) -> {
                label.setStyle(
                        label.getStyle().replace("-fx-background-color: blue", "-fx-background-color: fondo"));
            });
            label.setOnMouseEntered((MouseEvent t) -> {
                label.setStyle(
                        label.getStyle().replace("-fx-background-color: fondo", "-fx-background-color: blue"));
                for (Node le1 : legendFrame.getChildren()) {
                    if (le1 instanceof LegendAxis) {
                        le1.setStyle("-fx-background-color:" + strBackgroundColor);
                        ((LegendAxis) le1).selected = false;
                    }
                }
            });
            label.setStyle("fondo: " + strChartBackgroundColor
                    + ";-fx-text-fill: white;-fx-background-color: fondo;-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                    + String.valueOf(fontSize) + "px");

            le.getChildren().add(label);
            label.setGraphic(simb.getShapeGraphic());

            break;
        }
    }
}

From source file:de.bayern.gdi.gui.Controller.java

private void loadWfsSimple() {
    ObservableList<Node> children = simpleWFSContainer.getChildren();
    Map<String, String> parameters = downloadConfig.getParams();
    for (Node node : children) {
        if (node instanceof HBox) {
            HBox hb = (HBox) node;//www.j av a2  s. c  o m
            Node n1 = hb.getChildren().get(0);
            Node n2 = hb.getChildren().get(1);
            if (n1 instanceof Label && n2 instanceof TextField) {
                Label paramLabel = (Label) n1;
                TextField paramBox = (TextField) n2;
                String targetValue = parameters.get(paramLabel.getText());
                if (targetValue != null) {
                    paramBox.setText(targetValue);
                }
            }
            if (n2 instanceof ComboBox) {
                ComboBox<OutputFormatModel> cb = (ComboBox<OutputFormatModel>) n2;
                cb.setCellFactory(new Callback<ListView<OutputFormatModel>, ListCell<OutputFormatModel>>() {
                    @Override
                    public ListCell<OutputFormatModel> call(ListView<OutputFormatModel> list) {
                        return new CellTypes.StringCell();
                    }
                });
                cb.setOnAction(event -> {
                    if (cb.getValue().isAvailable()) {
                        cb.setStyle(FX_BORDER_COLOR_NULL);
                    } else {
                        cb.setStyle(FX_BORDER_COLOR_RED);
                    }
                });
                boolean formatAvailable = false;
                for (OutputFormatModel i : cb.getItems()) {
                    if (i.getItem().equals(downloadConfig.getOutputFormat())) {
                        cb.getSelectionModel().select(i);
                        formatAvailable = true;
                    }
                }
                if (!formatAvailable) {
                    String format = downloadConfig.getOutputFormat();
                    OutputFormatModel m = new OutputFormatModel();
                    m.setItem(format);
                    m.setAvailable(false);
                    cb.getItems().add(m);
                    cb.getSelectionModel().select(m);
                }
                if (cb.getValue().isAvailable()) {
                    cb.setStyle(FX_BORDER_COLOR_NULL);
                } else {
                    cb.setStyle(FX_BORDER_COLOR_RED);
                }
            }
        }
    }
}

From source file:de.bayern.gdi.gui.Controller.java

private void extractStoredQuery() {
    ItemModel data = this.dataBean.getDatatype();
    if (data instanceof StoredQueryModel) {
        this.dataBean.setAttributes(new ArrayList<DataBean.Attribute>());

        ObservableList<Node> children = this.simpleWFSContainer.getChildren();
        for (Node n : children) {
            if (n.getClass() == HBox.class) {
                HBox hbox = (HBox) n;//from w w  w . ja  va  2  s.c  o m
                ObservableList<Node> hboxChildren = hbox.getChildren();
                String value = "";
                String name = "";
                String type = "";
                Label l1 = null;
                Label l2 = null;
                TextField tf = null;
                ComboBox cb = null;
                for (Node hn : hboxChildren) {
                    if (hn.getClass() == ComboBox.class) {
                        cb = (ComboBox) hn;
                    }
                    if (hn.getClass() == TextField.class) {
                        tf = (TextField) hn;
                    }
                    if (hn.getClass() == Label.class) {
                        if (l1 == null) {
                            l1 = (Label) hn;
                        }
                        if (l1 != (Label) hn) {
                            l2 = (Label) hn;
                        }
                    }
                    if (tf != null && (l1 != null || l2 != null)) {
                        name = tf.getUserData().toString();
                        value = tf.getText();
                        if (l2 != null && l1.getText().equals(name)) {
                            type = l2.getText();
                        } else {
                            type = l1.getText();
                        }
                    }
                    if (cb != null && (l1 != null || l2 != null)
                            && cb.getId().equals(UIFactory.getDataFormatID())) {
                        name = OUTPUTFORMAT;
                        if (cb.getSelectionModel() != null
                                && cb.getSelectionModel().getSelectedItem() != null) {
                            value = cb.getSelectionModel().getSelectedItem().toString();
                            type = "";
                        } else {
                            Platform.runLater(() -> setStatusTextUI(I18n.getMsg(GUI_FORMAT_NOT_SELECTED)));
                        }
                    }
                    if (!name.isEmpty() && !value.isEmpty()) {
                        this.dataBean.addAttribute(name, value, type);
                    }
                }
            }
        }
    }
}

From source file:org.pdfsam.ui.dashboard.about.AboutDashboardPane.java

@Inject
public AboutDashboardPane(Pdfsam pdfsam) {
    getStyleClass().add("dashboard-container");
    VBox left = new VBox(5);
    addSectionTitle(pdfsam.name(), left);
    Label copyright = new Label("Copyright 2014 by Andrea Vacondio");
    AwesomeDude.setIcon(copyright, AwesomeIcon.COPYRIGHT);
    left.getChildren().addAll(new Label(String.format("ver. %s", pdfsam.version())), copyright);
    addHyperlink(null, "http://www.gnu.org/licenses/agpl-3.0.html", "GNU Affero General Public License v3",
            left);//from  w  w w  .j  ava2 s  .  c o  m
    addHyperlink(AwesomeIcon.HOME, "http://www.pdfsam.org", "www.pdfsam.org", left);
    addHyperlink(AwesomeIcon.RSS_SQUARE, "http://www.pdfsam.org/feed/",
            DefaultI18nContext.getInstance().i18n("Subscribe to the official news feed"), left);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Environment"), left);
    Label runtime = new Label(String.format("%s %s", System.getProperty("java.runtime.name"),
            System.getProperty("java.runtime.version")));
    Label fxRuntime = new Label(
            String.format("JavaFX %s", com.sun.javafx.runtime.VersionInfo.getRuntimeVersion()));
    Label memory = new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}",
            FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory())));
    Button copyButton = new Button(DefaultI18nContext.getInstance().i18n("Copy to clipboard"));
    AwesomeDude.setIcon(copyButton, AwesomeIcon.COPY);
    copyButton.getStyleClass().addAll(Style.BUTTON.css());
    copyButton.setId("copyEnvDetails");
    copyButton.setOnAction(a -> {
        ClipboardContent content = new ClipboardContent();
        writeContent(Arrays.asList(pdfsam.name(), pdfsam.version(), runtime.getText(), fxRuntime.getText(),
                memory.getText())).to(content);
        Clipboard.getSystemClipboard().setContent(content);
    });
    left.getChildren().addAll(runtime, fxRuntime, memory, copyButton);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Thanks to"), left);
    addHyperlink(null, "http://www.pdfsam.org/thanks_to",
            DefaultI18nContext.getInstance().i18n("The open source projects making PDFsam possible"), left);
    VBox right = new VBox(5);
    addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right);
    addHyperlink(AwesomeIcon.BUG, "http://www.pdfsam.org/issue_tracker",
            DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right);
    addHyperlink(AwesomeIcon.QUESTION_CIRCLE, "http://www.pdfsam.org/wiki", "HowTo wiki", right);
    addHyperlink(AwesomeIcon.YOUTUBE_PLAY, "http://www.pdfsam.org/quickstart_video",
            DefaultI18nContext.getInstance().i18n("Play the \"get started\" video"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right);
    addHyperlink(AwesomeIcon.GITHUB, "http://www.pdfsam.org/scm",
            DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right);
    addHyperlink(AwesomeIcon.FLAG_ALT, "http://www.pdfsam.org/translate",
            DefaultI18nContext.getInstance().i18n("Translate"), right);
    addHyperlink(AwesomeIcon.DOLLAR, "http://www.pdfsam.org/donate",
            DefaultI18nContext.getInstance().i18n("Donate"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right);
    addHyperlink(AwesomeIcon.TWITTER_SQUARE, "http://www.pdfsam.org/twitter",
            DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right);
    addHyperlink(AwesomeIcon.GOOGLE_PLUS_SQUARE, "http://www.pdfsam.org/gplus",
            DefaultI18nContext.getInstance().i18n("Follow us on Google Plus"), right);
    addHyperlink(AwesomeIcon.FACEBOOK_SQUARE, "http://www.pdfsam.org/facebook",
            DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right);
    getChildren().addAll(left, right);

}

From source file:org.pdfsam.ui.selection.single.SingleSelectionPaneTest.java

@Test
public void emptyDetailsOnSwithToInvalid() throws Exception {
    SingleSelectionPane victim = find("#victim-selection-pane");
    moveToLoadedWithDecryption(victim);/*  w  w  w. j a v a2  s .  co m*/
    typePathAndValidate("/this/doesnt/exists");
    Label details = find(".-pdfsam-selection-details");
    assertTrue(isEmpty(details.getText()));
}

From source file:org.pdfsam.ui.selection.single.SingleSelectionPaneTest.java

@Test
public void emptyStatusIndicatorOnSwithToInvalid() throws Exception {
    SingleSelectionPane victim = find("#victim-selection-pane");
    moveToLoadedWithDecryption(victim);/*from  w  w  w .  j  a  v a 2 s . c  o  m*/
    typePathAndValidate("/this/doesnt/exists");
    Label encStatus = find(".encryption-status");
    assertTrue(isEmpty(encStatus.getText()));
}

From source file:org.pdfsam.ui.selection.single.SingleSelectionPaneTest.java

@Test
public void invalidatedDescriptorDoesntTriggerAnything() throws Exception {
    typePathAndValidate();//  ww  w.  ja  v a2  s  . com
    typePathAndValidate("/this/doesnt/exists");
    SingleSelectionPane victim = find("#victim-selection-pane");
    FXTestUtils.invokeAndWait(() -> {
        victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED);
        victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADING);
        victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADED);
    }, 2);
    Label details = find(".-pdfsam-selection-details");
    assertTrue(isEmpty(details.getText()));
    Label encStatus = find(".encryption-status");
    assertTrue(isEmpty(encStatus.getText()));
    ValidableTextField field = find(".validable-container-field");
    field.getContextMenu().getItems().parallelStream().filter(i -> !(i instanceof SeparatorMenuItem))
            .forEach(i -> assertTrue(i.isDisable()));
}