How to change (Target)Anchor dynamicly? [message #227805] |
Mon, 11 December 2006 14:00 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
Originally posted by: js-ttn.jomisch.de
Hi Patrik,
> How about you only have one anchor that returns a
> different point based on
> the figure's location?
i have tried this before. Now i look at my solution again - and found my error.
thanks
josch
|
|
|
Powered by
FUDForum. Page generated in 0.03096 seconds