Hello everybody,
I would like to know how many children a selected cell has. I have implemented this in the onMouseClick event:
// Get Cell under Mousepointer
int x = e.getX(), y = e.getY();
DefaultGraphCell cell = (DefaultGraphCell) jgraph.getFirstCellForLocation(x, y); //Object
Object nn=jgraph.getFirstCellForLocation(x, y);
String lab = jgraph.convertValueToString(cell);// Print Cell Label
int size=0;
Node node= new Node();
if (cell != null)
{
GraphModel m = jgraph.getModel();
node=(Node)cell.getUserObject();
// I tried each of the following functions to get the childcount, to not avail
// can you help me fix it, please?
size=cell.getChildCount();
size=jgraph.getModel().getChildCount(nn);
size=m.getChildCount(cell);
Node aux=new Node();
for (int i = 0; i < size; i++)
{
// Fetch the Child of Vertex at Index i
Object child = jgAdapter.getChild(cell, i);
if (child instanceof Node)
{
aux=(Node)child;
if(node.expanded==true)
jgAdapter.remove();
}
}
}
I want to get the number of children that the selected node has and i want to have access to all of them. How can i do that?
thanks!
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/ |