Skip to main content



      Home
Home » Eclipse Projects » GEF » Anchor on a Connection
Anchor on a Connection [message #93118] Tue, 09 September 2003 11:19 Go to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

Is there an anchor that I can use to attach a connection to another
connection ? There was a post about this being implemented sometime; is it
there yet or do I have to write my own ?

Thanks,
Brian.
Re: Anchor on a Connection [message #93306 is a reply to message #93118] Wed, 10 September 2003 10:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

There is no such anchor yet. Try subclassing AbstractConnectionAnchor. In
addition to adding an ancestorListener to the owner, such an anchor would
also need to listen to the "points" property of a connection. If the set of
points change, it would also notify to its listeners.

getLocation() and getReferencePoint are pretty straightforwards. Feel free
to contribute back :-)


"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bjkq9j$5i2$1@eclipse.org...
> Is there an anchor that I can use to attach a connection to another
> connection ? There was a post about this being implemented sometime; is it
> there yet or do I have to write my own ?
>
> Thanks,
> Brian.
>
>
>
>
Re: Anchor on a Connection [message #93356 is a reply to message #93306] Wed, 10 September 2003 10:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

Thanks for the heads up.

Not as simple as I thought ...:)

I will have to put it off for a bit until I finish with my routing issues...

Will definitely contribute back. :-)

Thanks,
Brian.
Re: Anchor on a Connection [message #95754 is a reply to message #93306] Mon, 29 September 2003 09:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

Hi Randy,
In my initial Anchor implementation, I had extended
AbstractConnecitonAnchor and only overrode getLocation. The anchor would
simply return the closest point on it's owner figure .. (the point on the
owner figure closest to the argument to getLocation).

This seemed to work fine, but sometimes, even when doing something totally
removed from connections, for instance, adding an EditPart to the figure,
the anchor seems to detach itself from the connection. On the other hand,
most of the time it works perfectly fine. ie. The secondary connection is
connected to the closest point of the main connection(the connection to
which we are connecting it) If the main connection rerouts (due to moving
the edit parts to which it is connected ) then the seondary connection DOES
move with it. Most of the time it works, but it suddenly get's detached in
this case as well.


>In addition to adding an ancestorListener to the owner, such an anchor
would
> also need to listen to the "points" property of a connection. If the set
of
> points change, it would also notify to its listeners.
>

this is AbstractConnectionAnchor#addAnchorListener

public void addAnchorListener(AnchorListener listener) {
if (listener == null)
return;
if (listeners.size() == 0)
getOwner().addAncestorListener(this);
super.addAnchorListener(listener);
}

I was looking at this line...

getOwner().addAncestorListener(this)

what does this do ? I was trying to trace it but it was getting a bit
complex.

According to my understanding,
If I connect a connection to another connection, then getOwner() will return
a PolylineConnection. When the connection moves, then this anchor will be
informed (and fireAnchorMoved will ultimately be called) Isn't that all
that's needed ?

Or is "moving" slightly different in the case of a connection ?
Could you give me a little more info on how the anchor should listen to the
points the connection ? Again, to make my misunderstanding clear; I thought
"getOwner().addAncestorListener(this)" would be enough already.

Thanks a bunch,
Brian.

"Randy Hudson" <none@us.ibm.com> wrote in message
news:bjnbj5$m1m$1@eclipse.org...
> There is no such anchor yet. Try subclassing AbstractConnectionAnchor.
> getLocation() and getReferencePoint are pretty straightforwards. Feel
free
> to contribute back :-)
>
>
> "Brian Fernandes" <brian.fernandes@codito.com> wrote in message
> news:bjkq9j$5i2$1@eclipse.org...
> > Is there an anchor that I can use to attach a connection to another
> > connection ? There was a post about this being implemented sometime; is
it
> > there yet or do I have to write my own ?
> >
> > Thanks,
> > Brian.
> >
> >
> >
> >
>
>
Re: Anchor on a Connection [message #95841 is a reply to message #95754] Mon, 29 September 2003 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

I've also noticed that the connections (to other connections.. just
disconnect when I change the zoom factor).. they do not reconnect back again
when I go back to 100%.

Now I'm pretty sure that something is screwy with my anchor.. I do need to
listen to the points .. but I haven't the slightest clue how to, or why the
normal ancestorListener won't suffice.

Appreciate any help - and will contribute back of course,
Thanks,
Brian.
Re: Anchor on a Connection [message #96221 is a reply to message #95841] Tue, 30 September 2003 11:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bl9r6c$bkk$1@eclipse.org...
> I've also noticed that the connections (to other connections.. just
> disconnect when I change the zoom factor).. they do not reconnect back
again
> when I go back to 100%.
>
> Now I'm pretty sure that something is screwy with my anchor.. I do need to
> listen to the points .. but I haven't the slightest clue how to, or why
the
> normal ancestorListener won't suffice.
>
> Appreciate any help - and will contribute back of course,
> Thanks,
> Brian.

