Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » [Sirius-ELK] Wrong layout result with show/hide ports operation
[Sirius-ELK] Wrong layout result with show/hide ports operation [message #1795243] Wed, 19 September 2018 06:44 Go to next message
lee lucky is currently offline lee luckyFriend
Messages: 26
Registered: October 2017
Junior Member
Hi,
I am using layered algorithm to layout my diagram in Sirius editor.
When I do the following operations, I found the layout result is wrong:
Steps
1). Execute layered algorithm on my diagram in Sirius editor, it works well.
2). Hide ports.
3). Relayout on this diagram after doing 2), it works well, too.
4). Show these hidden ports.
5). Execute layered layout on this diagram again.
The result in step 5) is messed-up, it looks like these ports which are shown after hidden are not placed in their places. But, when I close this diagram, and then reopen it, the diagram is shown well as the step 1) shows.
Analyse
I check ELK's source codes in GmfLayoutCommand.java file of project "org.eclipse.sirius.diagram.elk".
	
        /**
	 * {@inheritDoc}
	 */
	@SuppressWarnings("unchecked")
	@Override
	protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info)
			throws ExecutionException {
		monitor.beginTask(getLabel(), 1);
		// process shape layout data
		for (ShapeLayoutData shapeLayout : shapeLayouts) {
			// set new location of the element
			if (shapeLayout.location != null) {
				ViewUtil.setStructuralFeatureValue(shapeLayout.view, NotationPackage.eINSTANCE.getLocation_X(),
						Integer.valueOf(shapeLayout.location.x));
				ViewUtil.setStructuralFeatureValue(shapeLayout.view, NotationPackage.eINSTANCE.getLocation_Y(),
						Integer.valueOf(shapeLayout.location.y));
			}
			// set new size of the element
			if (shapeLayout.size != null) {
				ViewUtil.setStructuralFeatureValue(shapeLayout.view, NotationPackage.eINSTANCE.getSize_Width(),
						Integer.valueOf(shapeLayout.size.width));
				ViewUtil.setStructuralFeatureValue(shapeLayout.view, NotationPackage.eINSTANCE.getSize_Height(),
						Integer.valueOf(shapeLayout.size.height));
			}
		}
		shapeLayouts.clear();
                ......
 

The ELK layout results are saved by this method, and due to the changes of ports' position and size, the corresponding refreshBounds method will be called in AbstractBorderItemEditPart.java.
              protected void refreshBounds() {
		if (getBorderItemLocator() != null) {
			int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE
				.getLocation_X())).intValue();
			int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE
				.getLocation_Y())).intValue();
			Point loc = new Point(x, y);
			
			int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
			int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
			Dimension size = new Dimension(width, height);

			[color=red][b]getBorderItemLocator().setConstraint(new Rectangle(
				loc, size));[/b][/color]
		} else {
			super.refreshBounds();
		}
	}]

The position and size set in method doExecuteWithResult is the input in getBorderItemLocator().setConstraint(new Rectangle(loc, size)).
In sirius, the relocate method in DBorderItemLocator.java is called to relocate ports on their parents.
	@Override
	public void relocate(final IFigure borderItem) {
		Rectangle parentBounds = getParentFigure().getBounds().getCopy();
		// If the relocate is called before that the figure have been
		// "initialized", it is by-passed.
		if (!(parentBounds.x == 0 && parentBounds.y == 0 && parentBounds.width <= 0 && parentBounds.height <= 0)) {
			final Dimension size = getSize(borderItem);
			final Rectangle rectSuggested = new Rectangle(getPreferredLocation(borderItem), size);
			BitSet authorizedSides = getAuthorizedSides(borderItem);
			// If the border item has moved, we change the preferred side,
			// otherwise we let the current side enabled
			if (borderItemHasMoved) {
				final int closestSide = DBorderItemLocator.findClosestSideOfParent(rectSuggested, getParentBorder(),
						authorizedSides);
				setPreferredSideOfParent(closestSide);
				borderItemHasMoved = false;
			} else {
				// We use the notion if figuresToIgnoreDuringNextRelocate only
				// if bordered node is moved.
				figuresToIgnoreDuringNextRelocate.clear();
			}
			Point ptNewLocation = locateOnBorder(rectSuggested, getCurrentSideOfParent(),
					NB_SIDES - getNumberOfAuthorizedSides(authorizedSides), borderItem,
					figuresToIgnoreDuringNextRelocate, new ArrayList<IFigure>());

			borderItem.setLocation(ptNewLocation);
			figuresToIgnoreDuringNextRelocate.clear();
			borderItem.setSize(size);
			this.located = true;
		}
	}


The field borderItemHasMoved is false which is set by the method called setConstraint in DBorderItemLocator.java
	@Override
	public void setConstraint(final Rectangle theConstraint) {
		if (!theConstraint.equals(getConstraint())) {
			borderItemHasMoved = true;
		}
		super.setConstraint(theConstraint);
	}

Therefore, in method relocate, borderItemHasMoved is false, the position and size are kept in the old ones, the ports are not relocated with their new values. This is why the result in step 5) is messed up as step 4) does. And these new values will be taken effect after reopen the diagram.

I want to fix this problem, Can you give some suggestions?
Hope for your reply, and thanks in advance.
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1795304 is a reply to message #1795243] Thu, 20 September 2018 08:00 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

