类javafx.scene.Node源码实例Demo

下面列出了怎么用javafx.scene.Node的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: marathonv5   文件: ModalDialog.java
private ObservableList<Node> getChildren(Node node) {
    if (node instanceof ButtonBar) {
        return ((ButtonBar) node).getButtons();
    }
    if (node instanceof ToolBar) {
        return ((ToolBar) node).getItems();
    }
    if (node instanceof Pane) {
        return ((Pane) node).getChildren();
    }
    if (node instanceof TabPane) {
        ObservableList<Node> contents = FXCollections.observableArrayList();
        ObservableList<Tab> tabs = ((TabPane) node).getTabs();
        for (Tab tab : tabs) {
            contents.add(tab.getContent());
        }
        return contents;
    }
    return FXCollections.observableArrayList();
}
 
源代码2 项目: markdown-writer-fx   文件: ProjectsComboBox.java
@Override
protected void updateItem(File item, boolean empty) {
	super.updateItem(item, empty);

	// add/remove separator below "open folder" item
	if (!empty && item == OPEN_FOLDER && ProjectsComboBox.this.getItems().size() > 1)
		getStyleClass().add("open-project");
	else
		getStyleClass().remove("open-project");

	String text = null;
	Node graphic = null;
	if (!empty && item != null) {
		text = (item == OPEN_FOLDER)
			? Messages.get("ProjectsComboBox.openProject")
			: item.getAbsolutePath();

		graphic = closeButton;
		closeButton.setVisible(item != OPEN_FOLDER);
	}
	setText(text);
	setGraphic(graphic);
}
 
源代码3 项目: AsciidocFX   文件: CellUtils.java
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
源代码4 项目: pdfsam   文件: DashboardTile.java
public DashboardTile(String title, String description, Node graphic) {
    getStyleClass().addAll("dashboard-modules-tile");
    Label titleLabel = new Label(title);
    titleLabel.getStyleClass().add("dashboard-modules-tile-title");
    if (nonNull(graphic)) {
        titleLabel.setGraphic(graphic);
    }
    Label textLabel = new Label(description);
    textLabel.getStyleClass().add("dashboard-modules-tile-text");
    textLabel.setMinHeight(USE_PREF_SIZE);
    VBox topTile = new VBox(5);
    topTile.getChildren().addAll(titleLabel, textLabel);

    button.getStyleClass().add("dashboard-modules-invisible-button");
    button.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

    armed.bind(button.armedProperty());
    getChildren().addAll(new StackPane(topTile, button));
    setMaxHeight(USE_PREF_SIZE);
    setMinHeight(USE_PREF_SIZE);
}
 
public MainApplicationController(Stage mainStage,
                                 DataModel model,
                                 Application fxApplication,
                                 ApplicationSettings appSettings,
                                 Node loggingPaneArea,
                                 ControllerRepositoryFactory controllersRepositoryFactory,
                                 DefaultActionHandlerFactory actionHandlerFactory,
                                 ApplicationBusySwitcher busySwitcher) {
    appStage = mainStage;
    dataModel = model;
    this.fxApplication = fxApplication;
    this.appSettings = appSettings;
    this.loggingPaneArea = loggingPaneArea;
    this.controllersRepositoryFactory = controllersRepositoryFactory;
    this.actionHandlerFactory = actionHandlerFactory;
    this.busySwitcher = busySwitcher;
}
 
源代码6 项目: FxDock   文件: FxDockTabPane.java
protected Tab newTab(Node nd)
{
	Node n = DockTools.prepareToAdd(nd);
		
	Tab t = new Tab(null, n);
	if(n instanceof FxDockPane)
	{
		FxDockPane p = (FxDockPane)n;
		t.setGraphic(p.titleField);
		t.setOnClosed((ev) -> 
		{
			Node pp = DockTools.getParent(this);
			DockTools.collapseEmptySpace(pp);
		});
	}
	return t;
}
 
源代码7 项目: phoebus   文件: SendLogbookAction.java
private void submitLogEntry(final Node parent, final String title, final String body, final File image_file)
{
    LogEntryBuilder logEntryBuilder = new LogEntryBuilder();
    if (title != null)
        logEntryBuilder.title(title);
    if (body != null)
        logEntryBuilder.appendDescription(body);

    if (image_file != null)
    {
        try
        {
            final Attachment attachment = AttachmentImpl.of(image_file, "image", false);
            logEntryBuilder.attach(attachment);
        }
        catch (FileNotFoundException ex)
        {
            logger.log(Level.WARNING, "Cannot attach " + image_file, ex);
        }
    }

    final LogEntryModel model = new LogEntryModel(logEntryBuilder.createdDate(Instant.now()).build());

    new LogEntryEditorStage(parent, model, null).show();

}
 
