Clean link in JGoArea

Hi;
I implemented my own JGoSubGraph to be area to hold a number of objects. I also create a number of links between object inside of group and outside regular node. It is fine when state is StateExpanded and link is fine from inside node to outside node.
When JGoSubGraph is in StateCollapsed, the link is not consist from JGoSubGraph, some links are just draw inside JGoSubGraph and some links are draw on the border.
My question is that can I overwrite some functions to make link always draw at border of JGoSubGraph to make it more clean?
Thanks
Steven

You can try having each invisible port pretend that the whole JGoSubGraph is its PortObject.
In your override of JGoSubGraph.collapseChild, if the child is a node, you can iterate over its ports and call JGoPort.setStyle(JGoPort.StyleObject) and JGoPort.setPortObject(theSubGraph). Your override of JGoSubGraph.expandChild can then restore the original values.

Hi Walter;
I follow your instruction to implement my JGoSubGraph. Now all the links is inside center place of my JGoSubGraph. I want all the links from outside link to the border of my JGoSubGraph.
What I should do ? move all the port to the border of my JGoSubgraph?
Steven

public class MyArea extends JGoSubGraph {
public MyArea(String label) {
super(label);
this.setGrabChildSelection(true);
}
public void paint(java.awt.Graphics2D g,JGoView view) {
super.paint(g, view);
Rectangle rect = this.getBoundingRect();
g.setColor(Color.red);
g.draw3DRect(rect.x,rect.y,rect.width,rect.height,false);

}
protected void collapseChild(JGoObject child,java.awt.Rectangle sgrect) {
JGoListPosition pos = getFirstObjectPos();
while (pos != null) {
JGoObject obj = getObjectAtPos(pos);
pos = getNextObjectPos(pos);

if (obj instanceof MyNode2) {
JGoPort port = ((MyNode2) obj).getPort();
port.setStyle(JGoPort.StyleObject);
port.setPortObject(this);
}
}
super.collapseChild(child,sgrect);
}
protected void expandChild(JGoObject child,java.awt.Point hpos) {
JGoListPosition pos = getFirstObjectPos();
while (pos != null) {
JGoObject obj = getObjectAtPos(pos);
pos = getNextObjectPos(pos);
if (obj instanceof MyNode2) {
JGoPort port = ((MyNode2) obj).getPort();
port.setStyle(JGoPort.StyleHidden);
port.setPortObject(obj);
}
}
super.expandChild(child,hpos);
}
}

Hi;
If somehow you can set JGoPort to be same size of JGoSubGraph, every thing will be perfect.
port.setBoundingRect(theSubGraph.getBoundingRect());
But I do not know where to put this code? After collapseChild method, do we have any event to trace to update JGoPort size ?
Thanks
Steven

Hi;
I use computeCollapsedSize(false) to find size. There are one or two pix difference. No complete perfect?
Any suggest?

Steven

protected void collapseChild(JGoObject child,java.awt.Rectangle sgrect) {
JGoListPosition pos = getFirstObjectPos();
while (pos != null) {
JGoObject obj = getObjectAtPos(pos);
pos = getNextObjectPos(pos);

if (obj instanceof MyNode2) {
JGoPort port = ((MyNode2) obj).getPort();
port.setStyle(JGoPort.StyleObject);
port.setPortObject(this);

Dimension d = this.computeCollapsedSize(false);
port.setWidth(d.width);
port.setHeight(d.height);
}
}

Changing the port size is probably undesirable, both because it’s annoying to have to change it back again later, and because it might not change exactly, depending on what its parent’s layoutChildren method does.
I suspect the problem is that JGoPort.getLinkPointFromPoint isn’t returning the value you want. I’m not sure why that is, since I haven’t had time to investigate.