Rotate graphical object [message #756453] |
Sun, 13 November 2011 14:39  |
Eclipse User |
|
|
|
Hello,
In my graphiti model, I have a triangle. However, I would like to rotate the triangle depending on its position. For that, I set up a function that checks first if the triangle can be moved (by extending the DefaultMoveShapeFeature).
So, now, I would like to be able to change the way the triangle is shown once he has been moved. So, I would like to know :
- Where can I put code that would be called once the triangle is moved ? Can I just call the post/pre-move function of the DefaultMoveShapeFeature inherited class ?
- How can I change the layout of the triangle and rotate it ? Is there some code example about that ? If there is no easy way to do so, can I remove the triangle and add a new one, without loosing the association with the business object ?
Thanks in advance for any hints/comments regarding this topic,
|
|
|
Re: Rotate graphical object [message #756525 is a reply to message #756453] |
Mon, 14 November 2011 08:21  |
Eclipse User |
|
|
|
my approach would be calling the triangles layoutfaeture from the postMove in the triangles movefeature.
In the LayoutFeature u just have to change the coordinates of the triangle polygon, there is no need of removing the trinagle and add a new one (at least i see no advantage in this).
The calculation of the new coordinates, thats just a mathematical problem, you will find plenty of infos therefor and i guess there ready for use java bibs available.
For code examples, just look in the tutorials layoutFeature. in the method layout() of your triangles layoutFeature you could change the Points of the triangle like this:
Triangle triangle = triangleShape.getGraphicsAlgorithm;
EList<Point> trianglePoints = triangle.getPoints();
trianglePoints.get(0).setX(1);
trianglePoints.get(0).setY(1);
trianglePoints.get(1).setX(2);
trianglePoints.get(1).setY(2);
trianglePoints.get(2).setX(3);
trianglePoints.get(2).setY(3);
|
|
|
Powered by
FUDForum. Page generated in 0.03031 seconds