JGOText ignoring newline feeds

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 class=“com.nwoods.jgo.JGo3DNoteRect” flapsize=“8” shadow=“4”/>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoRectangle”/>

<jgoxml:JGoClass class=“com.nwoods.jgo.JGoDrawable” drawablebrush=“jgoid14” drawablepen=“jgoid15” embeddedpenbrush=“true”>

<jgoxml:JGoClass brushcolor=“rgbalpha(255,255,204,255)” brushstyle=“65535” class=“com.nwoods.jgo.JGoBrush” id=“jgoid14”/>


<jgoxml:JGoClass class=“com.nwoods.jgo.JGoPen” id=“jgoid15” pencolor=“rgbalpha(192,192,192,255)” penstyle=“65535” penwidth=“1”/>

</jgoxml:JGoClass>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoObject” id=“jgoid12” obj_flags=“4195354” objheight=“70” objwidth=“325” objx=“375” objy=“275” user_flags=“0”/>


<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

----------------------------------------------

<jgoxml:JGoClass class=“com.nwoods.jgo.JGoObject” id=“jgoid13” obj_flags=“1034” objheight=“56” objwidth=“297” objx=“379” objy=“277” user_flags=“0”/>


<jgoxml:JGoClass class=“com.nwoods.jgo.JGoObject” obj_flags=“4228126” objheight=“70” objwidth=“325” objx=“375” objy=“275” user_flags=“0”/>

It works correctly when I try it here.

For debugging purposes, I’d suggest you start by turning off the SVG generation:

svgDomDoc.setGenerateSVG(false);

That will make the serialized data much simpler.

I notice that you are using your own class CommentNode. Can you post or email me (JGo at our domain) the source code for this class?

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 class=“com.nwoods.jgo.JGo3DNoteRect” flapsize=“8” shadow=“4”/>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoRectangle”/>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoDrawable” drawablebrush=“jgoid32” drawablepen=“jgoid33” embeddedpenbrush=“true”>

<jgoxml:JGoClass brushcolor=“rgbalpha(255,255,204,255)” brushstyle=“65535” class=“com.nwoods.jgo.JGoBrush” id=“jgoid32”/>


<jgoxml:JGoClass class=“com.nwoods.jgo.JGoPen” id=“jgoid33” pencolor=“rgbalpha(192,192,192,255)” penstyle=“65535” penwidth=“1”/>

</jgoxml:JGoClass>
<jgoxml:JGoClass class=“com.nwoods.jgo.JGoObject” id=“jgoid30” obj_flags=“4195354” objheight=“172” objwidth=“555” objx=“253” objy=“224” user_flags=“0”/>


<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”/>

Also, I have emailed you the CommentNode.java

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.

Thanks for looking into it.

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.