|
Re: attaching label to connection and anchors [message #48435 is a reply to message #48218] |
Fri, 06 December 2002 14:25  |
Eclipse User |
|
|
|
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);
|
|
|
Powered by
FUDForum. Page generated in 0.03455 seconds