• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Val类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.reactfx.value.Val的典型用法代码示例。如果您正苦于以下问题:Java Val类的具体用法?Java Val怎么用?Java Val使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Val类属于org.reactfx.value包,在下文中一共展示了Val类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: apply

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
public Node apply(int lineNumber) {
    Polygon triangle = new Polygon(0.0, 0.0, 40.0, 5.0, 0.0, 10.0);
    triangle.setFill(Color.GREEN);

    ObservableValue<Boolean> visible = Val.map(
            shownLine,
            sl -> sl == lineNumber);

    triangle.visibleProperty().bind(
            Val.flatMap(triangle.sceneProperty(), scene -> {
                return scene != null ? visible : Val.constant(false);
            })
    );

    return triangle;
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:18,代码来源:ArrowFactory.java


示例2: apply

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
public Node apply(int idx) {
    Val<String> formatted = nParagraphs.map(n -> format(idx + 1, n));
    Label lineNo = new Label();
    lineNo.setFont(DEFAULT_FONT);
    lineNo.setBackground(DEFAULT_BACKGROUND);
    highlightList
            .stream()
            .filter(range -> idx >= range.getFirst() && idx < range.getSecond())
            .forEach(range -> {
                lineNo.setBackground(DEFAULT_BACKGROUND_NEW);
            });
    lineNo.setTextFill(DEFAULT_TEXT_FILL);
    lineNo.setPadding(DEFAULT_INSETS);
    lineNo.getStyleClass().add("lineno");

    // bind label's text to a Val that stops observing area's paragraphs
    // when lineNo is removed from scene
    lineNo.textProperty().bind(formatted.conditionOnShowing(lineNo));

    return lineNo;
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:23,代码来源:DiffLineNumberFactory.java


示例3: apply

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
public Node apply(int idx) {
    Val<String> formatted = nParagraphs.map(n -> format(idx+1, n));

    Label lineNo = new Label();
    lineNo.setFont(DEFAULT_FONT);
    lineNo.setBackground(DEFAULT_BACKGROUND);
    lineNo.setTextFill(DEFAULT_TEXT_FILL);
    lineNo.setPadding(DEFAULT_INSETS);
    lineNo.setAlignment(Pos.TOP_RIGHT);
    lineNo.getStyleClass().add("lineno");

    // bind label's text to a Val that stops observing area's paragraphs
    // when lineNo is removed from scene
    lineNo.textProperty().bind(formatted.conditionOnShowing(lineNo));

    return lineNo;
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:19,代码来源:LineNumberFactory.java


示例4: ParagraphBox

import org.reactfx.value.Val; //导入依赖的package包/类
ParagraphBox(Paragraph<PS, SEG, S> par, BiConsumer<TextFlow, PS> applyParagraphStyle,
             Function<StyledSegment<SEG, S>, Node> nodeFactory) {
    this.getStyleClass().add("paragraph-box");
    this.text = new ParagraphText<>(par, nodeFactory);
    applyParagraphStyle.accept(this.text, par.getParagraphStyle());
    this.index = Var.newSimpleVar(0);
    getChildren().add(text);
    graphic = Val.combine(
            graphicFactory,
            this.index,
            (f, i) -> f != null ? f.apply(i) : null);
    graphic.addListener((obs, oldG, newG) -> {
        if(oldG != null) {
            getChildren().remove(oldG);
        }
        if(newG != null) {
            getChildren().add(newG);
        }
    });
    graphicOffset.addListener(obs -> requestLayout());
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:22,代码来源:ParagraphBox.java


示例5: test

import org.reactfx.value.Val; //导入依赖的package包/类
@Test
public void test() {
    LiveList<Integer> list = new LiveArrayList<>(1, 2, 4);
    Var<IndexRange> range = Var.newSimpleVar(new IndexRange(0, 0));
    Val<Integer> rangeSum = list.reduceRange(range, (a, b) -> a + b);

    assertNull(rangeSum.getValue());

    List<Integer> observed = new ArrayList<>();
    rangeSum.values().subscribe(sum -> {
        observed.add(sum);
        if(sum == null) {
            range.setValue(new IndexRange(0, 2));
        } else if(sum == 3) {
            list.addAll(1, Arrays.asList(8, 16));
        } else if(sum == 9) {
            range.setValue(new IndexRange(2, 4));
        }
    });

    assertEquals(Arrays.asList(null, 3, 9, 18), observed);
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:23,代码来源:ListRangeReductionTest.java


示例6: testLateListNotifications

import org.reactfx.value.Val; //导入依赖的package包/类
/**
 * Tests the case when both list and range have been modified and range
 * change notification arrived first.
 */
@Test
public void testLateListNotifications() {
    SuspendableList<Integer> list = new LiveArrayList<Integer>(1, 2, 3).suspendable();
    SuspendableVar<IndexRange> range = Var.newSimpleVar(new IndexRange(0, 3)).suspendable();
    Val<Integer> rangeSum = list.reduceRange(range, (a, b) -> a + b);

    list.suspendWhile(() -> {
        range.suspendWhile(() -> {
            list.addAll(4, 5, 6);
            range.setValue(new IndexRange(3, 6));
        });
    });
    assertEquals(15, rangeSum.getValue().intValue());

    // most importantly, this test tests that no IndexOutOfBoundsException is thrown
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:21,代码来源:ListRangeReductionTest.java


示例7: testMemoizedItemsChangeWithinForce

import org.reactfx.value.Val; //导入依赖的package包/类
@Test
public void testMemoizedItemsChangeWithinForce() {
    LiveList<Integer> src = new LiveArrayList<>(1, 2, 4, 8, 16, 32);
    MemoizationList<Integer> memo1 = src.memoize();
    MemoizationList<Integer> memo2 = memo1.map(Function.identity()).memoize();
    Val<Integer> memo1Sum = memo1.memoizedItems().reduce((a, b) -> a + b).orElseConst(0);
    memo1Sum.addListener((obs, oldVal, newVal) -> memo2.forget(0, memo2.size()));

    List<Integer> memo2Mirror = new ArrayList<>();
    memo2.memoizedItems().observeModifications(mod -> {
        memo2Mirror.subList(mod.getFrom(), mod.getFrom() + mod.getRemovedSize()).clear();
        memo2Mirror.addAll(mod.getFrom(), mod.getAddedSubList());
        // the main part of this test is that it does not throw IndexOutOfBoundsException
    });
    memo2.force(3, 6);

    assertEquals(Arrays.asList(32), memo2Mirror);
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:19,代码来源:MemoizationListTest.java


示例8: test

import org.reactfx.value.Val; //导入依赖的package包/类
@Test
public void test() {
    ObservableList<Integer> list = FXCollections.observableArrayList();
    Val<Integer> size = LiveList.sizeOf(list);
    List<Integer> sizes = new ArrayList<>();
    Subscription sub = EventStreams.valuesOf(size).subscribe(sizes::add);
    list.add(1);
    list.addAll(2, 3, 4);
    assertEquals(Arrays.asList(0, 1, 4), sizes);

    sub.unsubscribe();
    sizes.clear();
    list.addAll(5, 6);
    assertEquals(Arrays.asList(), sizes);

    EventStreams.valuesOf(size).subscribe(sizes::add);
    list.addAll(7, 8);
    assertEquals(Arrays.asList(6, 8), sizes);
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:20,代码来源:ListSizeTest.java


示例9: testWhenBound

import org.reactfx.value.Val; //导入依赖的package包/类
@Test
public void testWhenBound() {
    ObservableList<Integer> list = FXCollections.observableArrayList(1, 1, 1, 1, 1);
    Val<Integer> sum = LiveList.reduce(list, (a, b) -> a + b);
    Var<Integer> lastObserved = Var.newSimpleVar(sum.getValue());

    assertEquals(5, lastObserved.getValue().intValue());

    sum.addListener((obs, oldVal, newVal) -> {
        assertEquals(lastObserved.getValue(), oldVal);
        lastObserved.setValue(newVal);
    });

    list.addAll(2, Arrays.asList(2, 2));
    assertEquals(9, lastObserved.getValue().intValue());

    list.subList(3, 6).clear();
    assertEquals(5, lastObserved.getValue().intValue());
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:20,代码来源:ListReductionTest.java


示例10: VirtualWebView

import org.reactfx.value.Val; //导入依赖的package包/类
VirtualWebView(WebView webView) {
    this.webView = webView;
    getChildren().add(webView);

    totalWidth = Val.create(() -> Double.parseDouble(String.valueOf(webView.getEngine().executeScript("document.body.scrollWidth"))));
    totalHeight = Val.create(() -> Double.parseDouble(String.valueOf(webView.getEngine().executeScript("document.body.scrollHeight"))));
    estimateScrollX = Var.newSimpleVar(Double.parseDouble(String.valueOf(webView.getEngine().executeScript("window.pageXOffset || document.documentElement.scrollLeft"))));
    estimateScrollY = Var.newSimpleVar(Double.parseDouble(String.valueOf(webView.getEngine().executeScript("window.pageYOffset || document.documentElement.scrollTop"))));
}
 
开发者ID:jdesive,项目名称:textmd,代码行数:10,代码来源:VirtualWebView.java


示例11: apply

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
public Node apply(int lineNumber) {
    Polygon triangle = new Polygon(0.0, 0.0, 10.0, 5.0, 0.0, 10.0);
    triangle.setFill(Color.GREEN);
    ObservableValue<Boolean> visible = Val.map(shownLine, sl -> sl == lineNumber);
    triangle.visibleProperty().bind(
            Val.flatMap(triangle.sceneProperty(), scene -> {
                return scene != null ? visible : Val.constant(false);
            }));
    return triangle;
}
 
开发者ID:kasirgalabs,项目名称:ETUmulator,代码行数:12,代码来源:ArrowFunction.java


示例12: apply

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
public Node apply(int idx) {
    Val<String> formatted = paragraphs.map(n -> format(idx + 1, n));
    Label lineNo = new Label();
    lineNo.setCursor(Cursor.HAND);
    lineNo.setBackground(DEFAULT_BACKGROUND);
    lineNo.setPadding(DEFAULT_INSETS);
    lineNo.getStyleClass().add("lineno");
    lineNo.textProperty().bind(formatted.conditionOnShowing(lineNo));
    return lineNo;
}
 
开发者ID:kasirgalabs,项目名称:ETUmulator,代码行数:12,代码来源:LineNumberFunction.java


示例13: avoidFalseInvalidations

import org.reactfx.value.Val; //导入依赖的package包/类
private static <T> Val<T> avoidFalseInvalidations(Val<T> src) {
    return new ValBase<T>() {
        @Override
        protected T computeValue() {
            return src.getValue();
        }

        @Override
        protected Subscription connect() {
            return src.observeChanges((obs, oldVal,
                                       newVal) -> invalidate());
        }
    };
}
 
开发者ID:ChiralBehaviors,项目名称:Kramer,代码行数:15,代码来源:SizeTracker.java


示例14: RevertChangesDialog

import org.reactfx.value.Val; //导入依赖的package包/类
public RevertChangesDialog(Val<Git> git, Status firstStatus) {
    super(git);
    setTitle("Revert modified files");
    setResizable(true);

    ButtonType revertButtonType = new ButtonType("Revert...", ButtonBar.ButtonData.YES);
    setDialogPane(new RevertChangesDialogPane(git, new SelectableFileViewer(firstStatus), revertButtonType));
    setResultConverter(buttonType -> {
       if (buttonType.equals(revertButtonType)) {
           return revertChanges();
       } else {
           return null;
       }
    });
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:16,代码来源:RevertChangesDialog.java


示例15: RevertChangesDialogPaneBaseOld

import org.reactfx.value.Val; //导入依赖的package包/类
public RevertChangesDialogPaneBaseOld(Val<Git> git, F fileSelector, ButtonType revertButtonType) {
    super();
    this.git = git;
    this.fileViewer = fileSelector;

    this.revertButtonType = revertButtonType;
    getButtonTypes().add(revertButtonType);

    Button revertButton = (Button) lookupButton(revertButtonType);
    revertButton.setOnAction(ae -> revertChanges());

    revertButton.disableProperty().bind(Bindings.not(fileViewer.hasSelectedFilesProperty()));
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:14,代码来源:RevertChangesDialogPaneBaseOld.java


示例16: CommitDialogPane

import org.reactfx.value.Val; //导入依赖的package包/类
public CommitDialogPane(Val<Git> git, SelectableFileViewer fileViewer, ButtonType commitButton) {
    super(git);
    this.fileViewer = fileViewer;

    getButtonTypes().addAll(commitButton, ButtonType.CANCEL);
    Button button = (Button) lookupButton(commitButton);
    // commit button is disabled when there are no selected files
    button.disableProperty().bind(Bindings.not(fileViewer.hasSelectedFilesProperty()));

    splitter.setOrientation(Orientation.VERTICAL);
    splitter.getItems().addAll(
            // top
            fileViewer,

            // bottom
            new VBox(
                    new Label("Commit Message:"),
                    messageArea
            )
    );

    borderPane.setCenter(splitter);
    borderPane.setRight(new VBox(
            amendCheckBox
            // TODO: author & committer GUI components here
    ));
    setContent(borderPane);
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:29,代码来源:CommitDialogPane.java


示例17: CommitDialog

import org.reactfx.value.Val; //导入依赖的package包/类
public CommitDialog(Val<Git> git, Status firstStatus) {
    super(git);
    setTitle("Commit changes");
    setResizable(true);

    ButtonType commitButton = new ButtonType("Commit...", ButtonBar.ButtonData.YES);
    setDialogPane(new CommitDialogPane(git, new SelectableFileViewer(firstStatus), commitButton));
    setResultConverter(buttonType -> {
        if (buttonType.equals(commitButton)) {
            return addAndCommitSelectedFiles();
        } else {
            return null;
        }
    });
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:16,代码来源:CommitDialog.java


示例18: RevertChangesDialogPane

import org.reactfx.value.Val; //导入依赖的package包/类
public RevertChangesDialogPane(Val<Git> git, SelectableFileViewer fileViewer, ButtonType revertButtonType) {
    super(git);
    this.fileViewer = fileViewer;

    vbox.getChildren().addAll(
            new Label("Revert selected files back to previous commit"),
            fileViewer
    );
    setContent(vbox);
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:11,代码来源:RevertChangesDialogPane.java


示例19: initialize

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
    public void initialize(URL location, ResourceBundle resources) {
        executor = Executors.newSingleThreadExecutor();
        codeArea = new CodeArea();
        codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
        OkButton.disableProperty().bind(Val.map(codeArea.lengthProperty(), n -> n == 0));
        EventStream<?> richChanges = codeArea.richChanges();
        richChanges
                .successionEnds(Duration.ofMillis(500))
                .supplyTask(this::computeHighlightingAsync)
                .awaitLatest(richChanges)
                .filterMap(t -> {
                    if (t.isSuccess()) {
                        return Optional.of(t.get());
                    } else {
                        t.getFailure().printStackTrace();
                        return Optional.empty();
                    }
                })
                .subscribe(this::applyHighlighting);
        codeArea.replaceText(0, 0, getSampleCode());
        borderPane.setCenter(codeArea);
        borderPane.getStylesheets().add(getClass().getResource("/styles/JavaKeywords.css").toExternalForm());
        JdkFolderLocation.setOnMouseClicked((event) -> {
            if (event.getClickCount() == 2) {
                DirectoryChooser directoryChooser = new DirectoryChooser();
                directoryChooser.setTitle("Select JDK installation folder");
                File file = new File("C:\\Program Files\\Java");
                if (file.isDirectory()) { //check if it exists and a folder
                    directoryChooser.setInitialDirectory(file);
                }
                File directory = directoryChooser.showDialog(primaryStage);
                if (directory != null) {
                    JdkFolderLocation.setText(directory.getAbsolutePath());
                }
            }
        });
//        borderPane.setCenter(new VirtualizedScrollPane<>(codeArea));
    }
 
开发者ID:EMostafaAli,项目名称:HlaListener,代码行数:40,代码来源:ScriptWindowController.java


示例20: apply

import org.reactfx.value.Val; //导入依赖的package包/类
@Override
public Node apply(int paragraphIndex) {
	int lineNo = paragraphIndex + 1;
	Val<String> text = lineCount.map(n -> {
		int digits = Math.max(3, (int) Math.floor(Math.log10(textArea.getParagraphs().size())) + 1);
		return String.format("%" + digits + "d", lineNo);
	});

	Label label = new Label();
	label.textProperty().bind(text.conditionOnShowing(label));
	label.setAlignment(Pos.TOP_RIGHT);
	label.setMaxHeight(Double.MAX_VALUE);
	label.getStyleClass().add("lineno");
	return label;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:16,代码来源:LineNumberGutterFactory.java



注:本文中的org.reactfx.value.Val类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IEntityClassListener类代码示例发布时间:2022-05-21
下一篇:
Java FloodlightTestModuleLoader类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap