Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Initial layout of figures on canvas for new diagram is cluttered
Initial layout of figures on canvas for new diagram is cluttered [message #637335] Fri, 05 November 2010 06:44 Go to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi

I am creating a diagram using
ViewService.createDiagram(org.eclipse.emf.ecore.EObject context,
java.lang.String kind, PreferencesHint preferencesHint)

I then save the diagram using a ResourceSet provided by an EditingDomain.

Next I create a FileEditorInput to wrap the persisted diagram file and
feed the FileEditorInput to a new instance of my Diagram editor that is
initialized as a page in a FormEditor.

** The diagram layout is very cluttered when shown.

How and where and when to make the nodes and links have more space
between them when the diagram is opened?

Thanks

-H
Re: Initial layout of figures on canvas for new diagram is cluttered [message #637603 is a reply to message #637335] Sun, 07 November 2010 15:57 Go to previous message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi,

If I understand you correctly, you are trying to anagrammatically create a diagram corresponding to a domain object, save it to a file and open it again on an editor.

I think you will have to set the layout information just after creating the diagram using the notational model. The code would look something like below:

Diagram diagram = ViewService.createDiagram(....);
for (Object view : diagram.getChildren()) {
	if (view instanceof Node) {
		Node node = (Node) view;
		LayoutConstraint layoutData = node.getLayoutConstraint();
		if (layoutData instanceof Bounds) {
			((Bounds) layoutData).setX(0); // calculated x (you need to come up with an algorithm)
			((Bounds) layoutData).setY(0); // same
			((Bounds) layoutData).setWidth(0); // same
			((Bounds) layoutData).setHeight(0); // same
		}
	}
}

Although I should mention that I have never done something like this myself, this is just a suggestion Smile

Hope this helps.

- Asiri
Previous Topic:ColorPropertyContributionItem
Next Topic:border item positioning problem when using Seq initializer
Goto Forum:
  


Current Time: Fri Apr 26 16:04:16 GMT 2024

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

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

Back to the top