本文整理汇总了Java中javafx.scene.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于javafx.scene包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFX
import javafx.scene.Node; //导入依赖的package包/类
@Test public void loadFX() throws Exception {
final CountDownLatch cdl = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
final JFXPanel p = new JFXPanel();
Platform.runLater(new Runnable() {
@Override
public void run() {
Node wv = TestPages.getFX(10, cdl);
Scene s = new Scene(new Group(wv));
p.setScene(s);
done.countDown();
}
});
done.await();
JFrame f = new JFrame();
f.getContentPane().add(p);
f.pack();
f.setVisible(true);
cdl.await();
}
示例2: findFields
import javafx.scene.Node; //导入依赖的package包/类
private void findFields(Node current, Node container, List<String> fieldNames) {
Field[] declaredFields = container.getClass().getDeclaredFields();
for (Field field : declaredFields) {
boolean accessible = field.isAccessible();
try {
field.setAccessible(true);
Object o = field.get(container);
if (o == current) {
fieldNames.add(field.getName());
}
} catch (Throwable t) {
} finally {
field.setAccessible(accessible);
}
}
}
示例3: createFilteredTree
import javafx.scene.Node; //导入依赖的package包/类
private Node createFilteredTree() {
FilterableTreeItem<Actor> root = getTreeModel();
root.predicateProperty().bind(Bindings.createObjectBinding(() -> {
if (filterField.getText() == null || filterField.getText().isEmpty())
return null;
return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText()));
}, filterField.textProperty()));
TreeView<Actor> treeView = new TreeView<>(root);
treeView.setShowRoot(false);
TitledPane pane = new TitledPane("Filtered TreeView", treeView);
pane.setCollapsible(false);
pane.setMaxHeight(Double.MAX_VALUE);
return pane;
}
示例4: openHome
import javafx.scene.Node; //导入依赖的package包/类
@FXML
public void openHome(ActionEvent event) throws IOException {
MyJDBC.createTestDatabase("shabo");
Node node = (Node) event.getSource();
final Stage stage = (Stage) node.getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
stage.centerOnScreen();
final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
final Scene hScene = new Scene(home);
root.setOnKeyPressed(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
if (ke.getCode() == KeyCode.ESCAPE) {
System.out.println("Key Pressed: " + ke.getCode() + " Made by ShaMaster");
stage.setScene(hScene);
}
}
});
}
示例5: updateView
import javafx.scene.Node; //导入依赖的package包/类
private void updateView() {
getChildren().clear();
getSkinnable().setVisible(false);
final Scene scene = getSkinnable().getScene();
if (scene == null) {
return;
}
for (IntroPane.IntroTarget target : getSkinnable().getTargets()) {
Set<Node> nodes = target.getParent().lookupAll(target.getId());
if (nodes != null) {
nodes.forEach(node -> snapshotNode(scene, node));
}
}
getSkinnable().setVisible(true);
getSkinnable().requestLayout();
}
示例6: rowAdded
import javafx.scene.Node; //导入依赖的package包/类
public void rowAdded() {
RowPane rp;
if (curBoxDepth.isEmpty()) {
System.out.println("rowAdded! curBoxDepth.isEmpty");
rp = new RowPane(false, 0);
rList.add(rp);
rp.init(this, rList);
rows.getChildren().add(rp);
} else {
System.out.println("rowAdded!");
VBox box = curBoxDepth.peek();
List<Node> children = box.getChildren();
boolean isFirstRowInBox = (children.isEmpty()) ? true : false;
rp = new RowPane(isFirstRowInBox, 0);
rList.add(rp);
rp.init(this, rList);
children.add(rp);
}
lineNo.getChildren().add(createLabel());
updateLabelPaddings(rList.size());
scroll = true;
}
示例7: findIndex
import javafx.scene.Node; //导入依赖的package包/类
private int findIndex(Entry<?> entry) {
int childrenSize = getChildren().size();
for (int i = 0; i < childrenSize; i++) {
Node node = getChildren().get(i);
if (node instanceof AllDayEntryView) {
AllDayEntryView view = (AllDayEntryView) node;
Entry<?> viewEntry = view.getEntry();
if (viewEntry.getStartAsZonedDateTime().isAfter(entry.getStartAsZonedDateTime())) {
return i;
}
}
}
return childrenSize;
}
示例8: 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;
}
示例9: updateDefaultColorIndex
import javafx.scene.Node; //导入依赖的package包/类
private void updateDefaultColorIndex(final MultiAxisChart.Series<X, Y> series) {
int clearIndex = seriesColorMap.get(series);
Path seriesLine = (Path) ((Group) series.getNode()).getChildren().get(1);
Path fillPath = (Path) ((Group) series.getNode()).getChildren().get(0);
if (seriesLine != null) {
seriesLine.getStyleClass().remove(DEFAULT_COLOR + clearIndex);
}
if (fillPath != null) {
fillPath.getStyleClass().remove(DEFAULT_COLOR + clearIndex);
}
for (int j = 0; j < series.getData().size(); j++) {
final Node node = series.getData().get(j).getNode();
if (node != null) {
node.getStyleClass().remove(DEFAULT_COLOR + clearIndex);
}
}
}
示例10: createIconContent
import javafx.scene.Node; //导入依赖的package包/类
public static Node createIconContent() {
StackPane sp = new StackPane();
VBox vbox = new VBox(3);
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(5, 5, 5, 5));
Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));
vbox.getChildren().addAll(r1, r2, r3);
sp.getChildren().addAll(rectangle, vbox);
return new Group(sp);
}
示例11: clicknext
import javafx.scene.Node; //导入依赖的package包/类
public void clicknext(ActionEvent event) throws IOException {
if(edit.getText().equalsIgnoreCase("Edit"))
{
Stage stage = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("/template/TemplateFXML.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("/template/TemplateCSS.css").toExternalForm());
stage.setTitle("IDBuilderFX - Select Template");
Stage currstage = (Stage) ((Node) event.getSource()).getScene().getWindow();
currstage.close();
stage.setScene(scene);
stage.resizableProperty().setValue(Boolean.FALSE);
stage.show();
}
else
warnLabel.setText("Please Save First....");
}
示例12: okAction
import javafx.scene.Node; //导入依赖的package包/类
/**
* The action to fire when the user clicks the "Ok" button.
* <p>
* Sets the mapped genome in {@link GraphAnnotation} to the value in the genome choice textfield.
*
* @param actionEvent the {@link ActionEvent}
*/
@FXML
void okAction(final ActionEvent actionEvent) {
if (genomeChoice.getText().isEmpty()) {
(new WarningDialogue("Please select a mapping.")).show();
return;
}
try {
graphAnnotation.setMappedGenome(genomeChoice.getText());
} catch (final IOException e) {
LOGGER.error("Unable to build an index for genome " + genomeChoice.getText() + ".", e);
new ErrorDialogue(e).show();
}
final Node source = (Node) actionEvent.getSource();
source.getScene().getWindow().hide();
actionEvent.consume();
LOGGER.info("Genome " + gffGenome.getText() + " from GFF will be mapped onto " + genomeChoice.getText() + ".");
}
示例13: addContinuousPressHandler
import javafx.scene.Node; //导入依赖的package包/类
/**
* Add an event handler to a node will trigger continuously trigger at a given interval while the button is
* being pressed.
*
* @param node the {@link Node}
* @param holdTime interval time
* @param handler the handler
*/
private void addContinuousPressHandler(final Node node, final Duration holdTime,
final EventHandler<MouseEvent> handler) {
final Wrapper<MouseEvent> eventWrapper = new Wrapper<>();
final PauseTransition holdTimer = new PauseTransition(holdTime);
holdTimer.setOnFinished(event -> {
handler.handle(eventWrapper.content);
holdTimer.playFromStart();
});
node.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
eventWrapper.content = event;
holdTimer.playFromStart();
});
node.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
node.addEventHandler(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
示例14: createEmojiNode
import javafx.scene.Node; //导入依赖的package包/类
/**
* 创建emoji图片节点
*
* @param emoji
* emoji
* @param size
* 图片显示大小
* @param pad
* 图片间距
* @param isCursor
* 是否需要图片光标及鼠标处理事件
* @return
*/
public static Node createEmojiNode(Emoji emoji, int size, int pad) {
// 将表情放到stackpane中
StackPane stackPane = new StackPane();
stackPane.setMaxSize(size, size);
stackPane.setPrefSize(size, size);
stackPane.setMinSize(size, size);
stackPane.setPadding(new Insets(pad));
ImageView imageView = new ImageView();
imageView.setFitWidth(size);
imageView.setFitHeight(size);
imageView.setImage(ImageCache.getInstance().getImage(getEmojiImagePath(emoji.getHex())));
stackPane.getChildren().add(imageView);
return stackPane;
}
示例15: calculateAndRotatoNodes
import javafx.scene.Node; //导入依赖的package包/类
private void calculateAndRotatoNodes(List<Node> nodes, double alp, double bet, double gam) {
double A11 = Math.cos(alp) * Math.cos(gam);
double A12 = Math.cos(bet) * Math.sin(alp) + Math.cos(alp) * Math.sin(bet) * Math.sin(gam);
double A13 = Math.sin(alp) * Math.sin(bet) - Math.cos(alp) * Math.cos(bet) * Math.sin(gam);
double A21 = -Math.cos(gam) * Math.sin(alp);
double A22 = Math.cos(alp) * Math.cos(bet) - Math.sin(alp) * Math.sin(bet) * Math.sin(gam);
double A23 = Math.cos(alp) * Math.sin(bet) + Math.cos(bet) * Math.sin(alp) * Math.sin(gam);
double A31 = Math.sin(gam);
double A32 = -Math.cos(gam) * Math.sin(bet);
double A33 = Math.cos(bet) * Math.cos(gam);
double d = Math.acos((A11 + A22 + A33 - 1d) / 2d);
if (!ObjectUtils.equalsDoublePrecision(d, 0.0)) {
double den = 2d * Math.sin(d);
Point3D p = new Point3D((A32 - A23) / den, (A13 - A31) / den, (A21 - A12) / den);
for (Node node : nodes) {
node.setRotationAxis(p);
node.setRotate(Math.toDegrees(d));
}
}
}