@Override public Node afterEncode(mxCodec enc, Object obj, Node node) { if (obj instanceof mxRootChange) { enc.encodeCell((mxICell) ((mxRootChange) obj).getRoot(), node, true); } return node; }
@Override public Node afterEncode(mxCodec enc, Object obj, Node node) { if (obj instanceof mxRootChange) { enc.encodeCell((mxICell) ((mxRootChange) obj).getRoot(), node, true); } return node; }
/** * Encodes the given mxGraphModel by writing a (flat) XML sequence * of cell nodes as produced by the mxCellCodec. The sequence is * wrapped-up in a node with the name root. */ protected void encodeObject(mxCodec enc, Object obj, Node node) { if (obj instanceof mxGraphModel) { Node rootNode = enc.document.createElement("root"); mxGraphModel model = (mxGraphModel) obj; enc.encodeCell((mxICell) model.getRoot(), rootNode, true); node.appendChild(rootNode); } }
/** * Encodes the given mxGraphModel by writing a (flat) XML sequence * of cell nodes as produced by the mxCellCodec. The sequence is * wrapped-up in a node with the name root. */ protected void encodeObject(mxCodec enc, Object obj, Node node) { if (obj instanceof mxGraphModel) { Node rootNode = enc.document.createElement("root"); mxGraphModel model = (mxGraphModel) obj; enc.encodeCell((mxICell) model.getRoot(), rootNode, true); node.appendChild(rootNode); } }
/** * Encoding of cell hierarchies is built-into the core, but is a * higher-level function that needs to be explicitely used by the * respective object encoders (eg. mxModelCodec, mxChildChangeCodec * and mxRootChangeCodec). This implementation writes the given cell * and its children as a (flat) sequence into the given node. The * children are not encoded if the optional includeChildren is false. * The function is in charge of adding the result into the given node * and has no return value. * * @param cell mxCell to be encoded. * @param node Parent XML node to add the encoded cell into. * @param includeChildren Boolean indicating if the method * should include all descendents. */ public void encodeCell(mxICell cell, Node node, boolean includeChildren) { node.appendChild(encode(cell)); if (includeChildren) { int childCount = cell.getChildCount(); for (int i = 0; i < childCount; i++) { encodeCell(cell.getChildAt(i), node, includeChildren); } } }
/** * Encoding of cell hierarchies is built-into the core, but is a * higher-level function that needs to be explicitely used by the * respective object encoders (eg. mxModelCodec, mxChildChangeCodec * and mxRootChangeCodec). This implementation writes the given cell * and its children as a (flat) sequence into the given node. The * children are not encoded if the optional includeChildren is false. * The function is in charge of adding the result into the given node * and has no return value. * * @param cell mxCell to be encoded. * @param node Parent XML node to add the encoded cell into. * @param includeChildren Boolean indicating if the method * should include all descendents. */ public void encodeCell(mxICell cell, Node node, boolean includeChildren) { node.appendChild(encode(cell)); if (includeChildren) { int childCount = cell.getChildCount(); for (int i = 0; i < childCount; i++) { encodeCell(cell.getChildAt(i), node, includeChildren); } } }
@Override public Node afterEncode(mxCodec enc, Object obj, Node node) { if (obj instanceof mxChildChange) { mxChildChange change = (mxChildChange) obj; Object child = change.getChild(); if (isReference(obj, "child", child, true)) { // Encodes as reference (id) mxCodec.setAttribute(node, "child", enc.getId(child)); } else { // At this point, the encoder is no longer able to know which cells // are new, so we have to encode the complete cell hierarchy and // ignore the ones that are already there at decoding time. Note: // This can only be resolved by moving the notify event into the // execute of the edit. enc.encodeCell((mxICell) child, node, true); } } return node; }
@Override public Node afterEncode(mxCodec enc, Object obj, Node node) { if (obj instanceof mxChildChange) { mxChildChange change = (mxChildChange) obj; Object child = change.getChild(); if (isReference(obj, "child", child, true)) { // Encodes as reference (id) mxCodec.setAttribute(node, "child", enc.getId(child)); } else { // At this point, the encoder is no longer able to know which cells // are new, so we have to encode the complete cell hierarchy and // ignore the ones that are already there at decoding time. Note: // This can only be resolved by moving the notify event into the // execute of the edit. enc.encodeCell((mxICell) child, node, true); } } return node; }