javafx.scene.Node#getParent ( )源码实例Demo

下面列出了javafx.scene.Node#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: paintera   文件: LabelSourceStatePaintHandler.java
public EventHandler<Event> viewerHandler(final PainteraBaseView paintera, final KeyTracker keyTracker) {
	return event -> {
		final EventTarget target = event.getTarget();
		if (!(target instanceof Node))
			return;
		Node node = (Node) target;
		LOG.trace("Handling event {} in target {}", event, target);
		// kind of hacky way to accomplish this:
		while (node != null) {
			if (node instanceof ViewerPanelFX) {
				handlers.computeIfAbsent((ViewerPanelFX) node, k -> this.makeHandler(paintera, keyTracker, k)).handle(event);
				return;
			}
			node = node.getParent();
		}
	};
}
 
源代码2 项目: JFoenix   文件: JFXTreeTableCellSkin.java
private void updateDisclosureNode() {
    Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode();
    if (disclosureNode != null) {
        TreeItem<S> item = getSkinnable().getTreeTableRow().getTreeItem();
        final S value = item == null ? null : item.getValue();
        boolean disclosureVisible = value != null
                                    && !item.isLeaf()
                                    && value instanceof RecursiveTreeObject
                                    && ((RecursiveTreeObject) value).getGroupedColumn() == getSkinnable().getTableColumn();
        disclosureNode.setVisible(disclosureVisible);
        if (!disclosureVisible) {
            getChildren().remove(disclosureNode);
        } else if (disclosureNode.getParent() == null) {
            getChildren().add(disclosureNode);
            disclosureNode.toFront();
        } else {
            disclosureNode.toBack();
        }
        if (disclosureNode.getScene() != null) {
            disclosureNode.applyCss();
        }
    }
}
 
源代码3 项目: latexdraw   文件: Hand.java
/**
 * A tricky workaround to get the real plot view hidden behind its content views (Bezier curve, dots, etc.).
 * If the view has a ViewPlot as its user data, this view plot is returned. The source view is returned otherwise.
 * setMouseTransparency cannot be used since the mouse over would not work anymore.
 * @param view The view to check. Cannot be null.
 * @return The given view or the plot view.
 */
private static ViewShape<?> getRealViewShape(final ViewShape<?> view) {
	if(view == null) {
		return null;
	}

	// Checking whether the shape is not part of another shape
	ViewShape<?> currView = view;

	while(currView.getUserData() instanceof ViewShape) {
		currView = (ViewShape<?>) currView.getUserData();
	}

	// Checking whether the shape is not part of a group
	Node parent = currView;
	while(parent.getParent() != null && !(parent.getParent() instanceof ViewGroup)) {
		parent = parent.getParent();
	}

	if(parent.getParent() instanceof ViewGroup) {
		return (ViewShape<?>) parent.getParent();
	}

	return currView;
}
 
源代码4 项目: milkman   文件: JavaFxUtils.java
public static boolean isParent(Parent parent, Node child) {
    if (child == null) {
        return false;
    }
    Parent curr = child.getParent();
    while (curr != null) {
        if (curr == parent) {
            return true;
        }
        curr = curr.getParent();
    }
    return false;
}
 
源代码5 项目: LogFX   文件: LogViewPane.java
@MustCallOnJavaFXThread
private Optional<LogViewWrapper> getFocusedView() {
    Node node = pane.getScene().focusOwnerProperty().get();

    // go up in the hierarchy until we find a wrapper, or just hit null
    while ( node != null && !( node instanceof LogViewWrapper ) ) {
        node = node.getParent();
    }

    if ( node != null ) {
        return Optional.of( ( LogViewWrapper ) node );
    } else {
        return Optional.empty();
    }
}
 
源代码6 项目: LogFX   文件: SelectionHandler.java
private Node getTargetNode( Object objectTarget ) {
    if ( objectTarget instanceof Node ) {

        Node target = ( Node ) objectTarget;

        // try to go up in the hierarchy until we find a selectable node or the root node
        while ( target != root && !( target instanceof SelectableNode ) ) {
            target = target.getParent();
        }

        return target;
    } else {
        return root;
    }
}
 
源代码7 项目: phoebus   文件: FocusUtil.java
/** @param node Node from which to remove focus */
public static void removeFocus(Node node)
{
    // Cannot un-focus, can only focus on _other_ node.
    // --> Find the uppermost node and focus on that.
    Node parent = node.getParent();
    if (parent == null)
        return;
    while (parent.getParent() != null)
        parent = parent.getParent();
    parent.requestFocus();
}
 
