Skip to content

Commit

Permalink
[956] Update ELK layout to have border node offset
Browse files Browse the repository at this point in the history
The ELK option CoreOptions.PORT_BORDER_OFFSET is set by default to 8
pixels entering the parent node.

Bug: #956
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
  • Loading branch information
lfasani committed Feb 25, 2022
1 parent 77630e0 commit 4832178
Showing 1 changed file with 10 additions and 3 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2021 Obeo.
* Copyright (c) 2019, 2022 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -67,6 +67,11 @@ public class LayoutConfiguratorRegistry {
*/
private static final int MIN_WIDTH_CONSTRAINT = 150;

/**
* The default value for port border offset.
*/
private static final double DEFAULT_PORT_BORDER_OFFSET = -8;

private final List<IDiagramLayoutConfiguratorProvider> customLayoutProviders;

public LayoutConfiguratorRegistry(List<IDiagramLayoutConfiguratorProvider> customLayoutProviders) {
Expand All @@ -90,7 +95,8 @@ public ISiriusWebLayoutConfigurator getDefaultLayoutConfigurator() {
.setProperty(CoreOptions.NODE_SIZE_OPTIONS, EnumSet.of(SizeOptions.ASYMMETRICAL))
.setProperty(CoreOptions.NODE_SIZE_MINIMUM, new KVector(LayoutOptionValues.MIN_WIDTH_CONSTRAINT, LayoutOptionValues.MIN_HEIGHT_CONSTRAINT))
.setProperty(CoreOptions.NODE_LABELS_PLACEMENT, NodeLabelPlacement.insideTopCenter())
.setProperty(CoreOptions.NODE_SIZE_MINIMUM, new KVector(MIN_WIDTH_CONSTRAINT, MIN_HEIGHT_CONSTRAINT));
.setProperty(CoreOptions.NODE_SIZE_MINIMUM, new KVector(MIN_WIDTH_CONSTRAINT, MIN_HEIGHT_CONSTRAINT))
.setProperty(CoreOptions.PORT_BORDER_OFFSET, DEFAULT_PORT_BORDER_OFFSET);

configurator.configureByType(NodeType.NODE_LIST)
.setProperty(CoreOptions.ALGORITHM, FixedLayouterOptions.ALGORITHM_ID)
Expand All @@ -103,7 +109,8 @@ public ISiriusWebLayoutConfigurator getDefaultLayoutConfigurator() {

configurator.configureByType(NodeType.NODE_IMAGE)
.setProperty(CoreOptions.NODE_SIZE_CONSTRAINTS, EnumSet.of(SizeConstraint.MINIMUM_SIZE, SizeConstraint.PORT_LABELS, SizeConstraint.PORTS))
.setProperty(CoreOptions.NODE_LABELS_PLACEMENT, NodeLabelPlacement.outsideTopCenter());
.setProperty(CoreOptions.NODE_LABELS_PLACEMENT, NodeLabelPlacement.outsideTopCenter())
.setProperty(CoreOptions.PORT_BORDER_OFFSET, DEFAULT_PORT_BORDER_OFFSET);

// This image type does not match any diagram item. We add it to define the image size as constraint for the node image parent.
configurator.configureByType(ELKDiagramConverter.DEFAULT_IMAGE_TYPE)
Expand Down

0 comments on commit 4832178

Please sign in to comment.