use of javafx.scene.control.TreeItem in project tokentool by RPTools.
the class TokenTool_Controller method initialize.
@FXML
void initialize() {
// Note: A Pane is added to the compositeTokenPane so the ScrollPane doesn't consume the mouse events
assert fileManageOverlaysMenu != null : "fx:id=\"fileManageOverlaysMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert fileSaveAsMenu != null : "fx:id=\"fileSaveAsMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert fileExitMenu != null : "fx:id=\"fileExitMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert editCaptureScreenMenu != null : "fx:id=\"editCaptureScreenMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert editCopyImageMenu != null : "fx:id=\"editCopyImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert editPasteImageMenu != null : "fx:id=\"editPasteImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert helpAboutMenu != null : "fx:id=\"helpAboutMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert saveOptionsPane != null : "fx:id=\"saveOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayOptionsPane != null : "fx:id=\"overlayOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert backgroundOptionsPane != null : "fx:id=\"backgroundOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert zoomOptionsPane != null : "fx:id=\"zoomOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert compositeTokenPane != null : "fx:id=\"compositeTokenPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert tokenPreviewPane != null : "fx:id=\"tokenPreviewPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert portraitScrollPane != null : "fx:id=\"portraitScrollPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert compositeGroup != null : "fx:id=\"compositeGroup\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayTreeView != null : "fx:id=\"overlayTreeview\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert portraitImageView != null : "fx:id=\"portraitImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert maskImageView != null : "fx:id=\"maskImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayImageView != null : "fx:id=\"overlayImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert tokenImageView != null : "fx:id=\"tokenImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert useFileNumberingCheckbox != null : "fx:id=\"useFileNumberingCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayUseAsBaseCheckbox != null : "fx:id=\"overlayUseAsBaseCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert clipPortraitCheckbox != null : "fx:id=\"clipPortraitCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert fileNameTextField != null : "fx:id=\"fileNameTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert fileNameSuffixLabel != null : "fx:id=\"fileNameSuffixLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert fileNameSuffixTextField != null : "fx:id=\"fileNameSuffixTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayNameLabel != null : "fx:id=\"overlayNameLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert backgroundColorPicker != null : "fx:id=\"backgroundColorPicker\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayAspectToggleButton != null : "fx:id=\"overlayAspectToggleButton\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert portraitTransparencySlider != null : "fx:id=\"portraitTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert portraitBlurSlider != null : "fx:id=\"portraitBlurSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert portraitGlowSlider != null : "fx:id=\"portraitGlowSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayTransparencySlider != null : "fx:id=\"overlayTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayWidthSpinner != null : "fx:id=\"overlayWidthSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayHeightSpinner != null : "fx:id=\"overlayHeightSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
assert overlayTreeProgressBar != null : "fx:id=\"overlayTreeProgressIndicator\" was not injected: check your FXML file 'ManageOverlays.fxml'.";
executorService = Executors.newCachedThreadPool(runable -> {
loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable);
loadOverlaysThread.setDaemon(true);
return loadOverlaysThread;
});
overlayTreeView.setShowRoot(false);
overlayTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> updateCompositImageView((TreeItem<Path>) newValue));
addPseudoClassToLeafs(overlayTreeView);
// Bind color picker to compositeTokenPane background fill
backgroundColorPicker.setValue(Color.TRANSPARENT);
ObjectProperty<Background> background = compositeTokenPane.backgroundProperty();
background.bind(Bindings.createObjectBinding(() -> {
BackgroundFill fill = new BackgroundFill(backgroundColorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY);
return new Background(fill);
}, backgroundColorPicker.valueProperty()));
// Bind transparency slider to portraitImageView opacity
portraitTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
portraitImageView.setOpacity(new_val.doubleValue());
updateTokenPreviewImageView();
}
});
// // Restrict text field to valid filename characters
// Pattern validDoubleText = Pattern.compile("[^a-zA-Z0-9\\\\._ \\\\/`~!@#$%\\\\^&\\\\(\\\\)\\\\-\\\\=\\\\+\\\\[\\\\]\\\\{\\\\}',\\\\\\\\:]");
// Pattern validText = Pattern.compile("[^a-zA-Z0-9 ]");
// TextFormatter<> textFormatter = new TextFormatter<>(
// change -> {
// String newText = change.getControlNewText();
// if (validText.matcher(newText).matches()) {
// return change;
// } else
// return null;
// });
// UnaryOperator<TextFormatter.Change> filter = new UnaryOperator<TextFormatter.Change>() {
// @Override
// public TextFormatter.Change apply(TextFormatter.Change t) {
// String validText = "[^a-zA-Z0-9]";
//
// if (t.isReplaced())
// if (t.getText().matches(validText))
// t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd()));
//
// if (t.isAdded()) {
// if (t.getText().matches(validText)) {
// return null;
// }
// }
//
// return t;
// }
// };
UnaryOperator<Change> filter = change -> {
String text = change.getText();
if (text.matches(AppConstants.VALID_FILE_NAME_PATTERN)) {
return change;
} else {
change.setText(FileSaveUtil.cleanFileName(text));
;
return change;
}
//
// return null;
};
TextFormatter<String> textFormatter = new TextFormatter<>(filter);
fileNameTextField.setTextFormatter(textFormatter);
// Effects
GaussianBlur gaussianBlur = new GaussianBlur(0);
Glow glow = new Glow(0);
gaussianBlur.setInput(glow);
// Bind blur slider to portraitImageView opacity
portraitBlurSlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
gaussianBlur.setRadius(new_val.doubleValue());
portraitImageView.setEffect(gaussianBlur);
updateTokenPreviewImageView();
}
});
// Bind glow slider to portraitImageView opacity
portraitGlowSlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
glow.setLevel(new_val.doubleValue());
portraitImageView.setEffect(gaussianBlur);
updateTokenPreviewImageView();
}
});
// Bind transparency slider to overlayImageView opacity
overlayTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
overlayImageView.setOpacity(new_val.doubleValue());
updateTokenPreviewImageView();
}
});
// Bind width/height spinners to overlay width/height
overlayWidthSpinner.getValueFactory().valueProperty().bindBidirectional(overlayHeightSpinner.getValueFactory().valueProperty());
overlayWidthSpinner.valueProperty().addListener((observable, oldValue, newValue) -> overlayWidthSpinner_onTextChanged(oldValue, newValue));
overlayHeightSpinner.valueProperty().addListener((observable, oldValue, newValue) -> overlayHeightSpinner_onTextChanged(oldValue, newValue));
}
use of javafx.scene.control.TreeItem in project org.csstudio.display.builder by kasemir.
the class WidgetTree method setModel.
/**
* @param model Model to display as widget tree
*/
public void setModel(final DisplayModel model) {
// Could recursively remove all old model tree elements,
// on UI thread, one by one.
// Faster: Unlink listeners and then replace the whole
// tree model which was created in background.
final DisplayModel old_model = this.model;
if (old_model != null) {
old_model.runtimeChildren().removePropertyListener(children_listener);
for (Widget widget : old_model.runtimeChildren().getValue()) removeWidgetListeners(widget);
widget2tree.clear();
tab_name2tree.clear();
}
this.model = model;
// Might be called on UI thread, move off
EditorUtil.getExecutor().execute(() -> {
final TreeItem<WidgetOrTab> root = new TreeItem<WidgetOrTab>(WidgetOrTab.of(model));
if (model != null) {
widget2tree.put(model, root);
for (Widget widget : model.runtimeChildren().getValue()) addWidget(widget, -1);
root.setExpanded(true);
model.runtimeChildren().addPropertyListener(children_listener);
}
logger.log(Level.FINE, "Computed new tree on {0}, updating UI", Thread.currentThread().getName());
Platform.runLater(() -> {
tree_view.setRoot(root);
setSelectedWidgets(editor.getWidgetSelectionHandler().getSelection());
});
});
}
use of javafx.scene.control.TreeItem in project org.csstudio.display.builder by kasemir.
the class WidgetTree method bindSelections.
/**
* Link selections in tree view and model
*/
private void bindSelections() {
// Update selected widgets in model from selection in tree_view
final ObservableList<TreeItem<WidgetOrTab>> tree_selection = tree_view.getSelectionModel().getSelectedItems();
InvalidationListener listener = (Observable observable) -> {
if (!active.compareAndSet(false, true))
return;
try {
final List<Widget> widgets = new ArrayList<>(tree_selection.size());
for (TreeItem<WidgetOrTab> item : tree_selection) {
final WidgetOrTab wot = item.getValue();
final Widget widget = wot.isWidget() ? wot.getWidget() : wot.getTab().getWidget();
if (!widgets.contains(widget))
widgets.add(widget);
}
;
logger.log(Level.FINE, "Selected in tree: {0}", widgets);
editor.getWidgetSelectionHandler().setSelection(widgets);
} finally {
active.set(false);
}
};
tree_selection.addListener(listener);
// Update selection in tree_view from selected widgets in model
editor.getWidgetSelectionHandler().addListener(this::setSelectedWidgets);
}
use of javafx.scene.control.TreeItem in project blue by kunstmusik.
the class UserSoundObjectLibrary method buildContextMenu.
public ContextMenu buildContextMenu(TreeView<LibraryItem<SoundObject>> treeView) {
ContextMenu popupMenu = new ContextMenu();
// popupMenu.getItems().add(new MenuItem("Test"));
ObservableList<TreeItem<LibraryItem<SoundObject>>> selectedItems = treeView.getSelectionModel().getSelectedItems();
final ScoreController.ScoreObjectBuffer scoreObjectBuffer = ScoreController.getInstance().getScoreObjectBuffer();
// FOLDER MENU ITEMS
List<MenuItem> folderMenuItems = new ArrayList<>();
MenuItem addFolder = new MenuItem("Add Folder");
addFolder.setOnAction(evt -> {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
item.getChildren().add(new LibraryTreeItem(new LibraryItem<>("New Folder")));
});
MenuItem deleteFolder = new MenuItem("Delete Folder");
deleteFolder.setOnAction(evt -> {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
item.getParent().getChildren().remove(item);
});
MenuItem paste = new MenuItem("Paste SoundObject");
paste.setOnAction(evt -> {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
SoundObject sObj = (SoundObject) scoreObjectBuffer.scoreObjects.get(0).deepCopy();
if (!SoundObjectUtilities.isOrContainsInstance(sObj)) {
item.getChildren().add(new LibraryTreeItem(new LibraryItem<>(sObj)));
}
});
folderMenuItems.add(addFolder);
folderMenuItems.add(deleteFolder);
folderMenuItems.add(paste);
// FOLDER MENU ITEMS
List<MenuItem> sObjMenuItems = new ArrayList<>();
MenuItem cut = new MenuItem("Cut");
cut.setOnAction(evt -> {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
SoundObject sObj = item.getValue().getValue();
if (sObj == null) {
return;
}
scoreObjectBuffer.clear();
scoreObjectBuffer.scoreObjects.add(sObj.deepCopy());
scoreObjectBuffer.layerIndexes.add(0);
item.getParent().getChildren().remove(item);
});
MenuItem copy = new MenuItem("Copy");
copy.setOnAction(evt -> {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
SoundObject sObj = item.getValue().getValue();
if (sObj == null) {
return;
}
scoreObjectBuffer.clear();
scoreObjectBuffer.scoreObjects.add(sObj.deepCopy());
scoreObjectBuffer.layerIndexes.add(0);
});
MenuItem delete = new MenuItem("Delete");
delete.setOnAction(evt -> {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
item.getParent().getChildren().remove(item);
});
sObjMenuItems.add(cut);
sObjMenuItems.add(copy);
sObjMenuItems.add(new SeparatorMenuItem());
sObjMenuItems.add(delete);
popupMenu.getItems().addAll(folderMenuItems);
popupMenu.getItems().addAll(sObjMenuItems);
popupMenu.setOnShowing(evt -> {
if (selectedItems.size() == 1) {
TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
boolean isFolder = item.getValue().getValue() == null;
deleteFolder.setDisable(item == soundObjectLibrary.getRoot());
if (isFolder) {
boolean isScoreObj = scoreObjectBuffer.scoreObjects.size() == 1 && scoreObjectBuffer.scoreObjects.get(0) instanceof SoundObject;
if (isScoreObj) {
SoundObject sObj = (SoundObject) scoreObjectBuffer.scoreObjects.get(0);
paste.setDisable(SoundObjectUtilities.isOrContainsInstance(sObj));
} else {
paste.setDisable(true);
}
}
for (MenuItem menuItem : folderMenuItems) {
menuItem.setVisible(isFolder);
}
for (MenuItem menuItem : sObjMenuItems) {
menuItem.setVisible(!isFolder);
}
}
});
return popupMenu;
}
use of javafx.scene.control.TreeItem in project blue by kunstmusik.
the class SoundObjectExportPane method jbInit.
private void jbInit() throws Exception {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
soundObjectListPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
categoryPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
cateogriesLabel.setText(BlueSystem.getString("common.categories"));
categoryPanel.setLayout(new BorderLayout());
this.add(namePasswordPanel, BorderLayout.NORTH);
this.add(mainSplitPane, BorderLayout.CENTER);
this.add(jPanel2, BorderLayout.SOUTH);
descriptionText.setText(BlueSystem.getString("blueShare.enterDescription"));
descriptionText.setLineWrap(true);
descriptionScrollPane.setBorder(new TitledBorder(null, BlueSystem.getString("blueShare.instrDescription")));
submitButton.setText(BlueSystem.getString("common.submit"));
soundObjectListPanel.setLayout(new BorderLayout());
iLabel.setText("SoundObjects from Library");
// soundObjectLibraryTree.setSelectionModel(TreeSelectionModel.SINGLE_TREE_SELECTION);
topSplitPane.add(soundObjectListPanel, JSplitPane.LEFT);
soundObjectListPanel.add(soundObjectListScrollPane, BorderLayout.CENTER);
soundObjectListPanel.add(iLabel, BorderLayout.NORTH);
soundObjectListScrollPane.getViewport().add(soundObjectLibraryTree, null);
descriptionScrollPane.getViewport().add(descriptionText, null);
jPanel2.add(submitButton, null);
topSplitPane.setDividerLocation(300);
mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
mainSplitPane.add(topSplitPane, JSplitPane.TOP);
mainSplitPane.add(descriptionScrollPane, JSplitPane.BOTTOM);
topSplitPane.add(categoryPanel, JSplitPane.RIGHT);
categoryPanel.add(cateogriesLabel, BorderLayout.NORTH);
categoryPanel.add(categoryScrollPane, BorderLayout.CENTER);
categoryScrollPane.getViewport().add(categoryTree, null);
mainSplitPane.setDividerLocation(200);
submitButton.addActionListener((ActionEvent e) -> {
submitSoundObject();
});
soundObjectLibraryTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
TreePath path = soundObjectLibraryTree.getSelectionPath();
if (path == null) {
descriptionText.setText(SELECT_INSTR_TEXT);
descriptionText.setEnabled(false);
return;
}
Object userObj = path.getLastPathComponent();
TreeItem<LibraryItem<SoundObject>> node = (TreeItem<LibraryItem<SoundObject>>) userObj;
if (!node.isLeaf()) {
descriptionText.setText(SELECT_INSTR_TEXT);
descriptionText.setEnabled(false);
return;
}
SoundObject instr = node.getValue().getValue();
if (instr instanceof Sound) {
descriptionText.setText(((Sound) instr).getComment());
} else if (instr instanceof ObjectBuilder) {
descriptionText.setText(((ObjectBuilder) instr).getComment());
} else {
descriptionText.setText("");
}
descriptionText.setEnabled(true);
}
});
}
Aggregations