use of org.eclipse.sirius.components.diagrams.TextBounds in project sirius-components by eclipse-sirius.
the class BorderNodePositionTests method createNodeLayoutData.
private NodeLayoutData createNodeLayoutData(Position position, Size size, IContainerLayoutData parent, String nodeType) {
NodeLayoutData nodeLayoutData = new NodeLayoutData();
nodeLayoutData.setId(UUID.randomUUID().toString());
nodeLayoutData.setParent(parent);
nodeLayoutData.setPosition(position);
nodeLayoutData.setSize(size);
nodeLayoutData.setNodeType(nodeType);
nodeLayoutData.setChildrenNodes(new ArrayList<>());
// $NON-NLS-1$
nodeLayoutData.setLabel(this.createLabelLayoutData(Position.at(0, 0), "inside", new TextBounds(Size.of(0, 0), Position.at(0, 0))));
return nodeLayoutData;
}
use of org.eclipse.sirius.components.diagrams.TextBounds in project sirius-components by eclipse-sirius.
the class ELKDiagramConverter method getNodeListItemHeight.
private double getNodeListItemHeight(Node nodeListItem) {
TextBounds nodeListItemTextBounds = this.textBoundsService.getBounds(nodeListItem.getLabel());
double nodeListItemHeight = nodeListItemTextBounds.getSize().getHeight() + LayoutOptionValues.NODE_LIST_ELK_NODE_LABELS_PADDING_TOP + LayoutOptionValues.NODE_LIST_ELK_NODE_LABELS_PADDING_BOTTOM;
return nodeListItemHeight;
}
use of org.eclipse.sirius.components.diagrams.TextBounds in project sirius-components by eclipse-sirius.
the class ELKDiagramConverter method getNodeListWidth.
/**
* Returns the size of the given {@link NodeType#NODE_LIST}, which is the max value between the highest children
* item width, the node label width and {@link} LayoutOptionValues#MIN_WIDTH_CONSTRAINT}.
*
* @param nodeList
* The node list we want the width
* @return the size of the given {@link NodeType#NODE_LIST}
*/
private double getNodeListWidth(Node nodeList) {
TextBounds nodeListLabelTextBounds = this.textBoundsService.getBounds(nodeList.getLabel());
double largestNodeListItemWidth = this.getLargestNodeListItemWidth(nodeList.getChildNodes());
// @formatter:off
return Arrays.asList(largestNodeListItemWidth, nodeListLabelTextBounds.getSize().getWidth() + LayoutOptionValues.DEFAULT_ELK_NODE_LABELS_PADDING * 2, LayoutOptionValues.MIN_WIDTH_CONSTRAINT).stream().mapToDouble(Number::doubleValue).max().orElse(LayoutOptionValues.MIN_WIDTH_CONSTRAINT);
// @formatter:on
}
use of org.eclipse.sirius.components.diagrams.TextBounds in project sirius-components by eclipse-sirius.
the class ELKDiagramConverter method convertBorderNode.
private void convertBorderNode(Node borderNode, ElkNode elkNode, Map<String, ElkConnectableShape> connectableShapeIndex, Map<String, ElkGraphElement> id2ElkGraphElements) {
ElkPort elkPort = ElkGraphFactory.eINSTANCE.createElkPort();
elkPort.setIdentifier(borderNode.getId());
elkPort.setProperty(PROPERTY_TYPE, borderNode.getType());
TextBounds textBounds = this.textBoundsService.getBounds(borderNode.getLabel());
double width = borderNode.getSize().getWidth();
double height = borderNode.getSize().getHeight();
elkPort.setDimensions(width, height);
elkPort.setParent(elkNode);
connectableShapeIndex.put(elkPort.getIdentifier(), elkPort);
if (borderNode.getStyle() instanceof ImageNodeStyle) {
Size imageSize = this.imageNodeStyleSizeProvider.getSize((ImageNodeStyle) borderNode.getStyle());
elkPort.setDimensions(imageSize.getWidth(), imageSize.getHeight());
}
this.convertLabel(borderNode.getLabel(), textBounds, elkPort, id2ElkGraphElements, null);
id2ElkGraphElements.put(borderNode.getId(), elkPort);
}
use of org.eclipse.sirius.components.diagrams.TextBounds in project sirius-components by eclipse-sirius.
the class EdgeLabelPositionProviderTests method createLabelLayoutData.
private LabelLayoutData createLabelLayoutData() {
LabelLayoutData labelLayoutData = new LabelLayoutData();
labelLayoutData.setId(UUID.randomUUID().toString());
labelLayoutData.setPosition(Position.UNDEFINED);
// @formatter:off
LabelStyle labelStyle = LabelStyle.newLabelStyle().color(LABEL_COLOR).fontSize(FONT_SIZE).iconURL(ICON_URL).build();
// @formatter:on
// $NON-NLS-1$
TextBounds textBounds = new TextBoundsProvider().computeBounds(labelStyle, "labelText");
labelLayoutData.setTextBounds(textBounds);
return labelLayoutData;
}
Aggregations