本文整理汇总了Java中javafx.scene.control.TreeItem.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java TreeItem.getParent方法的具体用法?Java TreeItem.getParent怎么用?Java TreeItem.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TreeItem
的用法示例。
在下文中一共展示了TreeItem.getParent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTreeItemText
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
private String getTreeItemText(TreeItem<?> lastPathComponent) {
if (lastPathComponent == null || lastPathComponent.getValue() == null) {
return "";
}
String original = lastPathComponent.getValue().toString();
String itemText = original;
int suffixIndex = 0;
TreeItem<?> parent = lastPathComponent.getParent();
if (parent == null)
return itemText;
ObservableList<?> children = parent.getChildren();
for (int i = 0; i < children.indexOf(lastPathComponent); i++) {
TreeItem<?> child = (TreeItem<?>) children.get(i);
String current = child.getValue().toString();
if (current.equals(original)) {
itemText = String.format("%s(%d)", original, ++suffixIndex);
}
}
return itemText;
}
示例2: getTreeTableItemText
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") private String getTreeTableItemText(TreeTableView<?> treeTableView,
TreeItem<?> lastPathComponent) {
@SuppressWarnings("rawtypes")
TreeTableColumn treeTableColumn = treeTableView.getTreeColumn();
if (treeTableColumn == null) {
treeTableColumn = treeTableView.getColumns().get(0);
}
ObservableValue<?> cellObservableValue = treeTableColumn.getCellObservableValue(lastPathComponent);
String original = cellObservableValue.getValue().toString();
String itemText = original;
int suffixIndex = 0;
TreeItem<?> parent = lastPathComponent.getParent();
if (parent == null)
return itemText;
ObservableList<?> children = parent.getChildren();
for (int i = 0; i < children.indexOf(lastPathComponent); i++) {
TreeItem<?> child = (TreeItem<?>) children.get(i);
cellObservableValue = treeTableColumn.getCellObservableValue(child);
String current = cellObservableValue.getValue().toString();
if (current.equals(original)) {
itemText = String.format("%s(%d)", original, ++suffixIndex);
}
}
return itemText;
}
示例3: droppedOnEmptyTreeItem
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
private void droppedOnEmptyTreeItem(
TreeItem<LayerBaseContainer<? extends LayerBase>> currentlyDraggedLayerTreeItem) {
TreeItem<LayerBaseContainer<? extends LayerBase>> draggedParent = currentlyDraggedLayerTreeItem.getParent();
ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> draggedParentChildren = draggedParent != null
? draggedParent.getChildren() : null;
ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> rootChildren = this.getTreeView().getRoot()
.getChildren();
if (draggedParentChildren != null) {
draggedParentChildren.remove(currentlyDraggedLayerTreeItem);
}
DelayedExecuter.execute(100, () -> rootChildren.add(currentlyDraggedLayerTreeItem));
}
示例4: droppedOnTreeItem
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
private void droppedOnTreeItem(DragEvent event,
TreeItem<LayerBaseContainer<? extends LayerBase>> currentlyDraggedLayerTreeItem,
LayerBaseContainer<? extends LayerBase> targetItem) {
LayerBase targetLayer = targetItem.getLayerBase();
double y = event.getY();
double height = getHeight();
boolean above = y < height / 2;
TreeItem<LayerBaseContainer<? extends LayerBase>> targetParent = this.getTreeItem().getParent();
ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> targetParentChildren = targetParent
.getChildren();
TreeItem<LayerBaseContainer<? extends LayerBase>> draggedItem = currentlyDraggedLayerTreeItem;
TreeItem<LayerBaseContainer<? extends LayerBase>> draggedParent = draggedItem.getParent();
ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> draggedParentChildren = draggedParent != null
? draggedParent.getChildren() : null;
if (targetLayer instanceof EffectGroupLayer && (y >= height / 4 && y < height * 3 / 4)) {
// inside group
ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> groupChildren = getTreeItem()
.getChildren();
if (!groupChildren.equals(draggedParentChildren)) {
if (draggedParentChildren != null) {
draggedParentChildren.remove(draggedItem);
}
DelayedExecuter.execute(100, () -> groupChildren.add(0, draggedItem));
}
} else {
if (draggedParentChildren != null) {
ListItemUtil.swapItemsJavaFxThread(draggedParentChildren, targetParentChildren, draggedItem, this.getTreeItem(),
above);
} else {
ListItemUtil.insertItem(targetParentChildren, draggedItem, this.getTreeItem(), above);
}
}
}
示例5: notifyChangedLayer
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
/**
* Notify about changed layer.
*
* @param object the object.
* @param newLayer the new layer.
*/
public void notifyChangedLayer(@NotNull final Spatial object, @Nullable final SceneLayer newLayer) {
final TreeNode<?> objectNode = FACTORY_REGISTRY.createFor(object);
TreeItem<TreeNode<?>> objectItem = findItemForValue(getTreeView(), objectNode);
if (objectItem == null && newLayer != null) {
objectItem = new TreeItem<>(objectNode);
} else if (objectItem != null) {
final TreeItem<TreeNode<?>> parent = objectItem.getParent();
parent.getChildren().remove(objectItem);
}
final TreeItem<TreeNode<?>> newLayerItem =
newLayer == null ? null : findItemForValue(getTreeView(), FACTORY_REGISTRY.createFor(newLayer));
if (newLayerItem != null) {
newLayerItem.getChildren().add(objectItem);
}
}
示例6: buildTreePath
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
protected Object[] buildTreePath(TreeItem<?> selectedItem) {
List<Object> path = new ArrayList<>();
path.add(selectedItem);
while (selectedItem.getParent() != null) {
path.add(selectedItem.getParent());
selectedItem = selectedItem.getParent();
}
Collections.reverse(path);
return path.toArray();
}
示例7: selectItemAction
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
private void selectItemAction(ListChangeListener.Change<? extends TreeItem<FileComponent>> c) {
if (c.next() && c.wasAdded()) {
TreeItem<FileComponent> node = c.getList().get(c.getFrom());
if (node != null && node.getParent() != null) {
FileComponent cc = node.getValue();
Log.info("Select " + cc);
statusLabel.setText(cc.toString());
if (cc.getLength() > 0) {
hexPane.select(cc);
bytesBar.select(cc);
}
}
}
}
示例8: FindAbsolutePath
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
@Override
public String FindAbsolutePath(TreeItem<String> item, String s){
if((item.getParent()==null) || (item.getParent().getValue().equals("This PC"))){ return s;}
else{
String dir = item.getParent().getValue();
dir = dir+"\\"+s;
return FindAbsolutePath(item.getParent(), dir);
}
//return null;
}
示例9: findChildFullPath
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
/**
* Find path for {@link OptionSection} for use in retrieving correct {@link OptionSection} from {@link
* OptionsSettingsTree#optionSet}.
*
* @param selection
* @param childPath
*
* @return
*/
private String findChildFullPath( TreeItem<String> selection, String childPath )
{
TreeItem<String> parent = selection.getParent();
if ( parent != null && parent.getValue().length() > 0 )
return findChildFullPath(parent, Joiner.on(".").join(parent.getValue(), childPath));
else if ( parent.getValue().length() <= 0 )
return childPath;
else
throw new IllegalArgumentException(
"OptionsSettingsTree does not support a null root or a root with a value");
}
示例10: findRootParent
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
/**
* Retrieve selections most root parent in the form of TreeItem so it can later retrieve the root parents {@link
* OptionSection}.
* <p>
* NOTE: The most root parent of the selection could be the selection itself.
*
* @param selection
*
* @return
*/
private TreeItem<String> findRootParent( TreeItem<String> selection )
{
TreeItem<String> parent = selection.getParent();
//Reached root
if ( parent != null && parent.getValue().length() > 0 )
return findRootParent(parent);
else if ( parent.getValue().length() <= 0 )
return selection;
else
throw new IllegalArgumentException(
"OptionsSettingsTree does not support a null root or a root with a value");
}
示例11: isRootItem
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
/**
* Determine if this node is the root node or not
* @param node current node
* @return true if it is the root node or not
*/
public boolean isRootItem(TreeItem node) {
if(node == null) {
return false;
}else{
return node.getParent() == null? true : false;
}
}
示例12: getNodeLayerCount
import javafx.scene.control.TreeItem; //导入方法依赖的package包/类
/**
* Get the TreeItem's layer count
* root = layer 0
* subNode = layer 1
* leaf = layer 2
* @param node the current node
* @return the layer count number for the current node
*/
public int getNodeLayerCount(TreeItem node) {
int count = 0;
if(node == null) {
return count;
}
while(!isRootItem(node)){
node = node.getParent();
count++;
}
return count;
}