Java 类javafx.beans.value.ObservableObjectValue 实例源码

项目:LoliXL    文件:ImageBackgroundProvider.java   
@Override
public ObservableObjectValue<Background> getBackground() {
    if (background == null) {
        synchronized (lock) {
            if (background == null) {
                ObservableObjectValue<Image> bgimg = getBackgroundImage();
                background = Bindings.createObjectBinding(() -> new Background(new BackgroundImage(
                        bgimg.get(),
                        BackgroundRepeat.NO_REPEAT,
                        BackgroundRepeat.NO_REPEAT,
                        BackgroundPosition.CENTER,
                        new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, true, true))), bgimg);
            }
        }
    }
    return background;
}
项目:honest-profiler    文件:AbstractProfileViewController.java   
/**
 * Bind the supplied extractor function which extracts the target data structure T from the source to the source
 * {@link ObservableObjectValue}, and optionally to the {@link CombinedGrouping} {@link ObservableObjectValue} from
 * the {@link AbstractViewController} superclass if present.
 * <p>
 * @param source the {@link ObservableObjectValue} encapsulating the source from which the target data structure can
 *            be extracted
 * @param targetExtractor a function which extracts the target from the source Object
 */
public void bind(ObservableObjectValue<? extends Object> source,
    Function<Object, T> targetExtractor)
{
    // The createObjectBinding() dependency varargs parameter specifies a number of Observables. If the value of any
    // of those changes, the Binding is triggered and the specified function is executed. This is IMHO not so
    // clearly documented in the createObjectBinding() javadoc.

    // The View does not support CombinedGrouping.
    if (getGrouping() == null)
    {
        sourceBinding = createObjectBinding(() -> targetExtractor.apply(source.get()), source);
    }
    // The View supports CombinedGrouping.
    else
    {
        sourceBinding = createObjectBinding(
            () -> targetExtractor.apply(source.get()),
            source,
            getGrouping());
    }
}
项目:AsciidocFX    文件:TabService.java   
public void initializeTabChangeListener(TabPane tabPane) {

        ReadOnlyObjectProperty<Tab> itemProperty = tabPane.getSelectionModel().selectedItemProperty();

        tabPane.setOnMouseReleased(event -> {
            Optional.ofNullable(itemProperty)
                    .map(ObservableObjectValue::get)
                    .filter(e -> e instanceof MyTab)
                    .map(e -> (MyTab) e)
                    .map(MyTab::getEditorPane)
                    .ifPresent(EditorPane::focus);
        });

        itemProperty.addListener((observable, oldValue, selectedTab) -> {
            Optional.ofNullable(selectedTab)
                    .filter(e -> e instanceof MyTab)
                    .map(e -> (MyTab) e)
                    .map(MyTab::getEditorPane)
                    .filter(EditorPane::getReady)
                    .ifPresent(EditorPane::updatePreviewUrl);
        });
    }
