I just wanted to check if there is an example of rotated text class available for SWT… Or How I can implement rotated text “Vertical label” for SWT
The current implementation of JGo for SWT assumes only SWT version 3.0, so there’s no support for rotation.
If you are assuming 3.1, you might be able to use the example rotated text class (RotText) from Swing and change the paint method to use the new SWT 3.1 Transform class.
I used the RotText class. In the paint method I created a Transform object from the graphics object:
Transform t = new Transform(g.Device);
and instead of the following line:
g.rotate(angle, r.x+r.width/2, r.y+r.height/2);
because the Transform class does not have a rotate method with the same used signature in Graphics2D class.
I couldn’t know if this will work because I got compilation errors:
In expandRectByPenWidth(Rectangle rect) method there was an error in the following line:
because swt Rectangle doesn’t contain setBounds Method.
In isPointInObj(Point pnt) there was an error in the following line:
because swt Shape doesn’t contain contains(Point) method.
and the same thing in updateRealBounds(Rectangle r) I got errors because swt Shape doesn’t contain createTransformedShape or getBounds methods.
How can I fix those errors?
Right now I don’t know. I tried this briefly but ran into some unexplained behavior.
We’re considering requiring version 3.1 for our next version of JGo for SWT, so that we can take advantage of the new graphics features.