public Node beforeDecode(mxCodec dec, Node node, Object into)
{
if (node instanceof Element)
{
Element elt = (Element) node;
mxGraphModel model = null;
if (into instanceof mxGraphModel)
{
model = (mxGraphModel) into;
}
else
{
model = new mxGraphModel();
}
// Reads the cells into the graph model. All cells
// are children of the root element in the node.
Node root = elt.getElementsByTagName("root").item(0);
mxICell rootCell = null;
if (root != null)
{
Node tmp = root.getFirstChild();
while (tmp != null)
{
mxICell cell = dec.decodeCell(tmp, true);
if (cell != null && cell.getParent() == null)
{
rootCell = cell;
}
tmp = tmp.getNextSibling();
}
root.getParentNode().removeChild(root);
}
// Sets the root on the model if one has been decoded
if (rootCell != null)
{
model.setRoot(rootCell);
}
}
return node;
}