Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Rotate graphical object
Rotate graphical object [message #756453] Sun, 13 November 2011 14:39 Go to next message
Julien Delange is currently offline Julien DelangeFriend
Messages: 82
Registered: October 2011
Member
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 Go to previous message
Christian B is currently offline Christian BFriend
Messages: 68
Registered: August 2011
Member
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);




Previous Topic:Getting IProject instance associated to a Diagram
Next Topic:Enlarge click area for connections
Goto Forum:
  


Current Time: Fri Mar 29 12:19:44 GMT 2024

Powered by FUDForum. Page generated in 0.02566 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top