Grouping objects


I tried to group my nodes with the method in the example “demo1”:
But this method delete the links between my nodes. Is it possible to move a node in an area without losing links? (I can’t use layers, only area)
// make an area out of the current selection
public void groupAction() {
JGoSelection selection = getSelection();
JGoDocument doc = getDocument();
JGoArea area = new ISGraphGroup();
// now add the area to the document
// iterate through the selection’s objects and add them to
// the new area
JGoListPosition pos = selection.getFirstObjectPos();
while (pos != null) {
JGoObject temp = selection.getObjectAtPos(pos);
pos = selection.getNextObjectPos(pos);
// don’t let sub-areas get selected independent of the whole area
if (temp instanceof JGoArea)
((JGoArea) temp).setGrabChildSelection(false);
// move from document to the area
// update the selection too, for the user’s convenience


Currently you have two choices:

  1. you can just remember all the links and their current ports before the grouping operation, and then restore them afterwards
  2. you can override JGoPort.ownerChange to be a no-op during the grouping operation
    Most people do (1), but if you have already defined your own subclasses for all the ports that your application uses, then (2) is easier.
    We’ll build the behavior of (2) into a future release, along with methods on JGoLayer and JGoArea for adding collections of objects in a manner that doesn’t unlink links.


I tried the 2nd choice, but it doesn’t work like I want.
The nodes seems to be links but in fact not. I have dynamicals ports which appears and disappears when they are linked or unliked.
When I group my nodes. The link stay, but the ports of the nodes disappear.
When I ungroup the nodes, the links are fixed on the background and not on my nodes.
When did you plan your next release?


Hmm–sounds like you also need to control those “dynamic” ports which appear and disappear. I don’t know what you might be doing there, but maybe you need to disable their disappearance in this special circumstance, just as you disabled the port’s unlinking of links when the layer is changed.