use of org.eclipse.sirius.components.diagrams.LineStyle in project sirius-components by eclipse-sirius.
the class AbstractNodeMappingStyleProvider method createRectangularNodeStyle.
private RectangularNodeStyle createRectangularNodeStyle(VariableManager variableManager, FlatContainerStyleDescription flatContainerStyleDescription) {
Map<String, Object> variables = variableManager.getVariables();
ColorDescriptionConverter colorProvider = new ColorDescriptionConverter(this.interpreter, variables);
String color = colorProvider.convert(flatContainerStyleDescription.getBackgroundColor());
String borderColor = colorProvider.convert(flatContainerStyleDescription.getBorderColor());
LineStyle borderStyle = new LineStyleConverter().getStyle(flatContainerStyleDescription.getBorderLineStyle());
int borderRadius = this.getBorderRadius(flatContainerStyleDescription);
Result result = this.interpreter.evaluateExpression(variables, flatContainerStyleDescription.getBorderSizeComputationExpression());
int borderSize = result.asInt().getAsInt();
// @formatter:off
return RectangularNodeStyle.newRectangularNodeStyle().color(color).borderColor(borderColor).borderSize(borderSize).borderRadius(borderRadius).borderStyle(borderStyle).build();
// @formatter:on
}
use of org.eclipse.sirius.components.diagrams.LineStyle in project sirius-components by eclipse-sirius.
the class AbstractNodeMappingStyleProvider method createRectangularNodeStyle.
private RectangularNodeStyle createRectangularNodeStyle(VariableManager variableManager, SquareDescription squareDescription) {
ColorDescriptionConverter colorProvider = new ColorDescriptionConverter(this.interpreter, variableManager.getVariables());
String color = colorProvider.convert(squareDescription.getColor());
String borderColor = colorProvider.convert(squareDescription.getBorderColor());
LineStyle borderStyle = new LineStyleConverter().getStyle(squareDescription.getBorderLineStyle());
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), squareDescription.getBorderSizeComputationExpression());
int borderSize = result.asInt().getAsInt();
// @formatter:off
return RectangularNodeStyle.newRectangularNodeStyle().color(color).borderColor(borderColor).borderSize(borderSize).borderStyle(borderStyle).build();
// @formatter:on
}
use of org.eclipse.sirius.components.diagrams.LineStyle in project sirius-components by eclipse-sirius.
the class AbstractNodeMappingStyleProvider method createRectangularNodeStyle.
private RectangularNodeStyle createRectangularNodeStyle(VariableManager variableManager, DotDescription dotDescription) {
Map<String, Object> variables = variableManager.getVariables();
ColorDescriptionConverter colorProvider = new ColorDescriptionConverter(this.interpreter, variables);
String color = colorProvider.convert(dotDescription.getBackgroundColor());
String borderColor = colorProvider.convert(dotDescription.getBorderColor());
LineStyle borderStyle = new LineStyleConverter().getStyle(dotDescription.getBorderLineStyle());
int borderRadius = 100;
Result result = this.interpreter.evaluateExpression(variables, dotDescription.getBorderSizeComputationExpression());
int borderSize = result.asInt().getAsInt();
// @formatter:off
return RectangularNodeStyle.newRectangularNodeStyle().color(color).borderColor(borderColor).borderSize(borderSize).borderRadius(borderRadius).borderStyle(borderStyle).build();
// @formatter:on
}
use of org.eclipse.sirius.components.diagrams.LineStyle in project sirius-components by eclipse-sirius.
the class DiagramRendererEdgeTests method getEdgeDescription.
private EdgeDescription getEdgeDescription(NodeDescription nodeDescription, UUID id) {
// @formatter:off
Function<VariableManager, List<Element>> sourceNodesProvider = variableManager -> {
var optionalCache = variableManager.get(DiagramDescription.CACHE, DiagramRenderingCache.class);
Map<Object, List<Element>> objectToNodes = optionalCache.map(DiagramRenderingCache::getObjectToNodes).orElse(new HashMap<>());
List<Element> sourceNodes = objectToNodes.get(FIRST_OBJECT_ID).stream().filter(node -> ((NodeElementProps) node.getProps()).getDescriptionId().equals(nodeDescription.getId())).filter(Objects::nonNull).collect(Collectors.toList());
return sourceNodes;
};
Function<VariableManager, List<Element>> targetNodesProvider = variableManager -> {
var optionalCache = variableManager.get(DiagramDescription.CACHE, DiagramRenderingCache.class);
Map<Object, List<Element>> objectToNodes = optionalCache.map(DiagramRenderingCache::getObjectToNodes).orElse(new HashMap<>());
List<Element> targetNodes = objectToNodes.get(SECOND_OBJECT_ID).stream().filter(node -> ((NodeElementProps) node.getProps()).getDescriptionId().equals(nodeDescription.getId())).filter(Objects::nonNull).collect(Collectors.toList());
return targetNodes;
};
Function<VariableManager, EdgeStyle> edgeStyleProvider = variableManager -> {
return EdgeStyle.newEdgeStyle().size(2).lineStyle(LineStyle.Dash_Dot).sourceArrow(ArrowStyle.InputArrowWithDiamond).targetArrow(ArrowStyle.None).color(// $NON-NLS-1$
"rgb(1, 2, 3)").build();
};
Function<VariableManager, String> idProvider = variableManager -> {
return variableManager.get(VariableManager.SELF, String.class).orElse(null);
};
return EdgeDescription.newEdgeDescription(id).semanticElementsProvider(variableManager -> List.of(FIRST_OBJECT_ID)).sourceNodesProvider(sourceNodesProvider).targetNodesProvider(targetNodesProvider).sourceNodeDescriptions(List.of(nodeDescription)).targetNodeDescriptions(List.of(nodeDescription)).targetObjectIdProvider(idProvider).targetObjectKindProvider(// $NON-NLS-1$
variableManager -> "").targetObjectLabelProvider(// $NON-NLS-1$
variableManager -> "").styleProvider(edgeStyleProvider).deleteHandler(// $NON-NLS-1$
variableManager -> new Failure("")).labelEditHandler(// $NON-NLS-1$
(variableManager, newLabel) -> new Failure("")).build();
// @formatter:on
}
use of org.eclipse.sirius.components.diagrams.LineStyle in project sirius-components by eclipse-sirius.
the class WorkspaceImageDescriptionConverter method convert.
public ImageNodeStyle convert() {
// @formatter:off
String workspacePath = this.eAttributeCustomizationProvider.getEAttributeCustomization(this.workspaceImageDescription, WORKSPACE_PATH).map(EAttributeCustomization::getValue).flatMap(expression -> this.interpreter.evaluateExpression(this.variableManager.getVariables(), expression).asString()).orElse(this.workspaceImageDescription.getWorkspacePath());
// @formatter:on
Result scalingFactorResult = this.interpreter.evaluateExpression(this.variableManager.getVariables(), this.workspaceImageDescription.getSizeComputationExpression());
int scalingFactor = scalingFactorResult.asInt().orElse(DEFAULT_SCALING_FACTOR);
ColorDescriptionConverter colorDescriptionConverter = new ColorDescriptionConverter(this.interpreter, this.variableManager.getVariables());
String borderColor = colorDescriptionConverter.convert(this.workspaceImageDescription.getBorderColor());
LineStyle borderStyle = new LineStyleConverter().getStyle(this.workspaceImageDescription.getBorderLineStyle());
int borderRadius = this.getBorderRadius(this.workspaceImageDescription);
Result result = this.interpreter.evaluateExpression(this.variableManager.getVariables(), this.workspaceImageDescription.getBorderSizeComputationExpression());
int borderSize = result.asInt().getAsInt();
// @formatter:off
return ImageNodeStyle.newImageNodeStyle().imageURL(workspacePath.substring(workspacePath.indexOf('/', 1))).scalingFactor(scalingFactor).borderColor(borderColor).borderRadius(borderRadius).borderSize(borderSize).borderStyle(borderStyle).build();
// @formatter:on
}
Aggregations