javafx.scene.Node Java Examples

The following examples show how to use javafx.scene.Node. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: marathonv5   Author: jalian-systems   File: ModalDialog.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #2
Source Project: markdown-writer-fx   Author: JFormDesigner   File: ProjectsComboBox.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
}
 
Example #3
Source Project: AsciidocFX   Author: asciidocfx   File: CellUtils.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #4
Source Project: pdfsam   Author: torakiki   File: DashboardTile.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #5
Source Project: kafka-message-tool   Author: grzegorz-wolszczak   File: MainApplicationController.java    License: MIT License 6 votes vote down vote up
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;
}
 
Example #6
Source Project: FxDock   Author: andy-goryachev   File: FxDockTabPane.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #7
Source Project: phoebus   Author: ControlSystemStudio   File: SendLogbookAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
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();

}
 
Example #8
Source Project: CircuitSim   Author: ra4king   File: Properties.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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;
}
 
Example #9
Source Project: JFoenix   Author: jfoenixadmin   File: JFXNodesList.java    License: Apache License 2.0 5 votes vote down vote up
private static Object getConstraint(Node node, Object key) {
    if (node.hasProperties()) {
        Object value = node.getProperties().get(key);
        if (value != null) {
            return value;
        }
    }
    return null;
}
 
Example #10
Source Project: markdown-writer-fx   Author: JFormDesigner   File: EmbeddedImage.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #11
Source Project: jmonkeybuilder   Author: JavaSaBr   File: PaintingComponentContainer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source Project: AsciidocFX   Author: asciidocfx   File: AwesomeService.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example #13
Source Project: logbook-kai   Author: sanaehirotaka   File: FleetTabPane.java    License: MIT License 5 votes vote down vote up
/**
 * 注釈プラグインの初期化
 */
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);
    }
}
 
Example #14
Source Project: gef   Author: eclipse   File: SelectionModel.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@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);
		}
	}
}
 
Example #15
Source Project: java-ml-projects   Author: jesuino   File: AppUtils.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public static void disableIfNotSelected(SelectionModel selectionModel, Node... nodes) {
	BooleanBinding selected = selectionModel.selectedItemProperty().isNull();
	for (Node node : nodes) {
		node.disableProperty().bind(selected);
	}
}
 
Example #16
Source Project: JFoenix   Author: jfoenixadmin   File: JFXAlertAnimation.java    License: Apache License 2.0 5 votes vote down vote up
@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));
        }
    };
}
 
Example #17
Source Project: JFoenix   Author: jfoenixadmin   File: JFXComboBox.java    License: Apache License 2.0 5 votes vote down vote up
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();
    }
}
 
Example #18
Source Project: ikonli   Author: kordamp   File: StackedFontIcon.java    License: Apache License 2.0 5 votes vote down vote up
private void setIconColorOnChildren(Paint color) {
    for (Node node : getChildren()) {
        if (node instanceof Icon) {
            ((Icon) node).setIconColor(color);
        }
    }
}
 
Example #19
Source Project: Flowless   Author: FXMisc   File: CellWrapper.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    };
}
 
Example #20
Source Project: JFoenix   Author: jfoenixadmin   File: ValidatorBase.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #21
Source Project: gef   Author: eclipse   File: FocusModel.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@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);
		}
	}
}
 
Example #22
Source Project: marathonv5   Author: jalian-systems   File: SepiaToneSample.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #23
Source Project: constellation   Author: constellation-app   File: AttributeEditorPanel.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #24
Source Project: gef   Author: eclipse   File: HoverGesture.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 *
 * @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);
}
 
Example #25
Source Project: MyBox   Author: Mararsh   File: LabeledHorizontalBarChart.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #26
Source Project: marathonv5   Author: jalian-systems   File: StackPaneSample.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #27
Source Project: graph-editor   Author: tesis-dynaware   File: DraggableBox.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #28
Source Project: bisq   Author: bisq-network   File: InfoTextField.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
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());
    }
 
Example #29
Source Project: gluon-samples   Author: gluonhq   File: UITools.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
    }
}
 
Example #30
Source Project: marathonv5   Author: jalian-systems   File: SplitDockingContainer.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}