JGOSubgraph expand/collapse problem

I have a diagram with a context menu item to allow adding selected nodes to a subgraph. Everything works and looks perfect. I am using the TestSubGraph class from your demos. The problem is that when I collapse the graph it also looks correct, but when I expand it again, it loses the background color specified in the TestSubGraph class and the collapsed object which is an image stays even though it is expanded. Any thoughts.?

I can send you images of the problem if you like. Also, how do you listen for the expand/collapse event.

You can listen for the expand/collapse event by setting up a JGoDocumentListener and looking for a hint value of JGoDocumentEvent.CHANGED, and a subhint (flags value) of JGoSubGraph.ChangedState. Then check to see the current state of the JGoSubgraph. Something like the following:

void jGoView1_documentChanged(JGoDocumentEvent e) {
int hint = e.getHint();
int subhint = e.getFlags();
switch (e.getHint()) {
case JGoDocumentEvent.CHANGED:
if (e.getFlags() == JGoSubGraph.ChangedState)
if (e.getJGoObject() instanceof JGoSubGraph) {
JGoSubGraph sg = (JGoSubGraph)e.getJGoObject();
if (sg.isExpanded())
"... do whatever you want when graph is expanded" }
I'm not sure what's going on when you expand your TestSubGraph. Have you modified the TestSubGraph class or created a subclass? If so, can you show me the modified/added code?

My first problem has cleared up. I think I was doing an erroneous repaint. For the second item JGosubgraph events, the document event catches it correctly as you indicated. What I am trying to do is re-layout the graph when the subgraph is collapsed so there is not so much empty space. I actually think this is working except the view does not update. If I move a node, the view updates and shows the new layout. I wonder if it is because I am calling the layout method from within the Extended view class.


Calling the layout method from your extended view class should be fine, but I wonder if perhaps you have overridden one of the GoView methods and are not properly calling super to get the standard behavior. This could be in any of the GoView methods you have overriden, so check them all.

I've just testing doing an autolayout from my expand handler and it seems to work well for me - no repainting problems.

I will check this out. I have the jgoview inside a JIDE DOcument pane and I suppose it might be interrupting some of the update events

This still does not work correctly. It seems to be a timing or refresh problem. When I put a JOptionpane after the call to layout the document, it works fine. Otherwise no luck. iT does work for the expand event but not the collapse.

I’m going to continue this discussion with you in email so we can more easily exchange sample code. I’ll update this topic once it’s resolved.