Skip to main content



      Home
Home » Eclipse Projects » GEF » Problems in positioning XYAnchor
Problems in positioning XYAnchor [message #131871] Wed, 12 May 2004 06:51 Go to next message
Eclipse UserFriend
Originally posted by: sagivijay.yahoo.com

Hi All,
I have two editparts that represent two classes Foo and Bar in my model.
Foo contains Bar.
In the editPart for Foo I create a FreeFormLayer and add a rectangleFigure
to it.
Now all that the user does is creates Bar objects by dragging and dropping
from the PaletteViewer. In the Bar editPart I create a label and use an
XYAnchor to connect it with the rectangleFigure created in the Foo
editPart. I do this by setting the reference point of the source and
target XYAnchors to the location of the label and the rectangleFigure
respectively.The labels for the Bar objects are created one below the
other as shown below

Bar1-Label

Bar2-Label Foo-RectangleFigure

Bar3-Label

This works abosolutely fine until the number of bar objects created
becomes too high that I have to scroll down to view the label for the bar
object created last.

At this point (when the graphicalViewer is scrolled to the bottom), when I
try to create a Bar Object, The XYAnchor that is supposed to create this
label with the rectangleFigure does not actually connect them. It looks
like its hanging in the air. I assume this is because XYAnchor does not
have an owner and all it needs is only the reference Point. Hence what it
actually does is it uses the reference Point relative to the visible
portion of the graphicalViewer instead of taking it as the absoulute
location in the graphicalViewer. To be more specific the top portion of
the graphical viewer that is presently invisible is kinda omitted while
positioning the XYAnchor. Hence it is actually placed below the location
of the label/RectangleFigure by an amount that is equal to the size of the
invisible portion of the graphicalViewer.

Any help on how I can fix this is greatly appreciated.

Thanks and Regards,
Vijay
Re: Problems in positioning XYAnchor [message #131910 is a reply to message #131871] Wed, 12 May 2004 17:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news-1.labouisse.invalid.org

Le Wed, 12 May 2004 10:51:13 +0000, Vijay a écrit :


>
> At this point (when the graphicalViewer is scrolled to the bottom), when I
> try to create a Bar Object, The XYAnchor that is supposed to create this
> label with the rectangleFigure does not actually connect them. It looks
> like its hanging in the air.

Well I have the same problem on a simpler example. I create a set of
Labels and put links between them using PolylineConnection. When I scroll
down or right, and create a new edge the anchors are "hanging in the air".
The interesting part may be that the points from the BendConnectionRouter
seem to be positionned at the right place.

final PolylineConnection conn = new PolylineConnection();
conn.setForegroundColor(ColorConstants.gray);
final PolygonDecoration dec = new PolygonDecoration();
conn.setTargetDecoration(dec);

final Point sourcePoint = (Point) bends.remove(0);
final Point targetPoint = new Point(route.getEndPt().getX(), route.getEndPt().getY());
contents.translateToRelative(sourcePoint);
conn.setSourceAnchor(new XYAnchor(sourcePoint));
conn.setTargetAnchor(new XYAnchor(targetPoint));

if (bends.isEmpty()) {
conn.setConnectionRouter(null);
} else {
conn.setConnectionRouter(new BendpointConnectionRouter());
conn.setRoutingConstraint(bends);
}

contents.add(conn);

--
Le cinéma en Lumière : http://www.lumiere.org/
Retirer .invalid pour me répondre
Remove .invalid to reply
Re: Problems in positioning XYAnchor [message #131967 is a reply to message #131910] Thu, 13 May 2004 04:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sagivijay.yahoo.com

Hi Christophe,

Thanks a lot for your answer. Though your solution did not work for me, it
helped me come up with a fix for my case (the translateToRelative method
helped me realize what I should be doing).

I am not sure if this would work for you. May be you can give it a try.

Since the co-ordinates of the source and target points were being
considered relative to the visible portion of the viewer (i.e the origin
was always assumed to be the top-left corner of the visible portion rather
than the absolute origin that was invisible), I translated these points to
absoulte co-ordinates using the parent figures location. The
BendConnectionRouter was not needed for this to work.
In effect, the following two lines of code fixed it.
contents.translateToAbsolute(sourcePoint);
contents.translateToAbsolute(sourcePoint);

conn.setSourceAnchor(new XYAnchor(sourcePoint));
conn.setTargetAnchor(new XYAnchor(targetPoint));

contents.add(conn);

Please give it a try and let me know if it works for you too.

Thanks a lot,
Vijay
Christophe Labouisse wrote:

> Le Wed, 12 May 2004 10:51:13 +0000, Vijay a écrit :


> >
> > At this point (when the graphicalViewer is scrolled to the bottom), when I
> > try to create a Bar Object, The XYAnchor that is supposed to create this
> > label with the rectangleFigure does not actually connect them. It looks
> > like its hanging in the air.

> Well I have the same problem on a simpler example. I create a set of
> Labels and put links between them using PolylineConnection. When I scroll
> down or right, and create a new edge the anchors are "hanging in the air".
> The interesting part may be that the points from the BendConnectionRouter
> seem to be positionned at the right place.

> final PolylineConnection conn = new PolylineConnection();
> conn.setForegroundColor(ColorConstants.gray);
> final PolygonDecoration dec = new PolygonDecoration();
> conn.setTargetDecoration(dec);

> final Point sourcePoint = (Point) bends.remove(0);
> final Point targetPoint = new Point(route.getEndPt().getX(),
route.getEndPt().getY());
> contents.translateToRelative(sourcePoint);
> conn.setSourceAnchor(new XYAnchor(sourcePoint));
> conn.setTargetAnchor(new XYAnchor(targetPoint));

> if (bends.isEmpty()) {
> conn.setConnectionRouter(null);
> } else {
> conn.setConnectionRouter(new BendpointConnectionRouter());
> conn.setRoutingConstraint(bends);
> }

> contents.add(conn);
Re: Problems in positioning XYAnchor [message #132133 is a reply to message #131967] Thu, 13 May 2004 17:47 Go to previous message
Eclipse UserFriend
Originally posted by: news-1.labouisse.invalid.org

Le Thu, 13 May 2004 08:12:44 +0000, Vijay a écrit :

> Hi Christophe,
>
> Thanks a lot for your answer. Though your solution did not work for me, it
> helped me come up with a fix for my case (the translateToRelative method
> helped me realize what I should be doing).

Nice I could help because the translateToRelative line was a remain of a
non working experiment and shouldn't have make it to the newsgroup.


> contents.translateToAbsolute(sourcePoint);
> contents.translateToAbsolute(sourcePoint);

I really don't know why but those lines have no effect for me. I put log
before and after the translate and whatever translate I try the point
coordinates do not change at all :-(.

--
Le cinéma en Lumière : http://www.lumiere.org/
Retirer .invalid pour me répondre
Remove .invalid to reply
Previous Topic:WYSIWYG HTML Editor?
Next Topic:What was the bug in the GEF logic example?
Goto Forum:
  


Current Time: Tue Mar 11 07:25:23 EDT 2025

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

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

Back to the top