Resizable Comment and CHANGED event

Following situation:
I wrote a slightly extended version of Comment (included with the examples). I overwrote #layoutChildren so that the node’s size can be interactively changed. This works so far.

Problem is:
In my app the user has a JTabbedPane with JGOView instances. When I load a flowchart in a JGoDocument, I regsiter a DocumentChangedListener to be able to give the user feedback, that a flowchart has been changed and to show option dialogs when the user wants to close the tab or the appplication.
Unfortunately, when a flowchart contains my extended version of Comment, called StdComment, after calling JGoView#setDocument and registering the DocumentChangedListener, the StdComment fires a CHANGED event, although no change is visible. This does not happen with the original Comment class, which looks rather ugly in a JGoPalette, because it doesn’t care whether I set it’s size or not.

So, here is my rather ugly #layoutChildren. It would be great if we could get the node not to fire this particular CHANGED event which I think is fired up when the nodes gets displayed in the view the first time, which unfortunaletyl happens after I attached the listener.

[code] public void layoutChildren(JGoObject childchanged) {
if (isInitializing()) return;

    JGoText label = getLabel();
    if (label != null) {                                    
        final JGo3DNoteRect rect = getRect();                    
        if (rect != null) {
            // change node's size, if necessary
            if ((rect.getWidth() < label.getWidth()+12) &&
                    (rect.getHeight() < label.getHeight() + 4 +
                            rect.getFlapSize())) {
                rect.setBoundingRect(label.getLeft() - 4,
                        label.getTop() - 2,
                        label.getWidth() + 12,
                        label.getHeight() + 4 + rect.getFlapSize());
            }
        }
    }
}[/code]

P.S.:
I’d like to see the “Forgot your password?” link on the forum’s login form, as I’d like to be myself again ;)

That’s odd. Painting should not result in a call to layoutChildren, or any other document change.
If you look at the subhint for the JGoDocumentEvent.CHANGED case, is the value JGoObject.ChangedGeometry? If you set a break-point at that call to rect.setBoundingRect, does it execute after you have finished loading the document, when you show the view?
Regarding the forum, if you tell me your preferred name, I’ll see if I can reset things. You might want to post your suggestion in reply to the sticky note about choosing a new forum. Although that’s going to have to wait (if it’s going to happen at all) until we have upgraded our server(s).

Ahhh! My answer got lost with “RPC server unavailable” :(


Here I go again:
DocumentChangedEvent#getFlags delivers 1, but I do not know where to look up the description scratchinghead.

And no, rect#getBoundingRect does not get called after loading and displaying the flow.


I am registered as ‘AlArenal’ but cannot remeber my password. As the forum system does not send a Welcome mail with my username and password, I could not look it up again. :(

You can look up JGoDocumentEvent.CHANGED subhints/flags in the description for JGoObject.update. JGoObject.ChangedGeometry is indeed 1.
OK, so in your document listener when a change happens unexpectedly you can look at the stack to get a clue for why the change occurred. It must be some other object’s changing its bounding rect, or else that same comment rect changing for a different reason.

I have reset AlArenal’s password to be the same as ALanger’s e-mail address.
I don’t know how to change the author of these posts, without digging into the database and modifying some fields directly.

Thanks for the stack tip. I’m such a moron… The code of this class is pretty old and because I couldn’t help me in another way I overwrote #paint to adjust the background’s width in case the label increases its own width after editing. I forgot about that meanwhile and now it backfired at me. That’s a big DON’T :)

I moved the code into #layoutChildren, deleted my #paint and everything’s fine now.

Thanks for helping me out, Walter!

Thanks, Walter! :)