源代码8 项目: CircuitSim   文件: Properties.java
default Node createGui(Stage stage, T value, Consumer<T> onAction) {
	TextField valueField = new TextField(toString(value));
	
	Runnable updateValue = () -> {
		String newValue = valueField.getText();
		if(!newValue.equals(value)) {
			try {
				onAction.accept(parse(newValue));
			} catch(Exception exc) {
				exc.printStackTrace();
				valueField.setText(toString(value));
			}
		}
	};
	
	valueField.setOnAction(event -> updateValue.run());
	valueField.focusedProperty().addListener((observable, oldValue, newValue) -> {
		if(!newValue) {
			updateValue.run();
		}
	});
	return valueField;
}
 
源代码9 项目: JFoenix   文件: JFXNodesList.java
private static Object getConstraint(Node node, Object key) {
    if (node.hasProperties()) {
        Object value = node.getProperties().get(key);
        if (value != null) {
            return value;
        }
    }
    return null;
}
 
源代码10 项目: markdown-writer-fx   文件: EmbeddedImage.java
private Node createErrorNode() {
	Polyline errorNode = new Polyline(
		0, 0,  ERROR_SIZE, 0,  ERROR_SIZE, ERROR_SIZE,  0, ERROR_SIZE,  0, 0,	// rectangle
		ERROR_SIZE, ERROR_SIZE,  0, ERROR_SIZE,  ERROR_SIZE, 0);				// cross
	errorNode.setStroke(Color.RED); //TODO use CSS
	return errorNode;
}
 
/**
 * Activate the selected painting component.
 *
 * @param observable the component box's property.
 * @param oldValue   the previous component.
 * @param newValue   the new component.
 */
@FxThread
private void activate(
        @NotNull ObservableValue<? extends PaintingComponent> observable,
        @Nullable PaintingComponent oldValue,
        @Nullable PaintingComponent newValue
) {

    var items = getContainer().getChildren();

    if (oldValue != null) {
        oldValue.notifyHided();
        oldValue.stopPainting();
        items.remove(oldValue);
    }

    var paintedObject = getPaintedObject();

    if (newValue != null) {

        if (paintedObject != null) {
            newValue.startPainting(paintedObject);
        }

        if (isShowed()) {
            newValue.notifyShowed();
        }

        items.add((Node) newValue);
    }

    setCurrentComponent(newValue);
}
 
源代码12 项目: AsciidocFX   文件: AwesomeService.java
public Node getIcon(final Path path) {

        FontIcon fontIcon = new FontIcon(FontAwesome.FILE_O);

        if (Files.isDirectory(path)) {
            fontIcon.setIconCode(FontAwesome.FOLDER_O);
        } else {
            if (pathResolver.isAsciidoc(path) || pathResolver.isMarkdown(path))
                fontIcon.setIconCode(FontAwesome.FILE_TEXT_O);
            if (pathResolver.isXML(path) || pathResolver.isCode(path))
                fontIcon.setIconCode(FontAwesome.FILE_CODE_O);
            if (pathResolver.isImage(path))
                fontIcon.setIconCode(FontAwesome.FILE_PICTURE_O);
            if (pathResolver.isPDF(path))
                fontIcon.setIconCode(FontAwesome.FILE_PDF_O);
            if (pathResolver.isHTML(path))
                fontIcon.setIconCode(FontAwesome.HTML5);
            if (pathResolver.isArchive(path))
                fontIcon.setIconCode(FontAwesome.FILE_ZIP_O);
            if (pathResolver.isExcel(path))
                fontIcon.setIconCode(FontAwesome.FILE_EXCEL_O);
            if (pathResolver.isVideo(path))
                fontIcon.setIconCode(FontAwesome.FILE_VIDEO_O);
            if (pathResolver.isWord(path))
                fontIcon.setIconCode(FontAwesome.FILE_WORD_O);
            if (pathResolver.isPPT(path))
                fontIcon.setIconCode(FontAwesome.FILE_POWERPOINT_O);
            if (pathResolver.isBash(path))
                fontIcon.setIconCode(FontAwesome.TERMINAL);
        }

        return new Label(null, fontIcon);
    }
 
源代码13 项目: logbook-kai   文件: FleetTabPane.java
/**
 * 注釈プラグインの初期化
 */
