I’m having an issue with text alignment in my JGo code, and was wondering if anybody could help. I’ve tried a few different ways of coding what I want, and will show the code and the results in the following examples and attachments.
Example 1: I have a class that extends JGoText, where I call the following code upon initialization:
Everything looks fine when I view the text in my app until I zoom or print. When I do this, the text creates a new line at odd places and wraps incorrectly. The text selection’s rectangle has the correct bounds, but the text goes out of this text selection.
2. When I comment out code like the following, the zooming and printing works correctly. However, the text does not wrap at all, which is problematic with long strings.
3. When I comment out code like the following, the zooming and printing works correctly. The text does wraps, but is not centered, which is not correct for what I want.
From my experimentation, it seems as if there is a multi-line wrapping problem when using CENTER alignment. Has anybody else run into this issue? Or does anybody know of a workaround? FYI, I am using the SWT version of JGo within an Eclipse plugin.
That’s odd, because I just tried this in Demo1 by setting those three properties of the JGoText label of a node, using the inspector.
At scale == 1:
The same node, zoomed in (note the different line breaks):
What version of JGo are you using?
Thanks for the reply,
I am using JGoSWT 5.15. I did some more investigation into my code, and I’ve found that the incorrect wrapping occurs with short strings, but is correct with longer strings. I will also try to play around with the Demo1 code.
So, I played around with the Demo1 program and found that I can reproduce the problem. I just started zooming and saw that the Draggable Label example in the demo exhibits the same problem I see in my app. I changed the JGoText object to have multiline=true, wrapping=true and then zoomed in about 5 times. The problem becomes more apparent the more you zoom in. The text is not centered, it all contained to the left of center. The selection bounding box looks correct, however. Any ideas?
It’s a bug. Try using http://www.nwoods.com/forum/uploads/JGoText.java instead.
Thanks for reporting the problem. We ought to do more testing at various scales.
Thanks for providing the patched JGoText.java file. How would you recommend I go about actually using this patch in my production code?
Here’s what I tried:
I have the JGoSWT.jar file in my path, and tried creating a com/nwoods/jgo directory in my source directory and dropping this patched JGoText.java file into it. However, this didn’t work as it seems that there are methods in other classes that JGoText depends on that have been renamed in the .class file. For instance, there are many package private methods that don’t seem to be found, such as Graphics2D.getScale(), JGoView.getEffectivePrintScale().
My other thought was to patch my JGoSWT.jar file with just the updated JGoText.class file. But then I noticed jar seems to be signed, as every class file has a SHA-1-Digest and MD5-Digest entry in the manifest file. So, patching the jar file is out of the question if we want to keep the jar file properly signed.
The other thing I can think of would be to get a patched JGoSWT.jar file from NorthWoods that is signed, and I could just drop this file over my old JGoSWT.jar.
Thanks for your support.
OK, send us e-mail.