源代码8 项目: ApkToolPlus   文件: Activity.java
protected void initRootView(Node node){
    Node parent = node.getParent();
    Node notNullParent = node;
    while(parent != null){
        notNullParent = parent;
        parent = parent.getParent();
    }
    mRootView = notNullParent;
}
 
源代码9 项目: scenic-view   文件: SVRemoteNodeAdapter.java
public SVRemoteNodeAdapter(final Node node, final boolean collapseControls, final boolean collapseContentControls, final boolean fillChildren, final SVRemoteNodeAdapter parent) {
    super(ConnectorUtils.nodeClass(node), node.getClass().getName());
    boolean mustBeExpanded = !(node instanceof Control) || !collapseControls;
    if (!mustBeExpanded && !collapseContentControls) {
        mustBeExpanded = node instanceof TabPane || node instanceof SplitPane || node instanceof ScrollPane || node instanceof Accordion || node instanceof TitledPane;
    }
    setExpanded(mustBeExpanded);
    this.id = node.getId();
    this.nodeId = ConnectorUtils.getNodeUniqueID(node);
    this.focused = node.isFocused();
    if (node.getParent() != null && parent == null) {
        this.parent = new SVRemoteNodeAdapter(node.getParent(), collapseControls, collapseContentControls, false, null);
    } else if (parent != null) {
        this.parent = parent;
    }
    /**
     * Check visibility and mouse transparency after calculating the parent
     */
    this.mouseTransparent = node.isMouseTransparent() || (this.parent != null && this.parent.isMouseTransparent());
    this.visible = node.isVisible() && (this.parent == null || this.parent.isVisible());

    /**
     * TODO This should be improved
     */
    if (fillChildren) {
        nodes = ChildrenGetter.getChildren(node)
                  .stream()
                  .map(childNode -> new SVRemoteNodeAdapter(childNode, collapseControls, collapseContentControls, true, this))
                  .collect(Collectors.toList());
    }
}
 
源代码10 项目: graph-editor   文件: DraggableBox.java
/**
 * Gets the closest ancestor (e.g. parent, grandparent) to a node that is a subclass of {@link Region}.
 *
 * @param node a JavaFX {@link Node}
 * @return the node's closest ancestor that is a subclass of {@link Region}, or {@code null} if none exists
 */
private Region getContainer(final Node node) {

    final Parent parent = node.getParent();

    if (parent == null) {
        return null;
    } else if (parent instanceof Region) {
        return (Region) parent;
    } else {
        return getContainer(parent);
    }
}
 
源代码11 项目: JFoenix   文件: JFXNodesList.java
private static void setConstraint(Node node, Object key, Object value) {
    if (value == null) {
        node.getProperties().remove(key);
    } else {
        node.getProperties().put(key, value);
    }
    if (node.getParent() != null) {
        node.getParent().requestLayout();
    }
}
 
源代码12 项目: tornadofx-controls   文件: NodeHelper.java
public static <T> T findParentOfType( Node node, Class<T> type ){
    if( node == null ) return null;
    Parent parent = node.getParent();
    if( parent == null ) return null;
    if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
    return findParentOfType( parent, type );
}
 
源代码13 项目: mcaselector   文件: FilterBox.java
private boolean isChildOf(Node node) {
	Node parent = getParent();
	while (parent != null) {
		parent = parent.getParent();
		if (parent == node) {
			return true;
		}
	}
	return false;
}
 
源代码14 项目: Recaf   文件: ErrorHandling.java
/**
 * Update error list, hiding it if no errors are found.
 */
protected void toggleErrorDisplay() {
	Node content = errorList;
	while (!(content instanceof SplitPane) && content != null)
		content = content.getParent();
	if (content == null)
		return;
	SplitPane parent = (SplitPane) content;
	if(problems.isEmpty())
		parent.setDividerPositions(1);
	else if(parent.getDividerPositions()[0] > 0.98)
		parent.setDividerPositions(DEFAULT_ERROR_DISPLAY_PERCENT);
}
 
源代码15 项目: jmonkeybuilder   文件: TabToolComponent.java
/**
 * Handle a click to a tab.
 */
