本文整理汇总了Java中javafx.scene.Node.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getParent方法的具体用法?Java Node.getParent怎么用?Java Node.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: found
import javafx.scene.Node; //导入方法依赖的package包/类
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();
ObservableList<Node> children = parent.getChildrenUnmodifiable();
for (int i = index + 1; i < children.size(); i++) {
Node c = children.get(i);
IJavaFXElement je2 = JavaFXElementFactory.createElement(c, driver, driver.switchTo().getTopContainer());
if (sibling.matchesSelector(je2).size() > 0) {
IJavaFXElement e = topContainer.addElement(JavaFXElementFactory.createElement(c, driver, topContainer));
if (!r.contains(e)) {
r.add(e);
}
}
}
}
return r;
}
示例2: zoomInAndCenter
import javafx.scene.Node; //导入方法依赖的package包/类
private static void zoomInAndCenter(Node node, double initialWidth, double initialHeight, boolean preserveRatio) {
Parent parent = node.getParent();
node.toFront();
Bounds parentBoundsInParent = parent.getBoundsInLocal();
double xScaleRatio = parentBoundsInParent.getMaxX() / initialWidth;
double yScaleRatio = parentBoundsInParent.getMaxY() / initialHeight;
if (preserveRatio) {
double bestScaleRatio = Math.min(xScaleRatio, yScaleRatio);
node.setScaleX(bestScaleRatio);
node.setScaleY(bestScaleRatio);
} else {
node.setScaleX(xScaleRatio);
node.setScaleY(yScaleRatio);
}
Bounds boundsInParent = node.getBoundsInParent();
double translateX = -1 * Math.abs(boundsInParent.getMinY());
double translateY = -1 * Math.abs(boundsInParent.getMinY());
node.setTranslateX(translateX);
node.setTranslateY(translateY);
}
示例3: inHierarchy
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* Returns whether a MouseEvent happened in a certain node or not.
* @param node The node the event happened in.
* @param potentialHierarchyElement The node to check if the event
* happened in.
* @return True if the event happened in the checked node, false
* otherwise.
*/
public static boolean inHierarchy(Node node, Node potentialHierarchyElement) {
if (potentialHierarchyElement == null) {
return true;
}
while (node != null) {
if (Objects.equals(node, potentialHierarchyElement)) {
return true;
}
node = node.getParent();
}
return false;
}
示例4: getRowNumberLastFocusedTF
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* Returns the row index of the last focused textfield in the proof.
*
* @return row index of the last focused textfield in the proof, otherwise it returns -1
*/
public int getRowNumberLastFocusedTF() {
if (lastFocusedTf != null) {
Node check = lastFocusedTf.getParent();
if (!(check instanceof RowPane))
check = check.getParent();
int idx = rList.indexOf(check);
if (idx != -1)
return idx + 1;
}
return -1;
}
示例5: found
import javafx.scene.Node; //导入方法依赖的package包/类
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;
}
示例6: getIndexOfComponentInParent
import javafx.scene.Node; //导入方法依赖的package包/类
private int getIndexOfComponentInParent(Node component) {
Parent parent = component.getParent();
if (parent == null) {
return -1;
}
ObservableList<Node> components = parent.getChildrenUnmodifiable();
for (int i = 0; i < components.size(); i++) {
if (components.get(i) == component) {
return i;
}
}
return -1;
}
示例7: getParentScrollPane
import javafx.scene.Node; //导入方法依赖的package包/类
private ScrollPane getParentScrollPane(Node target) {
Parent p = target.getParent();
while (p != null && !(p instanceof ScrollPane)) {
p = p.getParent();
}
return (ScrollPane) p;
}
示例8: getTopNode
import javafx.scene.Node; //导入方法依赖的package包/类
private Node getTopNode(Node n) {
Node parent = null;
while (parent == null) {
if (ContextManager.isContext(n)) {
parent = n;
} else if (n.getScene().getRoot() == n) {
parent = n;
} else {
n = n.getParent();
}
}
return parent;
}
示例9: onCheckBox
import javafx.scene.Node; //导入方法依赖的package包/类
protected boolean onCheckBox(Node target) {
Node parent = target;
while (parent != null) {
if (parent instanceof CheckBox)
return true;
parent = parent.getParent();
}
return false;
}
示例10: getRootNode
import javafx.scene.Node; //导入方法依赖的package包/类
static Node getRootNode(final Node node) {
Node n = node;
while (n.getParent() != null) {
n = n.getParent();
}
return n;
}
示例11: isMenuBar
import javafx.scene.Node; //导入方法依赖的package包/类
private boolean isMenuBar(Node ownerNode) {
Node parent = ownerNode;
while (parent != null) {
if (parent instanceof MenuBar) {
this.menuBar = (MenuBar) parent;
return true;
}
parent = parent.getParent();
}
return false;
}
示例12: setConstraint
import javafx.scene.Node; //导入方法依赖的package包/类
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();
}
}
示例13: isScrollBar
import javafx.scene.Node; //导入方法依赖的package包/类
private boolean isScrollBar(Node node) {
boolean result = false;
if (node instanceof ScrollBar) {
result = true;
} else if (node.getParent() != null) {
return isScrollBar(node.getParent());
}
return result;
}
示例14: resetToOriginalIndexInParent
import javafx.scene.Node; //导入方法依赖的package包/类
private static void resetToOriginalIndexInParent(Node node, int originalIndexInParent) {
Parent parent = node.getParent();
VBox parentVBox = (VBox) parent;
parentVBox.getChildren().remove(node);
parentVBox.getChildren().add(originalIndexInParent, node);
}
示例15: findAncestor
import javafx.scene.Node; //导入方法依赖的package包/类
private static <T extends Node & MouseTrackable> LocationAware findAncestor(T subject) {
LocationAware parent = null;
Node descendant = subject;
while (parent == null && descendant != null) {
if (descendant.getParent() instanceof MouseTrackable) {
parent = (LocationAware) descendant.getParent();
}
descendant = descendant.getParent();
}
return parent;
}