how to create a self connection [message #151926] |
Fri, 24 September 2004 14:11 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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.
> >
> >
>
|
|
|
Powered by
FUDForum. Page generated in 0.03535 seconds