Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Two input connections on one connectionanchor
Two input connections on one connectionanchor [message #118513] Fri, 20 February 2004 03:41 Go to next message
Eclipse UserFriend
Originally posted by: josephlee.163.com

Hi
Now I want to place two input connections on one connectionanchor,how
can I do it?In Logic examples I cannot found the same functions.
And another questions:
How can I refresh the text in the label which I add to the connection
figure with ConnectionEndpointLocator.I use label.setText() in
refreshVisuals(),but it doesnot work.And I try to use
refreshChildren(),refreshSourceConnections(),it also doesnot work.
In my StateFigure it works well.
thanks in advance.
joseph
Re: Two input connections on one connectionanchor [message #118824 is a reply to message #118513] Mon, 23 February 2004 03:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

"joseph" <josephlee@163.com> wrote in message
news:c13vkv$jqr$1@eclipse.org...
> Hi
> Now I want to place two input connections on one connectionanchor,how
> can I do it?In Logic examples I cannot found the same functions.

The Logic example, because of its very nature will allow only a certain
number of connections per anchor - there is no point attaching more than one
connection to a single terminal of a gate, for instance. Therefore Logic has
additional "logic" to handle this. You probably just need to disregard this.

Make sure your editPart implements NodeEditPart, and in the
getSourceConnectionAnchor and getTargetConnectionAnchor
methods, simply return a NEW Anchor of your type, each time the method is
called. If you want to give the appearance of all the connections beginning
or ending from the same point, then write your anchor in such a way that it
always returns the same point in the figure in it's getLocaton method.

I just checked and it is also possible to return the SAME Anchor object in
the getSource/TargetConnectionAnchor methods - you can do something like
this -

private MyAnchor ca = null;
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
connection) {
if(ca == null) ca = new MyAnchor(getFigure());
return ca;
}

I don't think this has any sideeffects; seems to work fine for me.

> And another questions:
> How can I refresh the text in the label which I add to the connection
> figure with ConnectionEndpointLocator.I use label.setText() in
> refreshVisuals(),but it doesnot work.And I try to use
> refreshChildren(),refreshSourceConnections(),it also doesnot work.

If you've called label.setText() in the refreshVisuals of the connections
EditPart, then it should work just fine. Perhaps you should check if
refreshVisuals is being called when you change the labels Text, or if it IS
being called, then the text has indeed changed and is not the same - stupid,
but still check.

Hope this helps,
All the best,
Brian.
Re: Two input connections on one connectionanchor [message #119189 is a reply to message #118824] Tue, 24 February 2004 04:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: josephlee.163.com

thanks.
the label't content has been changed,but only I drag the connection to
another location and then back to the original location ,the content
change.Perhaps I should implement better method to finish my work.
And the anchor: what you mean is place the anchor to the same point on the
figure.But I place four anchor in my rectangle's edges' midpoint.Now I
want to drag the other connection to the same midpoint location on the
figure.I only can use getNodeFigure() to locate the anchor.I think if it
is my model's problem because my model is designed according to the
logic's circuit.I set the anchor's name using different letters .One
letter map to one anchor's input or output.
Can I modify my model?

Brian Fernandes wrote:

> "joseph" <josephlee@163.com> wrote in message
> news:c13vkv$jqr$1@eclipse.org...
> > Hi
> > Now I want to place two input connections on one connectionanchor,how
> > can I do it?In Logic examples I cannot found the same functions.

> The Logic example, because of its very nature will allow only a certain
> number of connections per anchor - there is no point attaching more than one
> connection to a single terminal of a gate, for instance. Therefore Logic has
> additional "logic" to handle this. You probably just need to disregard this.

> Make sure your editPart implements NodeEditPart, and in the
> getSourceConnectionAnchor and getTargetConnectionAnchor
> methods, simply return a NEW Anchor of your type, each time the method is
> called. If you want to give the appearance of all the connections beginning
> or ending from the same point, then write your anchor in such a way that it
> always returns the same point in the figure in it's getLocaton method.

> I just checked and it is also possible to return the SAME Anchor object in
> the getSource/TargetConnectionAnchor methods - you can do something like
> this -

> private MyAnchor ca = null;
> public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
> connection) {
> if(ca == null) ca = new MyAnchor(getFigure());
> return ca;
> }

> I don't think this has any sideeffects; seems to work fine for me.

> > And another questions:
> > How can I refresh the text in the label which I add to the connection
> > figure with ConnectionEndpointLocator.I use label.setText() in
> > refreshVisuals(),but it doesnot work.And I try to use
> > refreshChildren(),refreshSourceConnections(),it also doesnot work.

> If you've called label.setText() in the refreshVisuals of the connections
> EditPart, then it should work just fine. Perhaps you should check if
> refreshVisuals is being called when you change the labels Text, or if it IS
> being called, then the text has indeed changed and is not the same - stupid,
> but still check.

> Hope this helps,
> All the best,
> Brian.
Re: Two input connections on one connectionanchor [message #119202 is a reply to message #119189] Tue, 24 February 2004 06:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

"joseph" <josephlee@163.com> wrote in message
news:c1ej02$ueg$1@eclipse.org...
> thanks.
> the label't content has been changed,but only I drag the connection to
> another location and then back to the original location ,the content
> change.Perhaps I should implement better method to finish my work.
Clearly sounds like a refreshVisuals issue - are you sure refreshVisuals is
called on the Connections editPart when you change the label text ?
> And the anchor: what you mean is place the anchor to the same point on the
> figure.But I place four anchor in my rectangle's edges' midpoint.Now I
> want to drag the other connection to the same midpoint location on the
> figure.I only can use getNodeFigure() to locate the anchor.I think if it
> is my model's problem because my model is designed according to the
> logic's circuit.I set the anchor's name using different letters .One
> letter map to one anchor's input or output.
> Can I modify my model?

I'm not sure exactly what you want here. Do you want N number of connections
on a particular figure ? Or do you want only 4 ? Say you want only 4
connections per figure (whether source or target), from each midpoint of
your figures rectangle sides. I'll assume this and go on.

For all getSourceConnectionAnchor and getTargetConnectionAnchor calls,
return the SAME anchor object for each EditPart. (Maybe as soon as your
EditPart is created, create a new Anchor Object and return this all the
time)

Now this Anchor Object, has an internal list of the connecitons it has used
up so far. Depending on the the connections already used up on the anchor,
the Anchor will return a new position on the figures bounds in its
getLocation method. If all 4 connectons are used up - make sure
getSourceConnectionAnchor returns null.

I just thought over this, and it IS better if you manage the connections
list in the Model of the EditPart you intend to connect from/to and NOT in
the Anchor. Depending on that, pass a parameter to your anchor and it will
return an appropriate point. This is somewhat similar to what Logic does,
but it limits the number of connections to two per figure.

Hope I didn't miss the point and I wasn't too confusing, (if you can attach
a picture of what you intend to do, maybe I'll be able to understand better)

All the best,

Brian.









>
> Brian Fernandes wrote:
>
> > "joseph" <josephlee@163.com> wrote in message
> > news:c13vkv$jqr$1@eclipse.org...
> > > Hi
> > > Now I want to place two input connections on one
connectionanchor,how
> > > can I do it?In Logic examples I cannot found the same functions.
>
> > The Logic example, because of its very nature will allow only a certain
> > number of connections per anchor - there is no point attaching more than
one
> > connection to a single terminal of a gate, for instance. Therefore Logic
has
> > additional "logic" to handle this. You probably just need to disregard
this.
>
> > Make sure your editPart implements NodeEditPart, and in the
> > getSourceConnectionAnchor and getTargetConnectionAnchor
> > methods, simply return a NEW Anchor of your type, each time the method
is
> > called. If you want to give the appearance of all the connections
beginning
> > or ending from the same point, then write your anchor in such a way that
it
> > always returns the same point in the figure in it's getLocaton method.
>
> > I just checked and it is also possible to return the SAME Anchor object
in
> > the getSource/TargetConnectionAnchor methods - you can do something like
> > this -
>
> > private MyAnchor ca = null;
> > public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
> > connection) {
> > if(ca == null) ca = new MyAnchor(getFigure());
> > return ca;
> > }
>
> > I don't think this has any sideeffects; seems to work fine for me.
>
> > > And another questions:
> > > How can I refresh the text in the label which I add to the
connection
> > > figure with ConnectionEndpointLocator.I use label.setText() in
> > > refreshVisuals(),but it doesnot work.And I try to use
> > > refreshChildren(),refreshSourceConnections(),it also doesnot work.
>
> > If you've called label.setText() in the refreshVisuals of the
connections
> > EditPart, then it should work just fine. Perhaps you should check if
> > refreshVisuals is being called when you change the labels Text, or if it
IS
> > being called, then the text has indeed changed and is not the same -
stupid,
> > but still check.
>
> > Hope this helps,
> > All the best,
> > Brian.
>
>
Re: Two input connections on one connectionanchor [message #119735 is a reply to message #119202] Fri, 27 February 2004 12:34 Go to previous message
Eclipse UserFriend
Originally posted by: josephlee.163.com

Lots of thanks, Brian!
Perhaps my poor english makes you confused.What I mean is to place N
number of connections on the same anchor(target anchor,not the source
anchor) on my figure.Also this is two input connections on the same
connectionAnchor.
thanks again!
Brian Fernandes wrote:

> "joseph" <josephlee@163.com> wrote in message
> news:c1ej02$ueg$1@eclipse.org...
> > thanks.
> > the label't content has been changed,but only I drag the connection to
> > another location and then back to the original location ,the content
> > change.Perhaps I should implement better method to finish my work.
> Clearly sounds like a refreshVisuals issue - are you sure refreshVisuals is
> called on the Connections editPart when you change the label text ?
> > And the anchor: what you mean is place the anchor to the same point on the
> > figure.But I place four anchor in my rectangle's edges' midpoint.Now I
> > want to drag the other connection to the same midpoint location on the
> > figure.I only can use getNodeFigure() to locate the anchor.I think if it
> > is my model's problem because my model is designed according to the
> > logic's circuit.I set the anchor's name using different letters .One
> > letter map to one anchor's input or output.
> > Can I modify my model?

> I'm not sure exactly what you want here. Do you want N number of connections
> on a particular figure ? Or do you want only 4 ? Say you want only 4
> connections per figure (whether source or target), from each midpoint of
> your figures rectangle sides. I'll assume this and go on.

> For all getSourceConnectionAnchor and getTargetConnectionAnchor calls,
> return the SAME anchor object for each EditPart. (Maybe as soon as your
> EditPart is created, create a new Anchor Object and return this all the
> time)

> Now this Anchor Object, has an internal list of the connecitons it has used
> up so far. Depending on the the connections already used up on the anchor,
> the Anchor will return a new position on the figures bounds in its
> getLocation method. If all 4 connectons are used up - make sure
> getSourceConnectionAnchor returns null.

> I just thought over this, and it IS better if you manage the connections
> list in the Model of the EditPart you intend to connect from/to and NOT in
> the Anchor. Depending on that, pass a parameter to your anchor and it will
> return an appropriate point. This is somewhat similar to what Logic does,
> but it limits the number of connections to two per figure.

> Hope I didn't miss the point and I wasn't too confusing, (if you can attach
> a picture of what you intend to do, maybe I'll be able to understand better)

> All the best,

> Brian.









> >
> > Brian Fernandes wrote:
> >
> > > "joseph" <josephlee@163.com> wrote in message
> > > news:c13vkv$jqr$1@eclipse.org...
> > > > Hi
> > > > Now I want to place two input connections on one
> connectionanchor,how
> > > > can I do it?In Logic examples I cannot found the same functions.
> >
> > > The Logic example, because of its very nature will allow only a certain
> > > number of connections per anchor - there is no point attaching more than
> one
> > > connection to a single terminal of a gate, for instance. Therefore Logic
> has
> > > additional "logic" to handle this. You probably just need to disregard
> this.
> >
> > > Make sure your editPart implements NodeEditPart, and in the
> > > getSourceConnectionAnchor and getTargetConnectionAnchor
> > > methods, simply return a NEW Anchor of your type, each time the method
> is
> > > called. If you want to give the appearance of all the connections
> beginning
> > > or ending from the same point, then write your anchor in such a way that
> it
> > > always returns the same point in the figure in it's getLocaton method.
> >
> > > I just checked and it is also possible to return the SAME Anchor object
> in
> > > the getSource/TargetConnectionAnchor methods - you can do something like
> > > this -
> >
> > > private MyAnchor ca = null;
> > > public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
> > > connection) {
> > > if(ca == null) ca = new MyAnchor(getFigure());
> > > return ca;
> > > }
> >
> > > I don't think this has any sideeffects; seems to work fine for me.
> >
> > > > And another questions:
> > > > How can I refresh the text in the label which I add to the
> connection
> > > > figure with ConnectionEndpointLocator.I use label.setText() in
> > > > refreshVisuals(),but it doesnot work.And I try to use
> > > > refreshChildren(),refreshSourceConnections(),it also doesnot work.
> >
> > > If you've called label.setText() in the refreshVisuals of the
> connections
> > > EditPart, then it should work just fine. Perhaps you should check if
> > > refreshVisuals is being called when you change the labels Text, or if it
> IS
> > > being called, then the text has indeed changed and is not the same -
> stupid,
> > > but still check.
> >
> > > Hope this helps,
> > > All the best,
> > > Brian.
> >
> >
Previous Topic:How to undo a drag operation
Next Topic:Re: refresh the label's content
Goto Forum:
  


Current Time: Fri Nov 08 22:00:07 GMT 2024

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

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

Back to the top