I don't reproduce the problem.
Check you have no pinned elements when doing the layout.(select all-> right click->layout> if unpin element is usable, use it before doing the layout)
Do you execute layout on previous layouting pass or on original layout for each step?
Can you provide us a project where I can reproduce?
Or at least some pictures of right layout and the wrong one?

Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1795385 is a reply to message #1795304] Fri, 21 September 2018 08:14 Go to previous messageGo to next message
lee lucky is currently offline lee luckyFriend
Messages: 26
Registered: October 2017
Junior Member
Hi,
(1). Check you have no pinned elements when doing the layout.(select all-> right click->layout> if unpin element is usable, use it before doing the layout)
A: I checked my diagram, there are no elements are pinned.
(2).Do you execute layout on previous layouting pass or on original layout for each step?
A: The latter step is executed based on the former step. It is a continuous progress, step1)--> step 2)-->step 3) --> step 4) --> step 5) --> save and reopen.
(3). Can you provide us a project where I can reproduce?
Or at least some pictures of right layout and the wrong one?
A: I'm so sorry, I can't provide my models or projects, but I can attach the result pictures of each step.
Thanks and hope for your reply.
Regards
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1795660 is a reply to message #1795385] Wed, 26 September 2018 13:11 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,
I understand better.
First thing you can do is to open a ticket in the Sirius bugzilla https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Sirius with prefix [ELK] in ticket title with the screenshots and your analyse and steps to reproduce so we can take it in consideration and fix it at some point because it clearly seems to be a bug.
Until then, there is not much you can do. You could try to understand and fix the problem by yourself in a Sirius fork. But this is a very complicated way I would not recommend.

Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1795694 is a reply to message #1795660] Thu, 27 September 2018 01:55 Go to previous messageGo to next message
lee lucky is currently offline lee luckyFriend
Messages: 26
Registered: October 2017
Junior Member
Hi,
I have submit a ticket in bugzilla, you can see that:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=539537
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1796492 is a reply to message #1795694] Mon, 15 October 2018 08:41 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

Thank you for the ticket can you juste confirm you are using the arrange all button of your Sirius editor to do the layouting and that the layout is configured in the odesign?

Regards?


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1796586 is a reply to message #1796492] Tue, 16 October 2018 11:04 Go to previous messageGo to next message
lee lucky is currently offline lee luckyFriend
Messages: 26
Registered: October 2017
Junior Member
Hi,
Sorry for replying you so late.
Yes, I am using the arrange all button of my Sirius editor to do the layouting and that the layout is configured in the odesign.
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1796625 is a reply to message #1796586] Tue, 16 October 2018 14:58 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

That is okay no problem.
Last question are you using option override for the ELK layout algorithm you defined?

Regards,
Pierre


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: [Sirius-ELK] Wrong layout result with show/hide ports operation [message #1796720 is a reply to message #1796625] Thu, 18 October 2018 06:53 Go to previous message
lee lucky is currently offline lee luckyFriend
Messages: 26
Registered: October 2017
Junior Member
Hi,
Quote:
Last question are you using option override for the ELK layout algorithm you defined?

yes, I used the old way to configure my layered algorithm.

     private void configLayered(LayoutConfigurator layoutConfigurator, LayoutMapping layoutMapping) {
        layoutConfigurator.configure(ElkNode.class)
                .setProperty(LayeredOptions.PORT_LABELS_PLACEMENT, PortLabelPlacement.INSIDE)
                .setProperty(LayeredOptions.PORT_CONSTRAINTS, PortConstraints.UNDEFINED)
                .setProperty(LayeredOptions.NODE_SIZE_OPTIONS,
                        EnumSet.of(SizeOptions.MINIMUM_SIZE_ACCOUNTS_FOR_PADDING))
                .setProperty(LayeredOptions.NODE_SIZE_CONSTRAINTS, EnumSet.allOf(SizeConstraint.class))
                .setProperty(LayeredOptions.NODE_LABELS_PLACEMENT, NodeLabelPlacement.insideTopCenter())
                .setProperty(LayeredOptions.MERGE_EDGES, true).setProperty(LayeredOptions.MERGE_HIERARCHY_EDGES, true)
                .setProperty(LayeredOptions.HIERARCHY_HANDLING, HierarchyHandling.INCLUDE_CHILDREN)
                .setProperty(LayeredOptions.CROSSING_MINIMIZATION_GREEDY_SWITCH_TYPE, GreedySwitchType.OFF)
                .setProperty(LayeredOptions.CONTENT_ALIGNMENT, ContentAlignment.topLeft())
                .setProperty(LayeredOptions.EDGE_LABEL_SIDE_SELECTION, EdgeLabelSideSelection.ALWAYS_DOWN)
                .setProperty(LayeredOptions.SPACING_NODE_NODE, 10.0).setProperty(LayeredOptions.SPACING_PORT_PORT, 30.0)
                .setProperty(LayeredOptions.SPACING_EDGE_EDGE, 20.0).setProperty(LayeredOptions.THOROUGHNESS, 1)
                .setProperty(LayeredOptions.SPACING_LABEL_LABEL, 20.0)
                .setProperty(LayeredOptions.SPACING_EDGE_LABEL, 5.0)
                .setProperty(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE, true);
        layoutConfigurator.configure(ElkEdge.class).setProperty(LayeredOptions.INSIDE_SELF_LOOPS_YO, true);
    }


I called this function in method layoutEditParts of ELKLayoutNodeProvider.java.

    public Command layoutEditParts(final List selectedObjects, final IAdaptable layoutHint) {
           .........
        ElkDiagramLayoutConnector connector = injector.getInstance(ElkDiagramLayoutConnector.class);
        LayoutMapping layoutMapping = connector.buildLayoutGraph(null, container.getParent());

       configLayered();
      ......

    }


I am sorry that my company can't access to bugzilla recently, so I can't trace the ticket in bugzilla.
Previous Topic:Getting save event
Next Topic:[ANN] Sirius 6.1.0
Goto Forum:
  


Current Time: Fri Mar 29 08:35:31 GMT 2024

Powered by FUDForum. Page generated in 0.04116 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top