Anchor on a Connection [message #93118] |
Tue, 09 September 2003 11:19  |
Eclipse User |
|
|
|
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 #95754 is a reply to message #93306] |
Mon, 29 September 2003 09:22   |
Eclipse User |
|
|
|
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 #96574 is a reply to message #96518] |
Wed, 01 October 2003 10:13   |
Eclipse User |
|
|
|
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 #97454 is a reply to message #97402] |
Mon, 06 October 2003 10:52  |
Eclipse User |
|
|
|
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 ?
>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04742 seconds