private void initializeRemarkPlugin() {
    for (Updateable<DeckPort> plugin : Plugin.getContent(FleetTabRemark.class)) {
        Node node;
        if (plugin instanceof Node) {
            node = ((Node) plugin);
        } else {
            node = new RemarkLabel(plugin);
        }
        this.remark.getChildren().add(node);
    }
}
 
源代码14 项目: gef   文件: SelectionModel.java
@Override
public void onChanged(
		javafx.collections.MapChangeListener.Change<? extends Node, ? extends IVisualPart<? extends Node>> change) {
	// keep model in sync with part hierarchy
	if (change.wasRemoved()) {
		IVisualPart<? extends Node> valueRemoved = change
				.getValueRemoved();
		if (selection.contains(valueRemoved)) {
			selection.remove(valueRemoved);
		}
	}
}
 
源代码15 项目: java-ml-projects   文件: AppUtils.java
@SuppressWarnings("rawtypes")
public static void disableIfNotSelected(SelectionModel selectionModel, Node... nodes) {
	BooleanBinding selected = selectionModel.selectedItemProperty().isNull();
	for (Node node : nodes) {
		node.disableProperty().bind(selected);
	}
}
 
源代码16 项目: JFoenix   文件: JFXAlertAnimation.java
@Override
public Animation createShowingAnimation(Node contentContainer, Node overlay) {
    return new CachedTransition(contentContainer, new Timeline(
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentContainer.scaleXProperty(), 1, Interpolator.EASE_OUT),
            new KeyValue(contentContainer.scaleYProperty(), 1, Interpolator.EASE_OUT),
            new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH)
        ))) {
        {
            setCycleDuration(Duration.millis(160));
            setDelay(Duration.seconds(0));
        }
    };
}
 
源代码17 项目: JFoenix   文件: JFXComboBox.java
private boolean updateDisplayText(ListCell<T> cell, T item, boolean empty) {
    if (empty) {
        // create empty cell
        if (cell == null) {
            return true;
        }
        cell.setGraphic(null);
        cell.setText(null);
        return true;
    } else if (item instanceof Node) {
        Node currentNode = cell.getGraphic();
        Node newNode = (Node) item;
        //  create a node from the selected node of the listview
        //  using JFXComboBox {@link #nodeConverterProperty() NodeConverter})
        NodeConverter<T> nc = this.getNodeConverter();
        Node node = nc == null ? null : nc.toNode(item);
        if (currentNode == null || !currentNode.equals(newNode)) {
            cell.setText(null);
            cell.setGraphic(node == null ? newNode : node);
        }
        return node == null;
    } else {
        // run item through StringConverter if it isn't null
        StringConverter<T> c = this.getConverter();
        String s = item == null ? this.getPromptText() : (c == null ? item.toString() : c.toString(item));
        cell.setText(s);
        cell.setGraphic(null);
        return s == null || s.isEmpty();
    }
}
 
源代码18 项目: ikonli   文件: StackedFontIcon.java
private void setIconColorOnChildren(Paint color) {
    for (Node node : getChildren()) {
        if (node instanceof Icon) {
            ((Icon) node).setIconColor(color);
        }
    }
}
 
源代码19 项目: Flowless   文件: CellWrapper.java
public static <T, N extends Node,C extends Cell<T, N>>
CellWrapper<T, N, C> beforeUpdateIndex(C cell, IntConsumer action) {
    return new CellWrapper<T, N, C>(cell) {
        @Override
        public void updateIndex(int index) {
            action.accept(index);
            super.updateIndex(index);
        }
    };
}
 
源代码20 项目: JFoenix   文件: ValidatorBase.java
private void install(Node node, Tooltip tooltip) {
    if (tooltip == null) {
        return;
    }
    if (tooltip instanceof JFXTooltip) {
        JFXTooltip.install(node, (JFXTooltip) tooltip);
    } else {
        Tooltip.install(node, tooltip);
    }
}
 
源代码21 项目: gef   文件: FocusModel.java
@Override
public void onChanged(
		javafx.collections.MapChangeListener.Change<? extends Node, ? extends IVisualPart<? extends Node>> change) {
	// keep model in sync with part hierarchy
	if (change.wasRemoved()) {
		if (focusedProperty.get() == change.getValueRemoved()) {
			setFocus(null);
		}
	}
}
 
