[SOLVED] How to programmatically set the location of a label? [message #666802] |
Fri, 22 April 2011 16:25 |
Xavier Seignard Messages: 52 Registered: June 2010 |
Member |
|
|
Hello,
I've programmatically added two labels on my edge, but now I would like to implement something in order to set the location of my labels in a clever way.
I want them close to the first and last point of the edge, but I want them not overlapping the nodes at the end of it.
I also want them to be relocated when I move the nodes at the end of the edge.
So nothing fancy, only a standard strategy for placing a labels.
But I can't figure out how to do it.
For now I can place them close to the edge ends like this (where edgeFigure is the PolylineConnectionEx figure of the edge) :
targetRoleLabel = new WrappingLabel();
targetRoleLabel.setText(relDef.getTargetRole() + " [" + relDef.getTargetCard() + "]");
Point labelPoint = new Point(edgeFigure.getEnd().x - X_OFFSET, edgeFigure.getEnd().y - Y_OFFSET);
targetRoleLabel.setLocation(labelPoint);
edgeFigure.add(targetRoleLabel);
So I should find a smarter way to define the Point argument for the setLocation(Point p) method.
So if you have any hint it would be very welcome
Have a nice day,
Regards,
Xavier
[Updated on: Wed, 27 April 2011 09:38] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03509 seconds