Java Code Examples for javafx.scene.text.Text#setUserData()

The following examples show how to use javafx.scene.text.Text#setUserData() . 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: DataQueryController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
protected void loadList() {
    try {
        if (dataOperation == null) {
            return;
        }
        listView.getItems().clear();
        List<QueryCondition> list = TableQueryCondition.readList(dataController.dataName, dataOperation);
        if (list == null || list.isEmpty()) {
            return;
        }
        for (QueryCondition condition : list) {
            Text node = new Text(condition.getTitle().replaceAll("\n", " "));
            final long id = condition.getQcid();
            node.setUserData(condition);
            listView.getItems().add(node);
        }
    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 2
Source File: GeographyCodeSelectorController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
protected void addNode(TreeItem<Text> node, GeographyCode parent, GeographyCode child) {
    if (node == null || parent == null || child == null) {
        return;
    }
    if (node.getValue().getUserData() != null) {
        long current = (long) (node.getValue().getUserData());
        if (current == parent.getGcid()) {
            Text childNode = new Text(child.getName());
            childNode.setOnMouseClicked((MouseEvent event) -> {
                userController.codeSelected(child);
            });
            childNode.setUserData(child.getGcid());
            TreeItem<Text> codeItem = new TreeItem(childNode);
            node.getChildren().add(codeItem);
            node.setExpanded(true);
            return;
        }
    }
    if (node.isLeaf()) {
        return;
    }
    for (TreeItem<Text> subNode : node.getChildren()) {
        addNode(subNode, parent, child);
    }
}
 
Example 3
Source File: GeographyCodeSelectorController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void addNodes(TreeItem<Text> parent, List<GeographyCode> codes,
        List<Long> haveChildren) {
    if (parent == null || codes == null || codes.isEmpty()) {
        return;
    }
    for (GeographyCode code : codes) {
        long codeid = code.getGcid();
        Text codeNode = new Text(code.getName());
        codeNode.setOnMouseClicked((MouseEvent event) -> {
            userController.codeSelected(code);
        });
        codeNode.setUserData(codeid);
        TreeItem<Text> codeItem = new TreeItem(codeNode);
        parent.getChildren().add(codeItem);

        if (!leafCheck.isSelected()
                || (haveChildren != null && haveChildren.contains(codeid))) {
            TreeItem<Text> dummyItem = new TreeItem(new Text("Loading"));
            codeItem.getChildren().add(dummyItem);
            codeItem.setExpanded(false);
            codeItem.expandedProperty().addListener(
                    (ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) -> {
                        if (newVal && !codeItem.isLeaf() && !loaded(codeItem)) {
                            nodeTree(codeItem, code);
                        }
                    });
        }
    }
}
 
Example 4
Source File: WhitespaceOverlayFactory.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Text createTextNode(String text, Collection<String> styleClasses, int start, int end) {
	Text t = new Text(text);
	t.setTextOrigin(VPos.TOP);
	t.getStyleClass().add("text");
	t.setOpacity(0.3);
	t.getStyleClass().addAll(styleClasses);
	t.setUserData(new Range(start, end));
	return t;
}