Getting started (GEF + ELK) [message #1794100] |
Thu, 23 August 2018 14:00 |
João Pedro Messages: 52 Registered: December 2014 |
Member |
|
|
Hello guys and thank your for developing ELK.
I have a GEF project and want ELK to integrate the project so that I can define Layout Algorithms and, more importantly, to define the number and labels for each node inputs/outputs.
However, I'm having difficulties with the "getting started" phase. With that said, can someone please provide me with a link to some GEF/ELK project examples? I'm looking online and I can't seem to find any.
Thank you in advance.
[Updated on: Thu, 23 August 2018 16:47] Report message to a moderator
|
|
|
|
|
|
Re: Getting started (GEF + ELK) [message #1794136 is a reply to message #1794124] |
Fri, 24 August 2018 08:39 |
João Pedro Messages: 52 Registered: December 2014 |
Member |
|
|
Thank you very much @Miro for the links.
One really specific designing doubt that I'm having: within GEF, as far as I know it, I can't have multiple ports. The GEF library has no idea of the port concept.
Thus, I can have one node with 5 outgoing connections to other nodes but I don't have controllable and distinguishable ports. My main question with the ELK+GEF integration is if ELK will be able to create ports and label them, or if I need to take care of that somehow in GEF side.
What do you think?
[Updated on: Fri, 24 August 2018 08:43] Report message to a moderator
|
|
|
Re: Getting started (GEF + ELK) [message #1794156 is a reply to message #1794136] |
Fri, 24 August 2018 15:12 |
João Pedro Messages: 52 Registered: December 2014 |
Member |
|
|
I tried for 6 hours and couldn't integrate ELK with GEF. Please help me.
Please provide some really small example of GEF+ELK if possible.
I already have my Module implementing MvcFxModule, so I have no idea of what I need to do to implement a new binding for IDiagramLayoutConnector and ILayoutConfigurationStore.Provider.
This is what I have in my module:
public class MapModule extends MvcFxModule {
@Override
protected void bindIContentPartFactoryAsContentViewerAdapter(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(MapPartsFactory.class);
}
/**
*
* @param adapterMapBinder
*/
protected void bindMapNodePartAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
// bind anchor provider used to create the connection anchors
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(MapAnchorProvider.class);
// bind a geometry provider, which is used in our anchor provider
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ShapeOutlineProvider.class);
/**
* We need to tell GEF, how to render the hover and selection feedback for our
* parts. We do this by binding two providers to the MapNodePart.
*/
// provides a hover feedback to the shape, used by the HoverBehavior
AdapterKey<?> role = AdapterKey.role(DefaultHoverFeedbackPartFactory.HOVER_FEEDBACK_GEOMETRY_PROVIDER);
adapterMapBinder.addBinding(role).to(ShapeOutlineProvider.class);
// provides a selection feedback to the shape
role = AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_FEEDBACK_GEOMETRY_PROVIDER);
adapterMapBinder.addBinding(role).to(ShapeBoundsProvider.class);
// support moving nodes via mouse drag
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TransformPolicy.class);
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TranslateSelectedOnDragHandler.class);
// bind create connection handler
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(CreateMapConnectionOnClickHandler.class);
// bind the context menu policy to the part
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ShowMapNodeContextMenuOnClickHandler.class);
}
@Override
protected void configure() {
// start the default configuration
super.configure();
bindMapNodePartAdapters(AdapterMaps.getAdapterMapBinder(binder(), MapNodePart.class));
binder().bind(IDiagramLayoutConnector.class).to(GEFDiagramLayoutConnector.class);
}
@Override
protected void bindAbstractContentPartAdapters(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindAbstractContentPartAdapters(adapterMapBinder);
// binding the HoverOnHoverPolicy to every part
// if a mouse is moving above a part it is set to the HoverModel
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(HoverOnHoverHandler.class);
// add the focus and select policy to every part, listening to clicks
// and changing the focus and selection model
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(FocusAndSelectOnClickHandler.class);
}
/**
* {@link HoverBehavior} listens to changes in the HoverModel and updates the
* graphical representation. The behaviors for selection and focus are already
* bound in the superclass.
*/
@Override
protected void bindIRootPartAdaptersForContentViewer(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindIRootPartAdaptersForContentViewer(adapterMapBinder);
// support creation of nodes via mouse click
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(CreateMapNodeOnClickHandler.class);
// adding the creation feedback behavior
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(CreateConnectionFeedbackBehavior.class);
}
@Override
protected void bindIViewerAdaptersForContentViewer(MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
super.bindIViewerAdaptersForContentViewer(adapterMapBinder);
// bind the model to the content viewer
adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ItemCreation.class);
// binding the creation feedback part factory using the role that is specified in the behavior
AdapterKey<?> role = AdapterKey.role(CreateConnectionFeedbackBehavior.CREATE_FEEDBACK_PART_FACTORY);
adapterMapBinder.addBinding(role).to(CreateConnectionFeedbackFactory.class);
}
|
|
|
Re: Getting started (GEF + ELK) [message #1794188 is a reply to message #1794136] |
Mon, 27 August 2018 07:18 |
|
Quote:My main question with the ELK+GEF integration is if ELK will be able to create ports and label them, or if I need to take care of that somehow in GEF side.
You don't need to use ports with ELK, you can connect edges directly to nodes instead.
Quote:I already have my Module implementing MvcFxModule, so I have no idea of what I need to do to implement a new binding for IDiagramLayoutConnector and ILayoutConfigurationStore.Provider.
Don't use the same Guice module for different things. Create a new Guice module like it's done for the GMF layout connector (see link in my first post).
|
|
|
|
Re: Getting started (GEF + ELK) [message #1794347 is a reply to message #1794188] |
Wed, 29 August 2018 10:34 |
João Pedro Messages: 52 Registered: December 2014 |
Member |
|
|
[quote title=Miro Spönemann wrote on Mon, 27 August 2018 08:18]Quote:
Don't use the same Guice module for different things. Create a new Guice module like it's done for the GMF layout connector (see link in my first post).
I created a new Guice Module.
package mmi.presentation.views.graphicalEditor;
import java.util.Collection;
import org.eclipse.elk.core.service.IDiagramLayoutConnector;
import org.eclipse.elk.core.service.ILayoutSetup;
import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.util.Modules;
import mmi.presentation.views.graphicalEditor.connectors.GEFDiagramLayoutConnector;
import mmi.presentation.views.graphicalEditor.parts.MapConnectionPart;
import mmi.presentation.views.graphicalEditor.parts.MapNodePart;
import mmi.presentation.views.graphicalEditor.parts.ParentMapPart;
public class GEFLayoutSetup implements ILayoutSetup {
@Override
public boolean supports(Object object) {
if (object instanceof Collection) {
Collection<?> collection = (Collection<?>) object;
for (Object o : collection) {
if (o instanceof MapNodePart) {
return true;
}
}
return false;
}
return object instanceof ParentMapPart || object instanceof MapNodePart
|| object instanceof MapConnectionPart;
}
@Override
public Injector createInjector(Module defaultModule) {
return Guice.createInjector(Modules.override(defaultModule).with(new LayoutModule()));
}
public static class LayoutModule implements Module {
@Override
public void configure(Binder binder) {
binder.bind(IDiagramLayoutConnector.class).to(GEFDiagramLayoutConnector.class);
}
}
}
But where do I now instantiate it? The other module, the one doing the GEF graphs is being instantiated like this:
MapModule module = new MapModule();
this.domain = (HistoricizingDomain) Guice.createInjector(module).getInstance(IDomain.class);
// create viewers
hookViewers(parent);
// activate domain
domain.activate();
// load contents
populateViewerContents();
I tried instantiating it there without success. I mean, "createInjector()" and "configure()" of Layout Module are being called but "buildLayoutGraph()" from GEFLayoutConnector is never called:
//ELK Module
GEFLayoutSetup layoutELK = new GEFLayoutSetup();
layoutELK.createInjector(module);
Damn Miro, I know that you must be full of work and that for you this is easy as hell, but can you provide me with a little bit more help?
The GMF link you provided didn't help me at all
[Updated on: Wed, 29 August 2018 11:34] Report message to a moderator
|
|
|
|
Re: Getting started (GEF + ELK) [message #1795081 is a reply to message #1794437] |
Fri, 14 September 2018 07:51 |
|
The injector is not created directly. Instead you register your layout setup with the layoutConnectors extension point.
I've never tried to apply layout to a GEF5 diagram, so I cannot help there. You should ask the GEF developers what is the best way to programmatically set a layout in your diagram.
|
|
|
Powered by
FUDForum. Page generated in 0.03861 seconds