I have a JGoArea with a Jgo3DNoteRect at its head and JGoText at its
tail. When a strings are entered into the text box with newlines the text box displays just fine. However, after serializing and
de-serializing this box, when I bring up the UI again, the newlines are completely ignored and the text is combined and wrapped at the set width
The below
screen shots should make this problem clear. The first one is taken
before serialization and the other after.
I use JGo 5.1.5
Original:
Bringing up box again, after serializing and deserializing (handled by JGo)
Here is the serialized data pertaining to this component. I would
appreciate help in spotting the issue in this data and suggestions
towards possible fixes. Thanks.
<jgoxml:JGoClass User_Comment=“OPS-DIALOG: This is unusual --------------------
----------------------------------------------
This is the main content and the returns should be preserved
----------------------------------------------” class=“com.realops.ui.client.designer.nodes.CommentNode” label=“jgoid13” partid=“10” rectobj=“jgoid12”/>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoArea”/>
<jgoxml:JGoClass alignment=“1” backcolor=“white” class=“com.nwoods.jgo.JGoText” facename=“SansSerif” fontsize=“11” text=“OPS-DIALOG: This is unusual --------------------
----------------------------------------------
This is the main content and the returns should be preserved
----------------------------------------------” textcolor=“black” textflags=“118929” usertextflags=“0” wrappingwidth=“325”/>
OPS-DIALOG: This is unusual --------------------
----------------------------------------------
This is the main content and the returns should be preserved
Thanks for your response. here is the output after setting svgDoc.setGenerateSVG(false);
<jgoxml:JGoClass User_Comment=“OPS-DIALOG: This is wrapping testing:
----------------------------------------------
This is the main content
----------------------------------------------
The PM .” class=“com.realops.ui.client.designer.nodes.CommentNode” label=“jgoid31” partid=“4” rectobj=“jgoid30”/>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoArea”/>
<jgoxml:JGoClass alignment=“1” backcolor=“white” class=“com.nwoods.jgo.JGoText” facename=“SansSerif” fontsize=“12” text=“OPS-DIALOG: This is wrapping testing:
----------------------------------------------
This is the main content
----------------------------------------------
The PM .” textcolor=“black” textflags=“86161” usertextflags=“0” wrappingwidth=“555”/>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoObject” id=“jgoid31” obj_flags=“1034” objheight=“160” objwidth=“553” objx=“257” objy=“226” user_flags=“0”/>
Thanks for source code. I’ve updated my test application to use your CommentNode class, and everything appears to work fine for me. FYI, I’m using \n as the newline character in my string literal to initialize the CommentNode. I assume you’ve done the same.
Initial appearance:
Appearance after save, clear and restore:
I've also looked through the change history for JGoText and I'm not seeing anything jump out at me, but perhaps one of the changes to JGo since version 5.15 (released in Feb 2006) fixes this problem.
Download the current evaluation version and see if that corrects the problem.
Just to point out, I have wrapping turned on in my code. So I believe as per the docs also
Wrapping property is described as :
whether to automatically insert line breaks even when there is no
newline character embedded in the string; Multiline must also be true for
wrapping to take place, and any embedded newline characters are ignored.
So based on above, I tried explicitly setting wrapping to false inside layoutChildren and it worked. But not sure if it’s a good Idea: The working piece of code inside my layoutChildren looks like:
JGoText label = getLabel();
if (label != null) {
JGo3DNoteRect rect = getRect();
if (rect != null) {
int left = label.getLeft() - 4;
int top = label.getTop() - 2;
int width = Math.max(label.getWidth() + 2, rect.getWidth());
if (label.getText().indexOf("\n") != -1) {
label.setWrappingWidth(width);
}
label.setWrapping(false);
int height = Math.max(label.getHeight() + 4
+ rect.getFlapSize(), rect.getHeight());
rect.setBoundingRect(left, top, width, height);
}
}
Thanks for the update, I’m glad it’s working for you. In the current version, the wrapping property will insert newlines as necessary, but will also respect existing newlines, so you want to upgrade at some point, but it’s up to you.