Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to change (Target)Anchor dynamicly?
How to change (Target)Anchor dynamicly? [message #227805] Mon, 11 December 2006 14:00 Go to next message
Eclipse UserFriend
Originally posted by: js-ttn.jomisch.de

Hello,

i have implemented my own anchorclass to handel alignments and offsets. the target-editpart of the connection has two incomming anchors. if the sourcefigur is left of the targetfigur the method getTargetConnectionAnchor() (calls getConnectionAnchor) return the left Anchor, otherwise the Anchor on the right side.

private ConnectionAnchor getConnectionAnchor(ConnectionEditPart connection) {
if (connection.getTarget() == this) {
PathEditPart sourcePathPart = (PathEditPart)connection.getSource().getParent();
if (sourcePathPart.getFigure().getBounds().x >= this.getFigure().getBounds().x)
return incomingAnchorRight;
else
return incomingAnchorLeft;
}
.
.

The Problem is that getTargetConnectionAnchor() is called before layouting is done. I have try to calculate the position in OffsetAnchor.getLocation() and set always a new anchor.


TargetEditPart =>
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
OffsetAnchor anchor = new OffsetAnchor(getFigure(), connection);
anchor.setXAlign(OffsetAnchor.Align.auto);
return anchor;
}

But it has very strange results with the ShortestPathRouter (zigzag). How can i set the Anchor dynamicly? Please, step by step - i'm a beginner.

thx
josch
Re: How to change (Target)Anchor dynamicly? [message #228174 is a reply to message #227805] Sat, 16 December 2006 21:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

How about you only have one anchor that returns a different point based on
the figure's location? That's kinda like the ChopboxAnchor (see Shapes
example if you don't know how it behaves), but returns a point from a finite
set of points (in your case, a set of 2 points).

"josch" <js-ttn@jomisch.de> wrote in message
news:13539704.1165845645433.JavaMail.root@cp1.javalobby.org...
> Hello,
>
> i have implemented my own anchorclass to handel alignments and offsets.
> the target-editpart of the connection has two incomming anchors. if the
> sourcefigur is left of the targetfigur the method
> getTargetConnectionAnchor() (calls getConnectionAnchor) return the left
> Anchor, otherwise the Anchor on the right side.
>
> private ConnectionAnchor getConnectionAnchor(ConnectionEditPart
> connection) {
> if (connection.getTarget() == this) {
> PathEditPart sourcePathPart =
> (PathEditPart)connection.getSource().getParent();
> if (sourcePathPart.getFigure().getBounds().x >=
> this.getFigure().getBounds().x)
> return incomingAnchorRight;
> else
> return incomingAnchorLeft;
> }
> .
> .
>
> The Problem is that getTargetConnectionAnchor() is called before layouting
> is done. I have try to calculate the position in
> OffsetAnchor.getLocation() and set always a new anchor.
>
>
> TargetEditPart =>
> public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart
> connection) {
> OffsetAnchor anchor = new OffsetAnchor(getFigure(), connection);
> anchor.setXAlign(OffsetAnchor.Align.auto);
> return anchor;
> }
>
> But it has very strange results with the ShortestPathRouter (zigzag). How
> can i set the Anchor dynamicly? Please, step by step - i'm a beginner.
>
> thx
> josch
Re: How to change (Target)Anchor dynamicly? [message #228183 is a reply to message #228174] Sun, 17 December 2006 20:25 Go to previous message
Eclipse UserFriend
Originally posted by: js-ttn.jomisch.de

Hi Patrik,

&gt; How about you only have one anchor that returns a
&gt; different point based on
&gt; the figure's location?

i have tried this before. Now i look at my solution again - and found my error.

thanks
josch
Previous Topic:DragAndDrop between two view
Next Topic:restore diagram problem
Goto Forum:
  


Current Time: Fri Apr 19 22:06:13 GMT 2024

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

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

Back to the top