Java Code Examples for javafx.scene.Node#getProperties()

The following examples show how to use javafx.scene.Node#getProperties() . 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 File: NodeDetailPaneInfo.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void updateAllDetails() {
    final Node node = (Node) getTarget();

    // No property change events on these
    resizableDetail.setValue(node != null ? Boolean.toString(node.isResizable()) : "-");
    // boolean showResizable = node != null && node.isResizable();
    resizableDetail.setIsDefault(node == null);

    Orientation bias = null;
    if (node != null) {
        bias = node.getContentBias();
        contentBiasDetail.setValue(bias != null ? bias.toString() : "none");
    } else {
        contentBiasDetail.setValue("-");
    }
    contentBiasDetail.setIsDefault(node == null || node.getContentBias() == null);

    baselineDetail.setValue(node != null ? f.format(node.getBaselineOffset()) : "-");
    baselineDetail.setIsDefault(node == null);

    if (node != null) {
        double minw = 0;
        double minh = 0;
        double prefw = 0;
        double prefh = 0;
        double maxw = 0;
        double maxh = 0;

        if (bias == null) {
            minSizeDetail.setLabel("minWidth(-1)/minHeight(-1):");
            prefSizeDetail.setLabel("prefWidth(-1)/prefHeight(-1):");
            maxSizeDetail.setLabel("maxWidth(-1)/maxHeight(-1):");
            minw = node.minWidth(-1);
            minh = node.minHeight(-1);
            prefw = node.prefWidth(-1);
            prefh = node.prefHeight(-1);
            maxw = node.maxWidth(-1);
            maxh = node.maxHeight(-1);
        } else if (bias == Orientation.HORIZONTAL) {
            minSizeDetail.setLabel("minWidth(-1)/minHeight(w):");
            prefSizeDetail.setLabel("prefWidth(-1)/prefHeight(w):");
            maxSizeDetail.setLabel("maxWidth(-1)/maxHeight(w):");
            minw = node.minWidth(-1);
            minh = node.minHeight(minw);
            prefw = node.prefWidth(-1);
            prefh = node.prefHeight(prefw);
            maxw = node.maxWidth(-1);
            maxh = node.maxHeight(maxw);
        } else { // VERTICAL
            minSizeDetail.setLabel("minWidth(h)/minHeight(-1):");
            prefSizeDetail.setLabel("prefWidth(h)/prefHeight(-1):");
            maxSizeDetail.setLabel("maxWidth(h)/maxHeight(-1):");
            minh = node.minHeight(-1);
            minw = node.minWidth(minh);
            prefh = node.prefHeight(-1);
            prefw = node.prefWidth(prefh);
            maxh = node.maxHeight(-1);
            maxw = node.maxWidth(maxh);
        }

        minSizeDetail.setValue(f.format(minw) + " x " + f.format(minh));
        prefSizeDetail.setValue(f.format(prefw) + " x " + f.format(prefh));
        maxSizeDetail.setValue((maxw >= Double.MAX_VALUE ? "MAXVALUE" : f.format(maxw)) + " x " + (maxh >= Double.MAX_VALUE ? "MAXVALUE" : f.format(maxh)));
    } else {
        minSizeDetail.setValue("-");
        prefSizeDetail.setValue("-");
        maxSizeDetail.setValue("-");
    }
    final boolean fade = node == null || !node.isResizable();
    minSizeDetail.setIsDefault(fade);
    prefSizeDetail.setIsDefault(fade);
    maxSizeDetail.setIsDefault(fade);
    @SuppressWarnings("rawtypes") final ObservableMap map = node != null && node.hasProperties() ? node.getProperties() : null;
    constraintsDetail.setValue(ConnectorUtils.serializePropertyMap(map));
    constraintsDetail.setIsDefault(map == null || map.size() == 0);

    updateDetail("*");
}
 
Example 2
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@FxThread
private static void updateListener(@NotNull final Node node, @NotNull final ImageView imageView,
                                   @NotNull final ReadOnlyBooleanProperty condition,
                                   @NotNull final Object listenerKey, @NotNull final Object notSelectedKey,
                                   @NotNull final Object selectedKey) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    if (!theme.needRepaintIcons()) {
        return;
    }

    final ObservableMap<Object, Object> properties = node.getProperties();
    final Image newImage = imageView.getImage();

    if (newImage == null) {
        properties.remove(listenerKey);
        return;
    }

    final Image original = FILE_ICON_MANAGER.getOriginal(newImage);

    properties.put(notSelectedKey, newImage);
    properties.put(selectedKey, original);

    final ChangeListener<Boolean> listener = (observable, oldValue, newValue) -> {
        if (newValue) {
            imageView.setImage((Image) properties.get(selectedKey));
        } else {
            imageView.setImage((Image) properties.get(notSelectedKey));
        }
    };

    condition.addListener(listener);

    properties.put(listenerKey, listener);

    if (condition.get()) {
        imageView.setImage(original);
    } else {
        imageView.setImage(newImage);
    }
}