Java 类javafx.beans.binding.StringExpression 实例源码

项目:MPL    文件:MplIdeController.java   
private Tab createAndAttachTab(Path path) {
  BorderPane pane = new BorderPane();
  MplEditor editor = MplEditor.create(path, pane, eventBus, appMemento, this);

  ReadOnlyBooleanProperty modifiedProperty = editor.modifiedProperty();
  StringExpression titleText = Bindings.createStringBinding(() -> {
    return modifiedProperty.get() ? "*" : "";
  }, modifiedProperty).concat(path.getFileName());

  Tab tab = new Tab();
  tab.textProperty().bind(titleText);
  tab.setContent(pane);
  tab.setUserData(new MplEditorData(path, editor));
  tab.setOnCloseRequest(e -> {
    if (warnAboutUnsavedResources(Arrays.asList(tab)))
      e.consume();
  });
  editorTabPane.getTabs().add(tab);
  tab.setOnClosed(e -> {
    editors.remove(path);
    tabs.remove(path);
  });
  editors.put(path, editor);
  tabs.put(path, tab);
  return tab;
}
项目:photo-flow    文件:PhotoController.java   
private void initializeLabels() {
    filePathLabel.textProperty().bind(stringProperty(photo, "filePath"));

    StringExpression fileSize =  Bindings.format("%.2f MB", numberProperty(photo, "fileSize").divide(1024*1014));
    fileSizeLabel.textProperty().bind(fileSize);

    stateLabel.textProperty().bind(objectProperty(photo, STATE_PROPERTY).asString("State: %s"));

    try {
        FileHandler fileHandler = photoFlow.fileHandler(photo.getProjectId().get());
        String metadata = fileHandler.loadPhotoMetadata(photo);
        metadataLabel.setText("Metadata/Exif:\n" + metadata);
        metadataLabel.setVisible(!metadata.isEmpty());
    } catch (FileHandlerException e) {
        EventHandler.spawnError("Could not load any metadata from your photo :-(");
        throw new RuntimeException(e);
    }
}
项目:nitrite-database    文件:RootController.java   
void setRootLayout(BorderPane rootLayout) {
    this.rootLayout = rootLayout;
    brightness.valueProperty().addListener((observable, oldValue, newValue) -> {
        Double value = (Double) newValue;
        value = value * 2.55;
        StringExpression styleString = Bindings.format("-fx-base:rgb(%1$.0f , %1$.0f, %1$.0f)", value);
        this.rootLayout.styleProperty().bind(styleString);
    });
    brightness.setMin(0);
    brightness.setMax(100);
    brightness.setValue(30.8);
}
项目:drd    文件:StringConvertors.java   
public static StringExpression forRaceAndProfessionConverter(Translator translator, Hero hero) {
    Race race = hero.getRace();
    Profession profession = hero.getProfession();
    if (race == null || profession == null) {
        return Bindings.concat();
    }

    String translatedRace = translator.getRaceList().get(hero.getRace().ordinal());
    String translatedProfession = translator.getProfessionList()
        .get(hero.getProfession().ordinal());
    return Bindings.concat(translatedRace, " ", translatedProfession);
}
项目:willow-browser    文件:StatusDisplay.java   
public StatusDisplay(StringExpression statusProperty) {
    Text statusText = new Text();
    statusText.textProperty().bind(statusProperty);
    HBox.setMargin(statusText, new Insets(1, 6, 3, 6));

    setEffect(new DropShadow());
    getStyleClass().add("status-background");
    getChildren().add(statusText);
    setVisible(false);

    statusText.textProperty().addListener((observableValue, oldValue, newValue) ->
            setVisible(newValue != null && !newValue.equals(""))
    );
}
项目:assertj-javafx    文件:StringTest.java   
@Test
public void testStringExpression(){
    final StringExpression actual = Bindings.concat("hello", "world");

    assertThat(actual).hasValue("helloworld");

    assertThat(actual).hasSameValue(actual);
}
项目:fx-animation-editor    文件:FilePersistence.java   
public StringExpression getTitle() {
    StringBinding fileName = ChainedBindingFunctions.from(editedFile).mapToString(File::getName);
    StringBinding titleText = Bindings.when(editedFile.isNotNull()).then(fileName).otherwise("Untitled");
    StringBinding dirtyFlag = Bindings.when(dirty).then("*").otherwise("");
    return Bindings.concat(TITLE_BASE, titleText, dirtyFlag);
}
项目:jstackfx    文件:TooltipUtils.java   
public static Tooltip createNumberedTooltip(final StringProperty label, final DoubleProperty value) {
    final StringExpression text = label.concat(": ").concat(value.asString("%.0f"));
    final Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(text);
    return tooltip;
}
项目:FXGL    文件:UIFactory.java   
default Text newText(StringExpression textBinding) {
    Text text = newText(textBinding.get());
    text.textProperty().bind(textBinding);
    return text;
}
项目:netentionj-desktop    文件:StatusDisplay.java   
public StatusDisplay(StringExpression statusProperty) {
    Label statusText = new Label();
    statusText.setTextOverrun(OverrunStyle.ELLIPSIS);

    statusText.textProperty().bind(statusProperty);


    getStyleClass().add("status-background");

    setVisible(true);

    //statusText.textProperty().addListener((observableValue, oldValue, newValue) ->
            //setVisible(newValue != null && !newValue.equals(""))
    //);


    getChildren().addAll(statusText, progressHolder);
}
项目:assertj-javafx    文件:String_HasNullValue_Test.java   
@Test
public void testStringExpression(){
    final StringExpression actual = Bindings.createStringBinding(() -> null);

    assertThat(actual).hasNullValue();
}
项目:assertj-javafx    文件:String_HasNotNullValue_Test.java   
@Test
public void testStringExpression(){
    final StringExpression actual = Bindings.createStringBinding(() -> "test");

    assertThat(actual).hasNotNullValue();
}
项目:StreamSis    文件:ActorCell.java   
/**
 * The string binding that represents the text to be shown in the Actor Cell.
 *
 * @param actor
 *            the {@link Actor} bind to
 * @return the string binding
 */
private StringExpression getTextBinding(Actor actor) {
    return Bindings.concat(actor.getElementInfo().nameProperty()).concat(" (")
            .concat(checkIntervalProperty).concat(")");
}