源代码22 项目: marathonv5   文件: SepiaToneSample.java
public static Node createIconContent() {
    ImageView iv = new ImageView(BOAT);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(90,0,332,332));
    final SepiaTone SepiaTone = new SepiaTone();
    SepiaTone.setLevel(1);
    iv.setEffect(SepiaTone);
    return iv;
}
 
源代码23 项目: constellation   文件: AttributeEditorPanel.java
@Override
public void updateItem(Object item, boolean empty) {
    super.updateItem(item, empty);

    AbstractAttributeInteraction<?> interaction = AbstractAttributeInteraction.getInteraction(attrDataType);
    final String displayText;
    final List<Node> displayNodes;
    if (item == null) {
        displayText = NO_VALUE_TEXT;
        displayNodes = Collections.emptyList();
    } else {
        displayText = interaction.getDisplayText(item);
        displayNodes = interaction.getDisplayNodes(item, -1, CELL_HEIGHT - 1);
    }

    GridPane gridPane = new GridPane();
    gridPane.setHgap(CELL_ITEM_SPACING);
    ColumnConstraints displayNodeConstraint = new ColumnConstraints(CELL_HEIGHT - 1);
    displayNodeConstraint.setHalignment(HPos.CENTER);

    for (int i = 0; i < displayNodes.size(); i++) {
        final Node displayNode = displayNodes.get(i);
        gridPane.add(displayNode, i, 0);
        gridPane.getColumnConstraints().add(displayNodeConstraint);
    }

    setGraphic(gridPane);
    setPrefHeight(CELL_HEIGHT);
    setText(displayText);
}
 
源代码24 项目: gef   文件: HoverGesture.java
/**
 *
 * @param viewer
 *            The {@link IViewer}.
 * @param hoverIntent
 *            The hover intent {@link Node}.
 */
protected void notifyHoverIntent(IViewer viewer, Node hoverIntent) {
	// determine hover policies
	Collection<? extends IOnHoverHandler> policies = getHandlerResolver()
			.resolve(HoverGesture.this, hoverIntent, viewer,
					ON_HOVER_POLICY_KEY);
	getDomain().openExecutionTransaction(HoverGesture.this);
	// active policies are unnecessary because hover is not a
	// gesture, just one event at one point in time
	for (IOnHoverHandler policy : policies) {
		policy.hoverIntent(hoverIntent);
	}
	getDomain().closeExecutionTransaction(HoverGesture.this);
}
 
源代码25 项目: MyBox   文件: LabeledHorizontalBarChart.java
@Override
protected void seriesRemoved(final Series<X, Y> series) {
    if (labelType != null && labelType != LabelType.NotDisplay && labelType != LabelType.Pop) {
        for (Node bar : nodeMap.keySet()) {
            Node text = nodeMap.get(bar);
            this.getPlotChildren().remove(text);
        }
        nodeMap.clear();
    }
    super.seriesRemoved(series);
}
 
源代码26 项目: marathonv5   文件: StackPaneSample.java
public static Node createIconContent() {
    StackPane sp = new StackPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    sp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle biggerRec = new Rectangle(55, 55, Color.web("#1c89f4"));
    Rectangle smallerRec = new Rectangle(35, 35, Color.web("#349b00"));

    sp.getChildren().addAll(rectangle, biggerRec, smallerRec);
    return new Group(sp);
}
 
源代码27 项目: 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);
    }
}
 
源代码28 项目: bisq   文件: InfoTextField.java
private void setActionHandlers(Node node) {

        currentIcon.setManaged(true);
        currentIcon.setVisible(true);

        // As we don't use binding here we need to recreate it on mouse over to reflect the current state
        currentIcon.setOnMouseEntered(e -> popoverWrapper.showPopOver(() -> createPopOver(node)));
        currentIcon.setOnMouseExited(e -> popoverWrapper.hidePopOver());
    }
 
源代码29 项目: gluon-samples   文件: UITools.java
public static Node getRefIcon(GitRef ref) {
    if (ref instanceof GitTag) {
        return getIcon(Octicons.Glyph.TAG);
    } else if (ref instanceof GitBranch) {
        return getIcon(Octicons.Glyph.BRANCH);
    } else {
        return null;
    }
}
 
源代码30 项目: marathonv5   文件: SplitDockingContainer.java
@Override
public void remove(Node container) {
    container.getProperties().remove(DockingDesktop.DOCKING_CONTAINER);
    getItems().remove(container);
    if (getItems().size() == 0) {
        ((IDockingContainer) getProperties().get(DockingDesktop.DOCKING_CONTAINER)).remove(this);
    }
}
 
 类所在包
 同包方法