Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Realizing simple bendable connections
Realizing simple bendable connections [message #1794270] Tue, 28 August 2018 11:18
Robert Stelzmann is currently offline Robert StelzmannFriend
Messages: 3
Registered: July 2018
Junior Member
Hey guys,

I'm currently building a really simple diagram editor allowing the user to create nodes and connect them with edges. Now, I want to allow my users to create new bend points on edges and drag them around to enable them to do some simple kind of layouting. The resulting connection should be rendered as a list of straight lines connecting these bend points. Hence, nothing special so far. I investigated the logo example but the example is already quite complex and it's hard to extract the relevant code/configuration.

My connection visual derives from Connection and does nothing interesting. My connection part implements IBendableContentPart and thus get/setContentBendPoints. Furthermore, my doRefreshVisual implementation is straightforward:
    @Override
    protected void doRefreshVisual(final ConnectionVisual visual) {
        getVisual().setControlPoints(getContent().getWaypoints());
        super.doRefreshVisual(visual);
    }

    @Override
    public List<BendPoint> getContentBendPoints() {
        return getContent().getWaypoints().stream()
                .map(waypoint -> new BendPoint(waypoint))
                .collect(Collectors.toList());
    }

    @Override
    public void setContentBendPoints(final List<BendPoint> bendPoints) {
        getContent().setWaypoints(bendPoints.stream()
				.map(BendPoint::getPosition)
				.collect(Collectors.toList()));
    }


Finally, I tried to configure the Module likewise in the logo example. Here is the connection-related part:
    protected void bindConnectionPartAdapters(final MapBinder<AdapterKey<?>, Object> adapterMapBinder) {
        // geometry provider for selection feedback
        adapterMapBinder
                .addBinding(AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_FEEDBACK_GEOMETRY_PROVIDER))
                .to(GeometricOutlineProvider.class);
        // geometry provider for selection handles
        adapterMapBinder
                .addBinding(AdapterKey.role(DefaultSelectionHandlePartFactory.SELECTION_HANDLES_GEOMETRY_PROVIDER))
                .to(GeometricOutlineProvider.class);
        adapterMapBinder
                .addBinding(
                        AdapterKey.role(DefaultSelectionFeedbackPartFactory.SELECTION_LINK_FEEDBACK_GEOMETRY_PROVIDER))
                .to(GeometricOutlineProvider.class);
        // geometry provider for hover feedback
        adapterMapBinder.addBinding(AdapterKey.role(DefaultHoverFeedbackPartFactory.HOVER_FEEDBACK_GEOMETRY_PROVIDER))
                .to(GeometricOutlineProvider.class);
        // geometry provider for focus feedback
        adapterMapBinder.addBinding(AdapterKey.role(DefaultFocusFeedbackPartFactory.FOCUS_FEEDBACK_GEOMETRY_PROVIDER))
                .to(GeometricOutlineProvider.class);

        // transaction policy for resize + transform
        adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ResizePolicy.class);

        adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(BendConnectionPolicy.class);

        // interaction handler to relocate on drag
        adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TranslateSelectedOnDragHandler.class);

        // drag individual segments
        adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(BendOnSegmentDragHandler.class);

        adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(TransformPolicy.class);

        // clickable area resizing
        adapterMapBinder.addBinding(AdapterKey.defaultRole()).to(ConnectionClickableAreaBehavior.class);
    }


I'm absolutely not sure which Policies/Handlers/Behaviours I do need. By the way, some more documentation explaining their relations and interdependencies would be really helpful!

So, the whole stuff isn't working very well. At least, the edges get correctly displayed and hovered and I see a circle bend point in the middle. But the bend point is neither draggable nor is it possible to create new bend points. Can you guys give me a hint how to realize the described behaviour? Which Handlers/Policies/Behaviours do I need on the connection part? Do I have to configure the CircleSegmentHandlePart (like in the example)?
Previous Topic:Connection: how to update control points
Next Topic:GEF/ZEST more complex examples/projects
Goto Forum:
  


Current Time: Wed Nov 14 21:22:43 GMT 2018

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

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

Back to the top