connection decorator rotation on move [message #851227] |
Fri, 20 April 2012 15:36  |
Eclipse User |
|
|
|
Hi there,
This is just a observation which should probably be piggy-backed onto an current bugzilla. But I was not sure if it is directly related since most of the current ones deal with zoom features.
We noticed that a connection decorator (in this case a triangle representing a arrowhead on a connection) will rotate slightly depending on the relative position of the arrow to the feature. Hence the triangle skews slightly and the polyline connector is no longer orthogonal to the base of the triangle.
Thanks,
Joe
|
|
|
|
Re: connection decorator rotation on move [message #855496 is a reply to message #853630] |
Tue, 24 April 2012 17:54   |
Eclipse User |
|
|
|
Hi Matthias,
Sorry it has taken me a bit to get back to this.
Here is the code snippet for creating the arrow head:
private Polyline createArrow(GraphicsAlgorithmContainer gaContainer) {
IGaService gaService = Graphiti.getGaService();
Polygon polygon =
gaService.createPolygon(gaContainer, new int[] { -15, 10, 1, 0, -15,
-10 });
polygon.setForeground(manageColor(IColorConstant.BLACK));
polygon.setBackground(manageColor(IColorConstant.BLACK));
polygon.setLineWidth(2);
polygon.setFilled(true);
return polygon;
}
It is called from:
public PictogramElement add(IAddContext context) {
IAddConnectionContext addConContext = (IAddConnectionContext) context;
IsSolvedBy addedIsSolvedBy = (IsSolvedBy) 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(IColorConstant.BLACK));
link(connection, addedIsSolvedBy);
ConnectionDecorator cd;
cd = peCreateService
.createConnectionDecorator(connection, false, 1.0, true);
createArrow(cd);
return connection;
}
Here are the images you requested.
The straight instance:

The crooked version. This was a user reported issue and I still cannot, completely, convince myself that it is not just my eyes playing tricks on me. But I don't drink at work...

Thanks for all your help,
Joe
Attachment: straight.png
(Size: 10.77KB, Downloaded 936 times)
Attachment: crooked.png
(Size: 9.67KB, Downloaded 931 times)
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.26839 seconds