本文整理汇总了Java中javafx.beans.value.ObservableObjectValue类的典型用法代码示例。如果您正苦于以下问题:Java ObservableObjectValue类的具体用法?Java ObservableObjectValue怎么用?Java ObservableObjectValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObservableObjectValue类属于javafx.beans.value包,在下文中一共展示了ObservableObjectValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBackground
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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;
}
示例2: bind
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
/**
* 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());
}
}
示例3: initializeTabChangeListener
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
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);
});
}
示例4: setItem
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
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());
}
示例5: initializeRulesPane
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
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);
}
示例6: makeDeleteMcdirButton
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
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;
}
示例7: testObservableObjectValue
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@Test
public void testObservableObjectValue(){
ObservableObjectValue<TestPerson> actual = new SimpleObjectProperty<>(person);
assertThat(actual).hasValue(person);
assertThat(actual).hasSameValue(actual);
}
示例8: shoud_pass_if_actual_has_given_value
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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);
}
示例9: should_fail_if_actual_has_wrong_value
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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>");
}
}
示例10: should_fail_if_expectedValue_is_null
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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");
}
}
示例11: should_pass_if_actual_has_expected_value
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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);
}
示例12: should_pass_if_both_observables_has_value_of_null
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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);
}
示例13: should_fail_if_only_actual_has_value_of_null
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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>");
}
}
示例14: should_fail_if_only_expected_has_value_of_null
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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>");
}
}
示例15: should_fail_if_actual_has_wrong_value
import javafx.beans.value.ObservableObjectValue; //导入依赖的package包/类
@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>");
}
}