Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » how to add points to a connection
how to add points to a connection [message #161476] Mon, 13 December 2004 19:02 Go to next message
Steven is currently offline StevenFriend
Messages: 6
Registered: July 2009
Junior Member
Hello,

I want to add a connection between 2 points with the same y-coordinate,
but not directly. I want to have something like this:

----X
|
|
----X

I tried to add points to the connection in the creatFigure-method in a
subclass of AbstractConnectionEditPart, but the connection is still the
same (directly) (I used super.createFigure() and tried to change its
points...).
An other problem is the output of start and end-point of the
polyLineConnection. The startpoint is always (0,0) and the endpoint
(100,100), even when start and endpoint are among each other. how can this
be?

thx a lot - steven
Re: how to add points to a connection [message #161510 is a reply to message #161476] Tue, 14 December 2004 22:49 Go to previous message
Eclipse UserFriend
Originally posted by: bo.n0spam.majewski.com

Steven wrote:

> Hello,
>
> I want to add a connection between 2 points with the same y-coordinate,
> but not directly. I want to have something like this:
>
> ----X
> |
> |
> ----X

You probably want to use BendpointConnectionRouter. Add it in your
editor, like this:

protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = this.getGraphicalViewer();
RootEditPart root = viewer.getRootEditPart();

if (root instanceof LayerManager) {
((ConnectionLayer) ((LayerManager) root)
.getLayer(LayerConstants.CONNECTION_LAYER))
.setConnectionRouter(new BendpointConnectionRouter());
}
}

Next, in your edit part that controls edges set routing constraints on
the figure. These should be set when the figure is created or when
bendpoints of the edge are moved. Thus you can set them in the
refreshVisual method and call refreshVisual whenever you detect hat
bendpoints have changed. You can use relative or absolute bend points.
If you were to use relative the code for setting routing constraints on
the figure is something like this:

Connection figure = this.getConnectionFigure();
List bends = ... // get list of bend points of your edge
List constraints = new ArrayList();

for (Iterator iter = bends.iterator(); iter.hasNext(); ) {
MyBendpoint bend = (MyBendpoint) iter.next();
RelativeBendpoint rbp = new RelativeBendpoint(figure);
rbp.setRelativeDimensions(bend.getSourceOffset(),
bend.getTargetOffset());
constraints.add(rbp);
}

figure.setRoutingConstraint(constraints);

Finally, you should add bend point edit policy to the same edit part.
Try looking at the logic example, which allows you to dynamically switch
between various edge routing methods.
Previous Topic:selectAddedObject() throws NullPointerException only on Linux
Next Topic:Problems with plugins
Goto Forum:
  


Current Time: Fri Apr 26 05:16:21 GMT 2024

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

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

Back to the top