项目:HueSense    文件:QuickItemPresenter.java   
public void setItem(Sensor<?> sensor, ObservableObjectValue<Color> color) {
    color.addListener((observable, oldValue, newValue) -> {
        valueLabel.setTextFill(newValue);
        nameLabel.setTextFill(newValue);
    });
    sensor.getUpdateCount().addListener((observable, oldValue, newValue) -> {
        valueLabel.setText(sensor.getCurrentValueAsString());
        nameLabel.setText(sensor.getName());
    });
    valueLabel.setText(sensor.getCurrentValueAsString());
    nameLabel.setText(sensor.getName());
    valueLabel.setTextFill(color.get());
    nameLabel.setTextFill(color.get());
}
项目:fx-log    文件:ColorizersController.java   
private void initializeRulesPane() {
    ObservableObjectValue<Colorizer> selectedColorizer = colorizersPane.selectedItemProperty();
    selectedColorizerPane.disableProperty().bind(Bindings.isNull(selectedColorizer));

    ListBinding<StyleRule> selectedColorizerRules = UIUtils.selectList(selectedColorizer, Colorizer::getRules);
    rulesPane.setItemFactory(StyleRule::new);
    rulesPane.setItemDuplicator(StyleRule::new);
    rulesPane.getList().itemsProperty().bind(selectedColorizerRules);
}
项目:HueSense    文件:QuickItemPresenter.java   
public void setItem(Sensor<?> sensor, ObservableObjectValue<Color> color) {
    color.addListener((observable, oldValue, newValue) -> {
        valueLabel.setTextFill(newValue);
        nameLabel.setTextFill(newValue);
    });
    sensor.getUpdateCount().addListener((observable, oldValue, newValue) -> {
        valueLabel.setText(sensor.getCurrentValueAsString());
        nameLabel.setText(sensor.getName());
    });
    valueLabel.setText(sensor.getCurrentValueAsString());
    nameLabel.setText(sensor.getName());
    valueLabel.setTextFill(color.get());
    nameLabel.setTextFill(color.get());
}
项目:LoliXL    文件:GameVersionsPresenter.java   
private Button makeDeleteMcdirButton(GameVersionProvider provider, Parent parent) {
    Button button = new Button();
    ObservableObjectValue<Image> deleteIcon = ImageLoading.load("img/org.to2mbn.lolixl.ui.sidebar.version/delete_mcdir.png");
    button.backgroundProperty().bind(Bindings.createObjectBinding(() -> new Background(new BackgroundImage(deleteIcon.get(), null, null, null, null)), deleteIcon));
    button.setOnAction(event -> provider.delete());
    return button;
}
项目:assertj-javafx    文件:ObjectTest.java   
@Test
public void testObservableObjectValue(){
    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);

    assertThat(actual).hasValue(person);

    assertThat(actual).hasSameValue(actual);
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasValue_Test.java   
@Test
public void shoud_pass_if_actual_has_given_value(){
    TestPerson person = new TestPerson("Name");
    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);

    new ObservableValueAssertions<>(actual).hasValue(person);
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasValue_Test.java   
@Test
public void should_fail_if_actual_has_wrong_value(){
    try{
        TestPerson person = new TestPerson("Name");
        TestPerson other = new TestPerson("Other");

        ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);

        new ObservableValueAssertions<>(actual).hasValue(other);
        fail("Should throw an AssertionError");
    }catch(AssertionError error){
        assertThat(error).hasMessageContaining("<Other> but was <Name>");
    }
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasValue_Test.java   
@Test
public void should_fail_if_expectedValue_is_null(){
    try{
        TestPerson person = new TestPerson("Name");
        ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);

        new ObservableValueAssertions<>(actual).hasValue(null);
        fail("Should throw an AssertionError");
    }catch(AssertionError error){
        assertThat(error).hasMessageContaining("expected value may not be null");
    }
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasSameValue_Test.java   
@Test
public void should_pass_if_actual_has_expected_value() {
    TestPerson person = new TestPerson("Name");

    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);
    ObservableObjectValue<TestPerson> expected = new SimpleObjectProperty<>(person);

    new ObservableValueAssertions<>(actual).hasSameValue(expected);
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasSameValue_Test.java   
@Test
public void should_pass_if_both_observables_has_value_of_null(){
    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>();
    ObservableObjectValue<TestPerson> expected = new SimpleObjectProperty<>();

    new ObservableValueAssertions<>(actual).hasSameValue(expected);
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasSameValue_Test.java   
@Test
public void should_fail_if_only_actual_has_value_of_null(){
    TestPerson person = new TestPerson("Name");

    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>();
    ObservableObjectValue<TestPerson> expected = new SimpleObjectProperty<>(person);

    try{
        new ObservableValueAssertions<>(actual).hasSameValue(expected);

    } catch(AssertionError error){
        assertThat(error).hasMessageContaining("<null> but was <Name>");
    }
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasSameValue_Test.java   
@Test
public void should_fail_if_only_expected_has_value_of_null(){
    TestPerson person = new TestPerson("Name");

    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);
    ObservableObjectValue<TestPerson> expected = new SimpleObjectProperty<>();

    try{
        new ObservableValueAssertions<>(actual).hasSameValue(expected);

    } catch(AssertionError error){
        assertThat(error).hasMessageContaining("<Name> but was <null>");
    }
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasSameValue_Test.java   
@Test
public void should_fail_if_actual_has_wrong_value() {
    try {
        TestPerson person = new TestPerson("Name");
        TestPerson other = new TestPerson("Other");

        ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);
        ObservableObjectValue<TestPerson> expected = new SimpleObjectProperty<>(other);

        new ObservableValueAssertions<>(actual).hasSameValue(expected);
        fail("Should throw an AsssertionError");
    } catch (AssertionError error) {
        assertThat(error).hasMessageContaining("<Name> but was <Other>");
    }
}
项目:assertj-javafx    文件:ObservableValueAssertions_hasSameValue_Test.java   
@Test
public void should_fail_if_expectedValue_is_null() {
    try {
        TestPerson person = new TestPerson("Name");

        ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);

        new ObservableValueAssertions<>(actual).hasSameValue(null);
        fail("Should throw an AsssertionError");
    } catch (AssertionError error) {
        assertThat(error).hasMessageContaining("expected value may not be null");
    }
}
项目:ReactFX    文件:ObjectBinding.java   
/**
 * @deprecated Use {@link Val#suspendable(javafx.beans.value.ObservableValue)}.
 */
