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 09:39 Go to next message
Julien Mising name is currently offline Julien Mising name
Messages: 11
Registered: October 2011
Junior 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 03:21 Go to previous message
Christian B is currently offline Christian B
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: Thu Jul 31 17:38:17 EDT 2014

Powered by FUDForum. Page generated in 0.02942 seconds