Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » how to create a self connection
how to create a self connection [message #151926] Fri, 24 September 2004 14:11 Go to next message
Eclipse UserFriend
Originally posted by: chuchuns.cn.ibm.com

Hi !!!, I want to create a self connection for a editPart, Iknow the method
of build connection between two editPart. but how are about the self
connection. What can I do?

thanks.
Re: how to create a self connection [message #151940 is a reply to message #151926] Fri, 24 September 2004 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gaslade.yahoo.com

Do you mean a connection whose source is the same as the target? I guess
so..... I don't know what the problem is then, you select the connection
tool, you click on the source and then click on it again so that it is
also the target.
You probably won't actually see the edge being drawn as the anchors for
the source and target may be at the same point. To fudge your way around
this you could detect if the source and the target are the same in the
execute method of you ConnectionCommand ( see the logic example for an
example of ConnectionCommand ). In the execute method test to see if
the source and target are the same...i.e

if (source != null && source == target) {
handleConnectToSelf();
}

and then handle it by adding a bend point or two to the edge....

/**
* If the source and target of the connection are the same then
* generate a couple of bendpoints into the edge to that the
* connection looks ok.
*/
private void handleConnectToSelf() {
if (edge.getBendpoints().size() == 0) {
EdgeBendpoint b = new EdgeBendpoint();
b.setWeight(Float.parseFloat("0.5"));
Dimension d1 = new Dimension (10, 10);
Dimension d2 = new Dimension (-150, 85);
b.setRelativeDimensions(d1,d2);
edge.insertBendpoint(0, b);

b = new EdgeBendpoint();
b.setWeight(Float.parseFloat("0.5"));
d1 = new Dimension (66, -34);
d2 = new Dimension (-100, 1);
b.setRelativeDimensions(d1,d2);
edge.insertBendpoint(1, b);
}
}

you can play around with the bend point weights so that the edge looks
the way you want it to.

Guy



wallace,chu wrote:

> Hi !!!, I want to create a self connection for a editPart, Iknow the method
> of build connection between two editPart. but how are about the self
> connection. What can I do?
>
> thanks.
>
>
Re: how to create a self connection [message #152080 is a reply to message #151940] Mon, 27 September 2004 05:08 Go to previous message
Eclipse UserFriend
Originally posted by: chuchuns.cn.ibm.com

now I have solve the problem based your suggestion, I have the wrong
direction of solving it before. thank you very much.
"Guy Slade" <gaslade@yahoo.com> ???? news:cj1e51$4bd$1@eclipse.org...
> Do you mean a connection whose source is the same as the target? I guess
> so..... I don't know what the problem is then, you select the connection
> tool, you click on the source and then click on it again so that it is
> also the target.
> You probably won't actually see the edge being drawn as the anchors for
> the source and target may be at the same point. To fudge your way around
> this you could detect if the source and the target are the same in the
> execute method of you ConnectionCommand ( see the logic example for an
> example of ConnectionCommand ). In the execute method test to see if
> the source and target are the same...i.e
>
> if (source != null && source == target) {
> handleConnectToSelf();
> }
>
> and then handle it by adding a bend point or two to the edge....
>
> /**
> * If the source and target of the connection are the same then
> * generate a couple of bendpoints into the edge to that the
> * connection looks ok.
> */
> private void handleConnectToSelf() {
> if (edge.getBendpoints().size() == 0) {
> EdgeBendpoint b = new EdgeBendpoint();
> b.setWeight(Float.parseFloat("0.5"));
> Dimension d1 = new Dimension (10, 10);
> Dimension d2 = new Dimension (-150, 85);
> b.setRelativeDimensions(d1,d2);
> edge.insertBendpoint(0, b);
>
> b = new EdgeBendpoint();
> b.setWeight(Float.parseFloat("0.5"));
> d1 = new Dimension (66, -34);
> d2 = new Dimension (-100, 1);
> b.setRelativeDimensions(d1,d2);
> edge.insertBendpoint(1, b);
> }
> }
>
> you can play around with the bend point weights so that the edge looks
> the way you want it to.
>
> Guy
>
>
>
> wallace,chu wrote:
>
> > Hi !!!, I want to create a self connection for a editPart, Iknow the
method
> > of build connection between two editPart. but how are about the self
> > connection. What can I do?
> >
> > thanks.
> >
> >
>
Previous Topic:Running simple GEF Editor 3.0
Next Topic:Location problem when creating items with zoom level != 100%
Goto Forum:
  


Current Time: Wed Feb 05 07:46:25 GMT 2025

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

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

Back to the top