Text rotation on connection [message #1064532] |
Wed, 19 June 2013 17:57 |
Stefano Rando Messages: 1 Registered: June 2013 |
Junior Member |
|
|
Hello,
I need to decorate a connection with a text, but the text should be parallel to the connection (or the first part of the connection).
Basically I would like to calculate the angle of the connection (or polyline) in the first point and then apply it to text, but I do not know how to do.
you have any suggestions?
Thank you.
Here's the code
public PictogramElement add(IAddContext context) {
IAddConnectionContext addConContext = (IAddConnectionContext) context;
EReference addedEReference = (EReference) context.getNewObject();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
Connection connection = peCreateService.createFreeFormConnection(getDiagram());
connection.setStart(addConContext.getSourceAnchor());
connection.setEnd(addConContext.getTargetAnchor());
IGaService gaService = Graphiti.getGaService();
Polyline polyline = gaService.createPolyline(connection);
polyline.setLineWidth(2);
polyline.setForeground(manageColor(E_REFERENCE_FOREGROUND));
link(connection, addedEReference);
ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.1, true);
Text text = gaService.createDefaultText(getDiagram(), textDecorator);
int textAngle = ???????;
text.setAngle(textAngle );
....
...
....
}
|
|
|
Powered by
FUDForum. Page generated in 0.02986 seconds