@Deprecated
public static <T> ObjectBinding<T> wrap(ObservableObjectValue<T> source) {
    return new ObjectBinding<T>() {
        { bind(source); }

        @Override
        protected T computeValue() { return source.get(); }
    };
}
项目:tenhou-visualizer    文件:BindingHelper.java   
public static StringBinding covertOrDefault(ObservableObjectValue observableObjectValue, String defaultMessage) {
    return Bindings.when(Bindings.isNotNull(observableObjectValue))
            .then(Bindings.convert(observableObjectValue))
            .otherwise(defaultMessage);
}
项目:osrs-equipment-builder    文件:MainApp.java   
public ObservableObjectValue<NPC> getTargetData() {
    return targetProperty;
}
项目:LoliXL    文件:McdirGameVersion.java   
@Override
public ObservableObjectValue<Image> getIcon() {
    return icon;
}
项目:LoliXL    文件:FxConstants.java   
public static <T> ObservableObjectValue<T> object(T constant) {
    return new ObjectConstant<T>(constant);
}
项目:LoliXL    文件:DisplayableItem.java   
default ObservableObjectValue<Image> getIcon() {
    return FxConstants.object(null);
}
项目:LoliXL    文件:Tile.java   
static DoubleBinding createPerspectivePropertyBinding(Function<Perspective, Double> func, ObservableObjectValue<Perspective> perspective) {
    return Bindings.createDoubleBinding(() -> func.apply(perspective.get()), perspective);
}
项目:LoliXL    文件:ImageLoading.java   
public static ObservableObjectValue<Image> load(String location) {
    return load0(location, 4);
}
项目:LoliXL    文件:ImageLoading.java   
private static ObservableObjectValue<Image> load0(String location, int frames) {
    Class<?> caller = ClassUtils.getClassContext()[frames];
    return ServiceUtils.doWithService(ImageLoadingService.class, caller, service -> service.load(location, caller.getClassLoader()));
}
项目:LoliXL    文件:DownloadCenterPresenter.java   
@Override
public ObservableObjectValue<Image> getIcon() {
    return ImageLoading.load("img/org.to2mbn.lolixl.ui.download_center/icon.png");
}
项目:LoliXL    文件:SettingsPresenter.java   
@Override
public ObservableObjectValue<Image> getIcon() {
    return ImageLoading.load("img/org.to2mbn.lolixl.settings/icon.png");
}
项目:LoliXL    文件:BackgroundServiceImpl.java   
@Override
public ObservableObjectValue<BackgroundProvider> getCurrentBackgroundProvider() {
    return currentBackgroundProvider;
}
项目:LoliXL    文件:BackgroundServiceImpl.java   
@Override
public ObservableObjectValue<Background> getCurrentBackground() {
    return currentBackground;
}
项目:LoliXL    文件:DefaultBackground.java   
@Override
public ObservableObjectValue<Image> getBackgroundImage() {
    return ImageLoading.load("img/org.to2mbn.lolixl.ui.theme.background.default/background.jpg");
}
项目:LoliXL    文件:DefaultTheme.java   
@Override
public ObservableObjectValue<Image> getIcon() {
    return FxConstants.object(null);
}
项目:LoliXL    文件:ImageLoadingServiceImpl.java   
@Override
public ObservableObjectValue<Image> load(String location, ClassLoader caller) {
    // TODO: 使图像可以通过Theme修改
    // TODO: 图像加载缓存
    return FxConstants.object(ClassUtils.doWithContextClassLoader(caller, () -> new Image(location)));
}
项目:LoliXL    文件:OfflineAuthenticationService.java   
@Override
public ObservableObjectValue<Image> getIcon() {
    // TODO Auto-generated method stub
    return FxConstants.object(null);
}
项目:ISAAC    文件:PncsItem.java   
public PncsItem(String name, int id, ObservableObjectValue<String> displayType)
{
    this.name = name;
    this.id = id;
    this.displayType = displayType;
}
项目:ISAAC    文件:PncsItem.java   
public PncsItem(Pncs pncs, ObservableObjectValue<String> displayType)
{
    this.name = pncs.getName();
    this.id = pncs.getId();
    this.displayType = displayType;
}
项目:assertj-javafx    文件:ObservableObjectValueAssert.java   
protected ObservableObjectValueAssert(ObservableObjectValue<T> actual) {
    super(actual, ObservableObjectValueAssert.class);
}
项目:assertj-javafx    文件:Object_HasNotNullValue_Test.java   
@Test
public void testObservableObjectValue(){
    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);

    assertThat(actual).hasNotNullValue();
}
项目:assertj-javafx    文件:Object_HasNullValue_Test.java   
@Test
public void testObservableObjectValue(){
    ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>();

    assertThat(actual).hasNullValue();
}
项目:honest-profiler    文件:TreeExtractor.java   
/**
 * Constructor specifying the {@link CombinedGrouping} to be used when aggregating.
 * <p>
 * @param grouping the {@link CombinedGrouping} to be used when aggregating
 */
public TreeExtractor(ObservableObjectValue<CombinedGrouping> grouping)
{
    super();
    this.grouping = grouping;
}