private void processMouseClick(@NotNull final MouseEvent event) {
    final EventTarget target = event.getTarget();
    if (!(target instanceof Node)) return;

    final Node node = (Node) target;

    if (!(node instanceof Text) || node.getStyleClass().contains("tab-container")) {
        return;
    }

    final Parent label = node.getParent();

    if (!(label instanceof Label)) {
        return;
    }

    final Parent tabContainer = label.getParent();

    if (!tabContainer.getStyleClass().contains("tab-container")) {
        return;
    }

    if (isChangingTab()) {
        setChangingTab(false);
        return;
    }

    processExpandOrCollapse();
}
 
源代码16 项目: desktoppanefx   文件: InternalWindow.java
private static boolean isContainedInHierarchy(Node container, Node node) {
    Node candidate = node;
    do {
        if (candidate == container) {
            return true;
        }
        candidate = candidate.getParent();
    } while (candidate != null);
    return false;
}
 
源代码17 项目: desktoppanefx   文件: DesktopPane.java
public static InternalWindow resolveInternalWindow(Node node) {
    if (node == null) {
        return null;
    }

    Node candidate = node;
    while (candidate != null) {
        if (candidate instanceof InternalWindow) {
            return (InternalWindow) candidate;
        }
        candidate = candidate.getParent();
    }

    return null;
}
 
源代码18 项目: marathonv5   文件: AdjacentSiblingSelector.java
protected List<IJavaFXElement> found(List<IJavaFXElement> pElements, IJavaFXAgent driver) {
    List<IJavaFXElement> r = new ArrayList<IJavaFXElement>();
    for (IJavaFXElement je : pElements) {
        Node component = je.getComponent();
        if (!(component instanceof Parent)) {
            continue;
        }
        int index = getIndexOfComponentInParent(component);
        if (index < 0) {
            continue;
        }
        Parent parent = component.getParent();
        JFXWindow topContainer = driver.switchTo().getTopContainer();
        index += 1;
        if (index < parent.getChildrenUnmodifiable().size()) {
            Node c = parent.getChildrenUnmodifiable().get(index);
            IJavaFXElement je2 = JavaFXElementFactory.createElement(c, driver, driver.switchTo().getTopContainer());
            List<IJavaFXElement> matched = sibling.matchesSelector(je2);
            for (IJavaFXElement javaElement : matched) {
                IJavaFXElement e = topContainer.addElement(javaElement);
                if (!r.contains(e)) {
                    r.add(e);
                }
            }
        }
    }
    return r;
}
 
源代码19 项目: graph-editor   文件: IntersectionFinder.java
/**
 * Checks if the given connection is behind this one.
 *
 * @param other another {@link GConnection} instance
 * @return {@code true} if the given connection is behind this one
 */
private boolean checkIfBehind(final GConnection other) {

    final Node node = skinLookup.lookupConnection(connection).getRoot();
    final Node otherNode = skinLookup.lookupConnection(other).getRoot();

    if (node.getParent() == null) {
        return false;
    } else {
        final int connectionIndex = node.getParent().getChildrenUnmodifiable().indexOf(node);
        final int otherIndex = node.getParent().getChildrenUnmodifiable().indexOf(otherNode);

        return otherIndex < connectionIndex;
    }
}
 
源代码20 项目: FxDock   文件: FxDump.java
protected void dump(Node n)
{
	SB sb = new SB(4096);
	sb.nl();
	
	while(n != null)
	{
		sb.a(CKit.getSimpleName(n));
		
		String id = n.getId();
		if(CKit.isNotBlank(id))
		{
			sb.a(" #");
			sb.a(id);
		}
		
		for(String s: n.getStyleClass())
		{
			sb.a(" .").a(s);
		}
		
		for(PseudoClass c: n.getPseudoClassStates())
		{
			sb.a(" :").a(c);
		}
		
		sb.nl();
		
		if(n instanceof Text)
		{
			sb.sp(4);
			sb.a("text: ");
			sb.a(TextTools.escapeControlsForPrintout(((Text)n).getText()));
			sb.nl();
		}
		
		CList<CssMetaData<? extends Styleable,?>> md = new CList<>(n.getCssMetaData());
		sort(md);
		
		for(CssMetaData d: md)
		{
			String k = d.getProperty();
			Object v = d.getStyleableProperty(n).getValue();
			if(shouldShow(v))
			{
				Object val = describe(v);
				sb.sp(4).a(k);
				sb.sp().a(val);
				if(d.isInherits())
				{
					sb.a(" *");
				}
				sb.nl();
			}
		}
		
		n = n.getParent();
	}
	D.print(sb);
}