|
Re: how to add points to a connection [message #161510 is a reply to message #161476] |
Tue, 14 December 2004 22:49 |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.02439 seconds