I figured out the zoom problem.. that was becuase I didn't call
getOwner().translatetoAbsolute() on the appropriate points. But the
connections are still disconnecting sometimes ... :(
Re: Anchor on a Connection [message #96370 is a reply to message #96221] Tue, 30 September 2003 14:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> I figured out the zoom problem.. that was becuase I didn't call
> getOwner().translatetoAbsolute() on the appropriate points. But the
> connections are still disconnecting sometimes ... :(

Does this happen on slanted lines? I can see where the intersection would
be non-integral, but must be rounded to an integer. Then, you must scale
that rounded value, which could cause detaching. Returning a PrecisionPoint
might solve such a problem.
Re: Anchor on a Connection [message #96518 is a reply to message #96370] Wed, 01 October 2003 02:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

> Does this happen on slanted lines? I can see where the intersection would
> be non-integral, but must be rounded to an integer. Then, you must scale
> that rounded value, which could cause detaching. Returning a
PrecisionPoint
> might solve such a problem.
>

I don't calculate an intersection point. I return one of the existing points
of the connection itself. I think something may be wrong with my general
anchor logic.. esp since I'm trying to think of all the connections which
are connected to a single connection as one single large connection. I will
have to rethink the logic of this algorithm...

Another alternative - my anchor right now is pretty complex.. instead of
that, perhaps I could anchor everything very simply to the primary
connection and put in the actual positioning of the end points in the
routing algorithm.

What I need to clarify here is.. do I need anymore listeners ? Does the
anchor need to listen to the points property of the connection ? Acording to
me; AbstractConnectionAnchor is doing this already with the
ancestorListener.

Thanks,
Brian.
Re: Anchor on a Connection [message #96574 is a reply to message #96518] Wed, 01 October 2003 10:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Actually, there is one more cause for this type of problem. Take an int,
divide by 4, and multiply by 4. This is what you are doing when you do a
translateToAbsolute, followed by a translateToRelative. Because of integer
truncation, you don't end up with the same number. To solve this, use a
PrecisionPoint.

"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:blds22$4uh$1@eclipse.org...
>
> > Does this happen on slanted lines? I can see where the intersection
would
> > be non-integral, but must be rounded to an integer. Then, you must
scale
> > that rounded value, which could cause detaching. Returning a
> PrecisionPoint
> > might solve such a problem.
> >
>
> I don't calculate an intersection point. I return one of the existing
points
> of the connection itself. I think something may be wrong with my general
> anchor logic.. esp since I'm trying to think of all the connections which
> are connected to a single connection as one single large connection. I
will
> have to rethink the logic of this algorithm...
>
> Another alternative - my anchor right now is pretty complex.. instead of
> that, perhaps I could anchor everything very simply to the primary
> connection and put in the actual positioning of the end points in the
> routing algorithm.
>
> What I need to clarify here is.. do I need anymore listeners ? Does the
> anchor need to listen to the points property of the connection ? Acording
to
> me; AbstractConnectionAnchor is doing this already with the
> ancestorListener.
>
> Thanks,
> Brian.
>
>
Re: Anchor on a Connection [message #97402 is a reply to message #96574] Mon, 06 October 2003 06:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

Okay, yes, I can see the problem... Will use PrecisonPoint.

Right now they seem to be anchorning fine though. You suggested a
contribution for this, but this is algorithm specific.. I've chosen to
anchor at any of the Point of the connection (the closest). Also, I haven't
overridden getReferncePoint. All I had to do was override getLocation. I
haven't added any listeners. Should I contribute this ?
Re: Anchor on a Connection [message #97454 is a reply to message #97402] Mon, 06 October 2003 10:52 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Never hurts to contibute. Ideal way is to open a bugzilla with attached
source code.

"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:blre70$edi$1@eclipse.org...
> Okay, yes, I can see the problem... Will use PrecisonPoint.
>
> Right now they seem to be anchorning fine though. You suggested a
> contribution for this, but this is algorithm specific.. I've chosen to
> anchor at any of the Point of the connection (the closest). Also, I
haven't
> overridden getReferncePoint. All I had to do was override getLocation. I
> haven't added any listeners. Should I contribute this ?
>
>
>
>
>
Previous Topic:please help me!!! How to add serval connection creation tools?
Next Topic:how to build the source code of a plugin project to .jar file?
Goto Forum:
  


Current Time: Mon Jun 02 01:55:34 EDT 2025

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

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

Back to the top