use of org.eclipse.sirius.components.diagrams.CustomizableProperties in project sirius-components by eclipse-sirius.
the class IncrementalLayoutedDiagramProvider method getLayoutedNode.
private Node getLayoutedNode(Node node, NodeLayoutData nodeLayoutData, Map<String, ILayoutData> id2LayoutData) {
Label label = this.getLayoutedLabel(node.getLabel(), id2LayoutData);
List<Node> childNodes = this.getLayoutedNodes(node.getChildNodes(), id2LayoutData);
List<Node> borderNodes = this.getLayoutedNodes(node.getBorderNodes(), id2LayoutData);
Set<CustomizableProperties> customizableProperties = new HashSet<>(node.getCustomizedProperties());
if (nodeLayoutData.isResizedByUser()) {
customizableProperties.add(CustomizableProperties.Size);
}
// @formatter:off
return Node.newNode(node).label(label).size(nodeLayoutData.getSize()).position(nodeLayoutData.getPosition()).childNodes(childNodes).borderNodes(borderNodes).customizedProperties(customizableProperties).build();
// @formatter:on
}
use of org.eclipse.sirius.components.diagrams.CustomizableProperties in project sirius-components by eclipse-sirius.
the class NodeComponent method doRender.
private Element doRender(VariableManager nodeVariableManager, String targetObjectId, Optional<Node> optionalPreviousNode) {
NodeDescription nodeDescription = this.props.getNodeDescription();
NodeContainmentKind containmentKind = this.props.getContainmentKind();
String nodeId = optionalPreviousNode.map(Node::getId).orElseGet(() -> this.computeNodeId(targetObjectId));
Optional<Label> optionalPreviousLabel = optionalPreviousNode.map(Node::getLabel);
String type = nodeDescription.getTypeProvider().apply(nodeVariableManager);
String targetObjectKind = nodeDescription.getTargetObjectKindProvider().apply(nodeVariableManager);
String targetObjectLabel = nodeDescription.getTargetObjectLabelProvider().apply(nodeVariableManager);
INodeStyle style = nodeDescription.getStyleProvider().apply(nodeVariableManager);
var borderNodes = this.getBorderNodes(optionalPreviousNode, nodeVariableManager, nodeId);
var childNodes = this.getChildNodes(optionalPreviousNode, nodeVariableManager, nodeId);
LabelDescription labelDescription = nodeDescription.getLabelDescription();
nodeVariableManager.put(LabelDescription.OWNER_ID, nodeId);
LabelType nodeLabelType = LabelType.INSIDE_CENTER;
if (containmentKind == NodeContainmentKind.BORDER_NODE) {
nodeLabelType = LabelType.OUTSIDE;
} else if (NodeType.NODE_IMAGE.equals(type)) {
nodeLabelType = LabelType.OUTSIDE_CENTER;
}
LabelComponentProps labelComponentProps = new LabelComponentProps(nodeVariableManager, labelDescription, optionalPreviousLabel, nodeLabelType.getValue());
Element labelElement = new Element(LabelComponent.class, labelComponentProps);
List<Element> nodeChildren = new ArrayList<>();
nodeChildren.add(labelElement);
nodeChildren.addAll(borderNodes);
nodeChildren.addAll(childNodes);
// @formatter:off
Position position = optionalPreviousNode.map(Node::getPosition).orElse(Position.UNDEFINED);
Size size = this.getSize(optionalPreviousNode, nodeDescription, nodeVariableManager);
Set<CustomizableProperties> customizableProperties = optionalPreviousNode.map(Node::getCustomizedProperties).orElse(Set.of());
NodeElementProps nodeElementProps = NodeElementProps.newNodeElementProps(nodeId).type(type).targetObjectId(targetObjectId).targetObjectKind(targetObjectKind).targetObjectLabel(targetObjectLabel).descriptionId(nodeDescription.getId()).borderNode(containmentKind == NodeContainmentKind.BORDER_NODE).style(style).position(position).size(size).children(nodeChildren).customizableProperties(customizableProperties).build();
// @formatter:on
return new Element(NodeElementProps.TYPE, nodeElementProps);
}
Aggregations