Search in sources :

Example 1 with ColorInput

use of javafx.scene.effect.ColorInput in project toolboxfx by HanSolo.

the class HelperFX method createColorBlend.

public static final Blend createColorBlend(final Image sourceImage, final Color color) {
    final ColorInput mask = createColorMask(sourceImage, color);
    final Blend blend = new Blend(BlendMode.MULTIPLY);
    blend.setTopInput(mask);
    return blend;
}
Also used : Blend(javafx.scene.effect.Blend) ColorInput(javafx.scene.effect.ColorInput)

Example 2 with ColorInput

use of javafx.scene.effect.ColorInput in project constellation by constellation-app.

the class VertexTypeNodeProvider method setContent.

@Override
public void setContent(final Tab tab) {
    GraphManager.getDefault().addGraphManagerListener(this);
    final VBox filterBox = addFilter();
    treeView.setShowRoot(false);
    treeView.setOnDragDetected(event -> {
        final Dragboard db = treeView.startDragAndDrop(TransferMode.COPY);
        final ClipboardContent content = new ClipboardContent();
        final TreeItem<SchemaVertexType> selectedItem = treeView.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            final SchemaVertexType vxtype = selectedItem.getValue();
            final String value = String.format("Type:%s", vxtype.getName());
            content.put(VERTEX_DATA_FORMAT, value);
            content.putString(String.format("%s=%s", SchemaVertexType.class.getSimpleName(), value));
        } else {
            content.putString("");
        }
        db.setContent(content);
        event.consume();
    });
    treeView.getSelectionModel().selectedItemProperty().addListener(event -> {
        detailsView.getChildren().clear();
        // Display the relevant fg and colored bg icons.
        final TreeItem<SchemaVertexType> item = treeView.getSelectionModel().getSelectedItem();
        if (item != null) {
            final SchemaVertexType vertexType = item.getValue();
            final Color color = vertexType.getColor().getJavaFXColor();
            // Background icon, sized, clipped, colored.
            final ImageView bg = new ImageView(backgroundIcons.get(vertexType));
            bg.setFitWidth(LARGE_ICON_IMAGE_SIZE);
            bg.setPreserveRatio(true);
            bg.setSmooth(true);
            final ImageView clip = new ImageView(bg.getImage());
            clip.setFitWidth(LARGE_ICON_IMAGE_SIZE);
            clip.setPreserveRatio(true);
            clip.setSmooth(true);
            bg.setClip(clip);
            final ColorAdjust adjust = new ColorAdjust();
            adjust.setSaturation(-1);
            final ColorInput ci = new ColorInput(0, 0, LARGE_ICON_IMAGE_SIZE, LARGE_ICON_IMAGE_SIZE, color);
            final Blend blend = new Blend(BlendMode.MULTIPLY, adjust, ci);
            bg.setEffect(blend);
            // Foreground icon, sized.
            final ImageView fg = new ImageView(foregroundIcons.get(vertexType));
            fg.setFitWidth(LARGE_ICON_IMAGE_SIZE);
            fg.setPreserveRatio(true);
            fg.setSmooth(true);
            // Combine foreground and background icons.
            final Group iconGroup = new Group(bg, fg);
            final GridPane grid = new GridPane();
            grid.setMaxWidth(detailsView.widthProperty().doubleValue());
            grid.setPadding(new Insets(0, 0, 0, 5));
            grid.setHgap(2);
            final ColumnConstraints col0 = new ColumnConstraints();
            col0.setHgrow(Priority.ALWAYS);
            final ColumnConstraints col1 = new ColumnConstraints();
            col1.setPercentWidth(75);
            grid.getColumnConstraints().addAll(col0, col1);
            final Label nameLabel = new Label(vertexType.getName());
            nameLabel.setWrapText(true);
            grid.add(boldLabel("Name:"), 0, 0);
            grid.add(nameLabel, 1, 0);
            final Label descriptionLabel = new Label(vertexType.getDescription());
            descriptionLabel.setWrapText(true);
            grid.add(boldLabel("Description:"), 0, 1);
            grid.add(descriptionLabel, 1, 1);
            final Label colorLabel = new Label(vertexType.getColor().toString());
            colorLabel.setWrapText(true);
            grid.add(boldLabel("Color:"), 0, 2);
            grid.add(colorLabel, 1, 2);
            final Label foregroundIconLabel = new Label(vertexType.getForegroundIcon().getName());
            foregroundIconLabel.setWrapText(true);
            grid.add(boldLabel("Foreground Icon:"), 0, 3);
            grid.add(foregroundIconLabel, 1, 3);
            final Label backgroundIconLabel = new Label(vertexType.getBackgroundIcon().getName());
            backgroundIconLabel.setWrapText(true);
            grid.add(boldLabel("Background Icon:"), 0, 4);
            grid.add(backgroundIconLabel, 1, 4);
            if (vertexType.getValidationRegex() != null) {
                final Label validationLabel = new Label(vertexType.getValidationRegex().toString());
                validationLabel.setWrapText(true);
                grid.add(boldLabel("Validation Regex:"), 0, 5);
                grid.add(validationLabel, 1, 5);
            }
            if (vertexType.getDetectionRegex() != null) {
                final Label detectionLabel = new Label(vertexType.getDetectionRegex().toString());
                detectionLabel.setWrapText(true);
                grid.add(boldLabel("Detection Regex:"), 0, 6);
                grid.add(detectionLabel, 1, 6);
            }
            final Label hierarchyLabel = new Label(vertexType.getHierachy());
            hierarchyLabel.setWrapText(true);
            grid.add(boldLabel("Hierarchy:"), 0, 7);
            grid.add(hierarchyLabel, 1, 7);
            int gridPosition = 7;
            for (String property : vertexType.getProperties().keySet()) {
                final Object propertyValue = vertexType.getProperty(property);
                if (propertyValue != null) {
                    gridPosition++;
                    Label propertyLabel = new Label(propertyValue.toString());
                    propertyLabel.setWrapText(true);
                    grid.add(boldLabel(property + SeparatorConstants.COLON), 0, gridPosition);
                    grid.add(propertyLabel, 1, gridPosition);
                }
            }
            for (final Node child : grid.getChildren()) {
                final Integer column = GridPane.getColumnIndex(child);
                final Integer row = GridPane.getRowIndex(child);
                if ((column > 0 && row != null && child instanceof Label) && (isFilterMatchText(((Label) child).getText()))) {
                    child.getStyleClass().add("schemaview-highlight-blue");
                }
            }
            detailsView.getChildren().addAll(iconGroup, grid);
        }
    });
    final VBox contentBox = new VBox(schemaLabel, filterBox, treeView, detailsView);
    VBox.setVgrow(treeView, Priority.ALWAYS);
    detailsView.prefHeightProperty().bind(contentBox.heightProperty().multiply(0.4));
    final StackPane contentNode = new StackPane(contentBox);
    newActiveGraph(GraphManager.getDefault().getActiveGraph());
    Platform.runLater(() -> tab.setContent(contentNode));
}
Also used : Group(javafx.scene.Group) ToggleGroup(javafx.scene.control.ToggleGroup) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Blend(javafx.scene.effect.Blend) ClipboardContent(javafx.scene.input.ClipboardContent) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) Label(javafx.scene.control.Label) ColorAdjust(javafx.scene.effect.ColorAdjust) ImageView(javafx.scene.image.ImageView) VBox(javafx.scene.layout.VBox) Dragboard(javafx.scene.input.Dragboard) StackPane(javafx.scene.layout.StackPane) ColorInput(javafx.scene.effect.ColorInput)

Aggregations

Blend (javafx.scene.effect.Blend)2 ColorInput (javafx.scene.effect.ColorInput)2 GraphNode (au.gov.asd.tac.constellation.graph.node.GraphNode)1 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)1 Insets (javafx.geometry.Insets)1 Group (javafx.scene.Group)1 Node (javafx.scene.Node)1 Label (javafx.scene.control.Label)1 ToggleGroup (javafx.scene.control.ToggleGroup)1 ColorAdjust (javafx.scene.effect.ColorAdjust)1 ImageView (javafx.scene.image.ImageView)1 ClipboardContent (javafx.scene.input.ClipboardContent)1 Dragboard (javafx.scene.input.Dragboard)1 ColumnConstraints (javafx.scene.layout.ColumnConstraints)1 GridPane (javafx.scene.layout.GridPane)1 StackPane (javafx.scene.layout.StackPane)1 VBox (javafx.scene.layout.VBox)1 Color (javafx.scene.paint.Color)1