Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » BendPointConnectionRouter
BendPointConnectionRouter [message #232239] Mon, 26 March 2007 22:23 Go to next message
Eclipse UserFriend
Originally posted by: kathir.atc.tcs.com

Hi ,
I am using the BendPointConnectionRouter to connect to two EditPart
Figures. The following is the code snippet

connection.setEndpoints(start, end);

BendpointConnectionRouter connectionRouter = new
BendpointConnectionRouter();

List<Bendpoint> list = new ArrayList<Bendpoint>();
list.add(new AbsoluteBendpoint(start.x, end.y));
connectionRouter.setConstraint(connection, list);

connection.setConnectionRouter(connectionRouter);
connection.setRoutingConstraint(list);
connectionRouter.route(connection);

But this doesnt work for me. I just get a straight line between the two
figures. Am i doing the right thing here !

Thanks in advance,
Kathir.
Re: BendPointConnectionRouter [message #232283 is a reply to message #232239] Tue, 27 March 2007 17:03 Go to previous messageGo to next message
Anthony Hunter is currently offline Anthony HunterFriend
Messages: 446
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0029_01C77070.5803F190
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Kathir

Where are you putting this code snippet? I assume you are putting this =
code in createFigure() in your ConnectionEditPart?

Try:

protected IFigure createFigure() {
PolylineConnection connection =3D new PolylineConnection();
BendpointConnectionRouter connectionRouter =3D new =
BendpointConnectionRouter();
connection.setConnectionRouter(connectionRouter);
return connection;
}

protected void refreshVisuals() {
super.refreshVisuals();
PolylineConnection connection =3D (PolylineConnection) =
getFigure();
ConnectionRouter connectionRouter =3D =
connection.getConnectionRouter();
List list =3D new ArrayList();
list.add(new AbsoluteBendpoint(connection.getSourceAnchor()
.getReferencePoint().x, connection.getTargetAnchor()
.getReferencePoint().y));
connectionRouter.setConstraint(connection, list);
connection.setRoutingConstraint(list);
}


Cheers...
Anthony

"kathir" <kathir@atc.tcs.com> wrote in message =
news:eu9h4n$eg9$1@utils.eclipse.org...
>=20
> Hi ,
> I am using the BendPointConnectionRouter to connect to two EditPart=20
> Figures. The following is the code snippet
>=20
> connection.setEndpoints(start, end);
>=20
> BendpointConnectionRouter connectionRouter =3D new=20
> BendpointConnectionRouter();
>=20
> List<Bendpoint> list =3D new ArrayList<Bendpoint>();
> list.add(new AbsoluteBendpoint(start.x, end.y));
> connectionRouter.setConstraint(connection, list);
>=20
> connection.setConnectionRouter(connectionRouter);
> connection.setRoutingConstraint(list);
> connectionRouter.route(connection);
>=20
> But this doesnt work for me. I just get a straight line between the =
two=20
> figures. Am i doing the right thing here !
>=20
> Thanks in advance,
> Kathir.
------=_NextPart_000_0029_01C77070.5803F190
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi Kathir</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Where are you putting this code=20
snippet?&nbsp;I</FONT><FONT face=3DArial size=3D2> assume you are =
putting this code=20
in createFigure() in your ConnectionEditPart?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Try:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; protected =
IFigure=20
createFigure() {<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
PolylineConnection connection =3D new=20
PolylineConnection();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
BendpointConnectionRouter connectionRouter =3D new=20
BendpointConnectionRouter();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp=
;=20
connection.setConnectionRouter(connectionRouter);<BR>&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
return connection;<BR>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; protected =
void=20
refreshVisuals() {<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
super.refreshVisuals();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
PolylineConnection connection =3D (PolylineConnection)=20
getFigure();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
ConnectionRouter=20
connectionRouter =3D=20
connection.getConnectionRouter();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
List list =3D new =
ArrayList();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
list.add(new=20
AbsoluteBendpoint(connection.getSourceAnchor()<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;=20
..getReferencePoint().x,=20
connection.getTargetAnchor()<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
..getReferencePoint().y));<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
connectionRouter.setConstraint(connection,=20
list);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
connection.setRoutingConstraint(list);<BR>&nbsp;&nbsp;&nbsp; =
}<BR></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Cheers...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Anthony</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"kathir" &lt;</FONT><A=20
href=3D"mailto:kathir@atc.tcs.com"><FONT face=3DArial=20
size=3D2>kathir@atc.tcs.com</FONT></A><FONT face=3DArial size=3D2>&gt; =
wrote in=20
message </FONT><A href=3D"news:eu9h4n$eg9$1@utils.eclipse.org"><FONT =
face=3DArial=20
size=3D2>news:eu9h4n$eg9$1@utils.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; <BR>&gt; Hi =
,<BR>&gt;&nbsp;I=20
am using the BendPointConnectionRouter to connect to two EditPart =
<BR>&gt;=20
Figures. The following is the code snippet<BR>&gt;=20
<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
connection.setEndpoints(start, end);<BR>&gt;=20
<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
BendpointConnectionRouter connectionRouter =3D new <BR>&gt;=20
BendpointConnectionRouter();<BR>&gt;=20
<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
List&lt;Bendpoint&gt; list =3D new=20
ArrayList&lt;Bendpoint&gt;();<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
list.add(new AbsoluteBendpoint(start.x,=20
end.y));<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
connectionRouter.setConstraint(connection, list);<BR>&gt;=20
<BR> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&a mp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
connection.setConnectionRouter(connectionRouter);<BR>&gt;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;=20
connection.setRoutingConstraint(list);<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;=20
connectionRouter.route(connection);<BR>&gt; <BR>&gt; But this doesnt =
work for=20
me. I just get a straight line between the two <BR>&gt; figures. Am i =
doing the=20
right thing here !<BR>&gt; <BR>&gt; Thanks in advance,<BR>&gt; =
Kathir.</FONT>=20
</BODY></HTML>

------=_NextPart_000_0029_01C77070.5803F190--
Re: BendPointConnectionRouter [message #232297 is a reply to message #232283] Tue, 27 March 2007 18:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kathir.atc.tcs.com

Hi Anthony !
Thanks !

No luck on the bendpoint connection !

Actually i do all steps you mentioned inside my refreshVisuals(). I
create the connection inside my editpart.
I set the end points of the connection inside the refresh visuals every
time. and based on the endpoints my bendpoints will change.

I dont use ConnectionAnchor. Is this a must for a PolylineConnection?

I am not sure what is going wrong !

BR,
Kathir.



Anthony Hunter wrote:
> Hi Kathir
>
> Where are you putting this code snippet? I assume you are putting this
> code in createFigure() in your ConnectionEditPart?
>
> Try:
>
> protected IFigure createFigure() {
> PolylineConnection connection = new PolylineConnection();
> BendpointConnectionRouter connectionRouter = new
> BendpointConnectionRouter();
> connection.setConnectionRouter(connectionRouter);
> return connection;
> }
>
> protected void refreshVisuals() {
> super.refreshVisuals();
> PolylineConnection connection = (PolylineConnection) getFigure();
> ConnectionRouter connectionRouter =
> connection.getConnectionRouter();
> List list = new ArrayList();
> list.add(new AbsoluteBendpoint(connection.getSourceAnchor()
> .getReferencePoint().x, connection.getTargetAnchor()
> .getReferencePoint().y));
> connectionRouter.setConstraint(connection, list);
> connection.setRoutingConstraint(list);
> }
>
> Cheers...
> Anthony
>
> "kathir" <kathir@atc.tcs.com <mailto:kathir@atc.tcs.com>> wrote in
> message news:eu9h4n$eg9$1@utils.eclipse.org...
> >
> > Hi ,
> > I am using the BendPointConnectionRouter to connect to two EditPart
> > Figures. The following is the code snippet
> >
> > connection.setEndpoints(start, end);
> >
> > BendpointConnectionRouter connectionRouter = new
> > BendpointConnectionRouter();
> >
> > List<Bendpoint> list = new ArrayList<Bendpoint>();
> > list.add(new AbsoluteBendpoint(start.x, end.y));
> > connectionRouter.setConstraint(connection, list);
> >
> > connection.setConnectionRouter(connectionRouter);
> > connection.setRoutingConstraint(list);
> > connectionRouter.route(connection);
> >
> > But this doesnt work for me. I just get a straight line between the two
> > figures. Am i doing the right thing here !
> >
> > Thanks in advance,
> > Kathir.
Re: BendPointConnectionRouter [message #232303 is a reply to message #232297] Tue, 27 March 2007 20:20 Go to previous message
Eclipse UserFriend
Originally posted by: kathir.atc.tcs.com

ok, now it works.
I created the connection using the XYAnchor instead of using the
setEndPoints() method.

BR,
Kathir.

kathir wrote:
> Hi Anthony !
> Thanks !
>
> No luck on the bendpoint connection !
>
> Actually i do all steps you mentioned inside my refreshVisuals(). I
> create the connection inside my editpart.
> I set the end points of the connection inside the refresh visuals
> every time. and based on the endpoints my bendpoints will change.
>
> I dont use ConnectionAnchor. Is this a must for a PolylineConnection?
>
> I am not sure what is going wrong !
>
> BR,
> Kathir.
>
>
>
> Anthony Hunter wrote:
>> Hi Kathir
>>
>> Where are you putting this code snippet? I assume you are putting
>> this code in createFigure() in your ConnectionEditPart?
>>
>> Try:
>>
>> protected IFigure createFigure() {
>> PolylineConnection connection = new PolylineConnection();
>> BendpointConnectionRouter connectionRouter = new
>> BendpointConnectionRouter();
>> connection.setConnectionRouter(connectionRouter);
>> return connection;
>> }
>>
>> protected void refreshVisuals() {
>> super.refreshVisuals();
>> PolylineConnection connection = (PolylineConnection)
>> getFigure();
>> ConnectionRouter connectionRouter =
>> connection.getConnectionRouter();
>> List list = new ArrayList();
>> list.add(new AbsoluteBendpoint(connection.getSourceAnchor()
>> .getReferencePoint().x, connection.getTargetAnchor()
>> .getReferencePoint().y));
>> connectionRouter.setConstraint(connection, list);
>> connection.setRoutingConstraint(list);
>> }
>>
>> Cheers...
>> Anthony
>>
>> "kathir" <kathir@atc.tcs.com <mailto:kathir@atc.tcs.com>> wrote in
>> message news:eu9h4n$eg9$1@utils.eclipse.org...
>> >
>> > Hi ,
>> > I am using the BendPointConnectionRouter to connect to two EditPart
>> > Figures. The following is the code snippet
>> >
>> > connection.setEndpoints(start, end);
>> >
>> > BendpointConnectionRouter connectionRouter = new
>> > BendpointConnectionRouter();
>> >
>> > List<Bendpoint> list = new ArrayList<Bendpoint>();
>> > list.add(new AbsoluteBendpoint(start.x, end.y));
>> > connectionRouter.setConstraint(connection, list);
>> >
>> > connection.setConnectionRouter(connectionRouter);
>> > connection.setRoutingConstraint(list);
>> > connectionRouter.route(connection);
>> >
>> > But this doesnt work for me. I just get a straight line between the
>> two
>> > figures. Am i doing the right thing here !
>> >
>> > Thanks in advance,
>> > Kathir.
Previous Topic:FlagSupport
Next Topic:[QUERY] Superior Routing + Placement
Goto Forum:
  


Current Time: Tue Dec 12 14:19:35 GMT 2017

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

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