Eclipse Community Forums Forum Search:

Home » Modeling » Graphiti » Rotate GraphicsAlgorithm(by an self defined angle)
Rotate GraphicsAlgorithm Thu, 06 March 2014 10:15
 John ColeMessages: 66Registered: June 2013 Member
Hello everybody!

I want to rotate some GraphicsAlgorithms like rectangles, polygons, polylines, etc. by an self defined int value (angle).

For example something like this (whereas there is no method called rotate):

```Shape shape = peCreateService.createShape(containerShape, false);
Rectangle rectangle = gaService.createRectangle(shape);
rectangle.rotate(270);```

In tis example it would be a rotation by 270°.
Can somebody help me?
Re: Rotate GraphicsAlgorithm [message #1266449 is a reply to message #1265616] Fri, 07 March 2014 13:30
 Michael WenzMessages: 1890Registered: July 2009 Location: Walldorf, Germany Senior Member
John,

unfortunatly, Graphiti as of today only supports rotating Text and
Polygon/Polyline graphics algorithms. For the rest, this is simply not
implemented yet.

As a workaround for now you migt try to draw a Polygon instead of a
rectangle and rotate that.

In order to see the real feature, please port an enhancement Bugzilla for
Graphiti.

Michael
Re: Rotate GraphicsAlgorithm [message #1268178 is a reply to message #1266449] Mon, 10 March 2014 06:41
 John ColeMessages: 66Registered: June 2013 Member
Hello Michael,

thank you very much for the answer. Probably I can solve this problem by transforming coordinates.

Best regards,
John
Re: Rotate GraphicsAlgorithm [message #1269863 is a reply to message #1266449] Wed, 12 March 2014 09:10
 John ColeMessages: 66Registered: June 2013 Member
Hello Michael,

can you tell me, how I can rotate a polyline or a polygon?
For the text there is a method called setAngle:

```int angle = 90;
Shape shape = peCreateService.createShape(containerShape, false);
Text text = gaService.createText(shape);
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setAngle(angle);```

I can't find such a method for the polyline/polygon.

Thank you very much in advance!

John

[Updated on: Wed, 12 March 2014 09:10]

Report message to a moderator

Re: Rotate GraphicsAlgorithm [message #1270148 is a reply to message #1269863] Wed, 12 March 2014 14:55
 Soeren MMessages: 77Registered: September 2011 Member
I think what he means is that you calculate the new positions by yourself.
Re: Rotate GraphicsAlgorithm [message #1270793 is a reply to message #1270148] Thu, 13 March 2014 13:53
 Michael WenzMessages: 1890Registered: July 2009 Location: Walldorf, Germany Senior Member
Right. Sorry for being not precise.

Michael
Re: Rotate GraphicsAlgorithm [message #1385394 is a reply to message #1270793] Fri, 06 June 2014 06:55
 John ColeMessages: 66Registered: June 2013 Member
I want to refer on that topic again, as I haven't found a solution yet.

I have defined some quite extensive shapes as following:
There is a container shape placed somewhere on the graphical editor (not he origin of course), which contains other shapes (rectangles, lines, polygons, etc.). All these basic shapes in the container form a complex overall shape.

In some cases I want to rotate that compound shape by an defined angle. Of course it would be the best solution to just rotate the container and the content would be rotated automatically (that would be the case if the container rectangle would define its own coordinate system) but unfortunately it is not possible. I also tried to translate each of the shapes to the origin, rotate it by using coordinate transformation

http://en.wikipedia.org/wiki/Transformation_matrix#Rotation

and then translate it back to the original position. But as the shapes are really complex, I am not able to represent them properly.

I also thought about using Graphics2D - as it supports AffineTransform - by converting the Graphiti shapes into Graphics2D shapes, rotate them and then transform them back to Graphiti shapes. But in my oppinion this is not a really good solution, as Graphics2D and Graphiti are quite different.

What in your opinion would be the best solution to realise that?

P.S. It would be sufficient to just rotate the elements by 90°, 180° and 270° for now.

[Updated on: Fri, 06 June 2014 06:57]

Report message to a moderator

 Previous Topic: Auto update not fully working ? Next Topic: [Spray] Problem with anchors
Goto Forum:

Current Time: Fri May 25 01:38:35 GMT 2018