Skip to main content



      Home
Home » Eclipse Projects » GEF » attaching label to connection and anchors
attaching label to connection and anchors [message #48218] Fri, 06 December 2002 06:18 Go to next message
Eclipse UserFriend
Originally posted by: bramez.users.sourceforge.net

quick question:

how do I attach a label to a connection, and a label (as e.g. a
multiplicity indicator) to a anchor?

Bram
Re: attaching label to connection and anchors [message #48435 is a reply to message #48218] Fri, 06 December 2002 14:25 Go to previous message
Eclipse UserFriend
Originally posted by: noone.ibm.com

Bram Stieperaere wrote:

> quick question:
>
> how do I attach a label to a connection, and a label (as e.g. a
> multiplicity indicator) to a anchor?
>
> Bram

Bram Stieperaere" wrote in message news:... > quick question: > > how do
I attach a label to a connection, and a label (as e.g. a > multiplicity
indicator) to a anchor? > > Bram >

One way is to add the Label as a child to the connection and pass a
ConnectionLocator as the constraint. For example, if you wanted your
Label in the midpoint of the connection:

Figure rect1 = new RectangleFigure();
rect1.setBounds(new Rectangle(0,0,50,50));
Figure rect2 = new RectangleFigure();
rect2.setBounds(new Rectangle(500,500,50,50));
fig.add(rect1);
fig.add(rect2);

PolylineConnection c = new PolylineConnection();
c.setSourceAnchor(new ChopboxAnchor(rect1));
c.setTargetAnchor(new ChopboxAnchor(rect2));
fig.add(c);

Label label = new Label("MidPoint");
MidpointLocator ml = new MidpointLocator(c,0);
c.add(label,ml);

For the case of the multiplicity indicator, I would do it the same way
but use a ConnectionEndPointLocator:

Label endLabel = new Label("EndPoint");
ConnectionEndpointLocator ce = new ConnectionEndpointLocator(c,true);
c.add(endLabel,ce);
Previous Topic:line on figure and more
Next Topic:MarqueeDragTracker request
Goto Forum:
  


Current Time: Thu May 08 15:15:00 EDT 2025

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

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

Back to the top