[GEF4] geometry axis [message #1712265] |
Thu, 22 October 2015 13:39 |
Sylvain Bi Messages: 10 Registered: May 2015 |
Junior Member |
|
|
I have 3 question about gef4 geometry display
- Y Axis : I would like to invert the Y axis, to make the Y axis start from the bottom to the top, and so invert all of my shapes... (c.f. image)
- Zoom : I would like to change the zoom by default to make my geometry bigger (c.f. image)
- shift the X and Y : I have found how to do :
ViewportModel viewportModel = getViewer().getAdapter(ViewportModel.class);
viewportModel.setTranslateX(x);
viewportModel.setTranslateY(y);
Actual display -------------------------------------------------------------------> Needed Display
For the moment I convert each of my points like that :
pointConverted = [ pointToConvert.x * zoom, - pointToConvert.y * zoom]
That makes my code more difficult to understand because I lost my right distances... is there a way to fix the #1 & #2 questions? thanks you
[Updated on: Fri, 23 October 2015 13:58] Report message to a moderator
|
|
|
Re: GEF4 geometry axis [message #1712333 is a reply to message #1712265] |
Fri, 23 October 2015 07:02 |
|
Hi,
the ViewportModel manages a "contentsTransform" additional to the "translateX" and "translateY" values that you already found.
The contentsTransform is a transformation matrix that is applied to all visuals. Therefore, you can set the contentsTransform to a scale that inverts the Y axis and zooms in: viewportModel.setContentsTransform(new AffineTransform().scale(2, -2));
The translateX and translateY values are applied to the transformed contents, therefore, you could compute them based on the viewer's bounds if you want to keep the origin in the center.
Best regards,
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.02528 seconds