How Customized ELK to fit Sirius application? [message #1785293] |
Thu, 12 April 2018 07:50 |
Nicholas Kong Messages: 59 Registered: July 2016 Location: China |
Member |
|
|
To whom it may concern,
I want to use the ELK in Sirius application ( I am the fresh man in this field).
I installed ELK to my Eclipse, it works well using the property to do.
But some times, I want to customized some BorderNode position (ElkPort), based on the semantic model information IN/OUT. It is hard to do.
I find a presentation 'introducing the Eclipse Layout Kernel' by Christoph Daniel Schulze, which includes the same example. As following description:
But this example code just is partial code. And then I follow the 'Advanced Configuration' tutorial, find I can prepare the parameter before DiagramLayoutEngine. However, it maybe can not specify the layout option to corresponded semantic model element. (Because the mapping(LayoutMapping) can not prepared before the DiagramLayoutEngine).
Compare these, this information makes me confused.
1) What's the correct way to customized the layout, like using the semantic model information to impact the ELK? (like Daniel's presentation)
2) Is there any example/sample for ELK tool developer?
Thanks for your reply.
[Updated on: Thu, 12 April 2018 07:54] Report message to a moderator
|
|
|
Re: How Customized ELK to fit Sirius application? [message #1785299 is a reply to message #1785293] |
Thu, 12 April 2018 08:38 |
|
There are many ways to configure ELK layout. If you would like to reuse the code snipped that you posted, you could try the following:
- Implement an ILayoutSetup (see e.g. GmfLayoutSetup) and register it with the org.eclipse.elk.core.service.layoutConnectors extension point.
- In the Guice Module returned by your setup, bind DiagramLayoutEngine to a new subclass (e.g. CustomDiagramLayoutEngine).
- In CustomDiagramLayoutEngine, override addDiagramConfig(Parameters, LayoutMapping) to add your configuration code.
@Override
protected void addDiagramConfig(Parameters params, LayoutMapping layoutMapping) {
LayoutConfigurator layoutConfigurator = params.addLayoutRun();
// Put your configuration code here
...
super.addDiagramConfig(params, layoutMapping);
}
|
|
|
Re: How Customized ELK to fit Sirius application? [message #1785301 is a reply to message #1785299] |
Thu, 12 April 2018 08:51 |
|
Caution: My proposed solution does not work well if you call DiagramLayoutEngine.invokeLayout(IWorkbenchPart, Object, Parameters) somewhere and configure the layout there. The effect would be that the layout would be computed twice, which is probably not what you want.
Alternative approaches are to use the aforementioned static invokeLayout method (but then you don't have access to the LayoutMapping) or to create a subclass of GmfDiagramLayoutConnector and set the configuration properties directly on the elements of the created layout graph.
|
|
|
|
|
|
Re: How Customized ELK to fit Sirius application? [message #1785317 is a reply to message #1785314] |
Thu, 12 April 2018 11:01 |
|
Nicholas Kong wrote on Thu, 12 April 2018 12:56
Can I use this ElkUtil.applyVisitors(graph, configurator) before the DiagramLayoutEngine.invokeLayout() ?
No. DiagramLayoutEngine.invokeLayout() calls GmfLayoutConnector.buildLayoutGraph() in order to obtain a graph instance, so you cannot apply the configurator before the graph has been created.
You can use ElkUtil.applyVisitors(graph, configurator) in a subclass of GmfLayoutConnector.
If you add a configurator to the DiagramLayoutEngine.Parameters, you don't need to apply it yourself because ELK will take care of that.
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 3.56142 seconds