Search in sources :

Example 1 with CustomizableProperties

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
}
Also used : Node(org.eclipse.sirius.components.diagrams.Node) Label(org.eclipse.sirius.components.diagrams.Label) CustomizableProperties(org.eclipse.sirius.components.diagrams.CustomizableProperties) HashSet(java.util.HashSet)

Example 2 with CustomizableProperties

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);
}
Also used : NodeElementProps(org.eclipse.sirius.components.diagrams.elements.NodeElementProps) Position(org.eclipse.sirius.components.diagrams.Position) Size(org.eclipse.sirius.components.diagrams.Size) Node(org.eclipse.sirius.components.diagrams.Node) Element(org.eclipse.sirius.components.representations.Element) Label(org.eclipse.sirius.components.diagrams.Label) ArrayList(java.util.ArrayList) CustomizableProperties(org.eclipse.sirius.components.diagrams.CustomizableProperties) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle)

Aggregations

CustomizableProperties (org.eclipse.sirius.components.diagrams.CustomizableProperties)2 Label (org.eclipse.sirius.components.diagrams.Label)2 Node (org.eclipse.sirius.components.diagrams.Node)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 INodeStyle (org.eclipse.sirius.components.diagrams.INodeStyle)1 Position (org.eclipse.sirius.components.diagrams.Position)1 Size (org.eclipse.sirius.components.diagrams.Size)1 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)1 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)1 NodeElementProps (org.eclipse.sirius.components.diagrams.elements.NodeElementProps)1 Element (org.eclipse.sirius.components.representations.Element)1