Java Code Examples for javafx.scene.Parent#lookupAll()

The following examples show how to use javafx.scene.Parent#lookupAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VariableHighlighter.java    From milkman with MIT License 5 votes vote down vote up
private List<Rectangle> processCodeAreas(Parent pane) {
        var nodes = pane.lookupAll("ContentEditor");
        ArrayList<Rectangle> result = new ArrayList<>();


        for (Node node : nodes) {
            ArrayList<TextBoundingBox> bboxes = new ArrayList<>();
            var area = ((ContentEditor) node).getCodeArea();
            LiveList<Paragraph<Collection<String>, String, Collection<String>>> visibleParagraphs = area.getVisibleParagraphs();
            int visibleParIdx = 0;
            for (Paragraph visiblePar : visibleParagraphs) {
                int parIdx = area.visibleParToAllParIndex(visibleParIdx);
                var parMatcher = tagPattern.matcher(visiblePar.getText());
                if (parMatcher.find()){
//                    var bounds = area.getVisibleParagraphBoundsOnScreen(visibleParIdx);
                    var matchStartIdxAbs = area.getAbsolutePosition(parIdx, parMatcher.start());
                    var bounds = area.getCharacterBoundsOnScreen(matchStartIdxAbs, matchStartIdxAbs + parMatcher.group().length());
                    bounds.ifPresent(b -> {
                        var localBounds = parent.sceneToLocal(area.localToScene(area.screenToLocal(b)));
                        bboxes.add(new TextBoundingBox(parMatcher.group(1),
                                localBounds.getMinX(), localBounds.getMinY(), localBounds.getWidth(), localBounds.getHeight()));
                    });

                }
                visibleParIdx++;
            }
            var rectangles = getRectangles(area, bboxes);
            if (rectangles.size() > 0){
                result.addAll(rectangles);
                boxes.put(area, rectangles);
            }
        }

        return result;
    }
 
Example 2
Source File: VariableHighlighter.java    From milkman with MIT License 5 votes vote down vote up
private Set<Node> getTextNodes(Parent pane) {
    Set<Node> labeledTextNodes = pane.lookupAll("LabeledText");
    Set<Node> textNodes = pane.lookupAll("Text");
    Set<Node> nodes = new HashSet<>();
    nodes.addAll(labeledTextNodes);
    nodes.addAll(textNodes);
    return nodes;
}
 
Example 3
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected String _getLabeledBy() {
    Parent root = node.getScene().getRoot();
    Set<Node> allLabels = root.lookupAll(".label");
    for (Node node2 : allLabels) {
        Label label = (Label) node2;
        if (label.getLabelFor() == node) {
            return label.getText();
        }
    }
    return null;
}
 
Example 4
Source File: JFXHighlighter.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private Set<Node> getTextNodes(Parent pane) {
    Set<Node> labeledTextNodes = pane.lookupAll("LabeledText");
    Set<Node> textNodes = pane.lookupAll("Text");
    Set<Node> nodes = new HashSet<>();
    nodes.addAll(labeledTextNodes);
    nodes.addAll(textNodes);
    return nodes;
}