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;
}
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));
}
Aggregations