<divid=Content><divclass="CClass"><divclass=CTopicid=MainTopic><h1class=CTitle><aname="mxCodec"></a>mxCodec</h1><divclass=CBody><p>XML codec for JavaScript object graphs. See <ahref="mxObjectCodec-js.html#mxObjectCodec"class=LClassid=link23onMouseOver="ShowTip(event, 'tt20', 'link23')"onMouseOut="HideTip('tt20')">mxObjectCodec</a> for a description of the general encoding/decoding scheme. This class uses the codecs registered in <ahref="mxCodecRegistry-js.html#mxCodecRegistry"class=LClassid=link24onMouseOver="ShowTip(event, 'tt21', 'link24')"onMouseOut="HideTip('tt21')">mxCodecRegistry</a> for encoding/decoding each object.</p><h4class=CHeading>References</h4><p>In order to resolve references, especially forward references, the mxCodec constructor must be given the document that contains the referenced elements.</p><h4class=CHeading>Examples</h4><p>The following code is used to encode a graph model.</p><blockquote><preclass="prettyprint">var encoder = new mxCodec();
var xml = mxUtils.getXml(result);</pre></blockquote><h4class=CHeading>Example</h4><p>Using the code below, an XML document is decoded into an existing model. The document may be obtained using one of the functions in mxUtils for loading an XML file, eg. <ahref="../util/mxUtils-js.html#mxUtils.get"class=LFunctionid=link25onMouseOver="ShowTip(event, 'tt22', 'link25')"onMouseOut="HideTip('tt22')">mxUtils.get</a>, or using <ahref="../util/mxUtils-js.html#mxUtils.parseXml"class=LFunctionid=link26onMouseOver="ShowTip(event, 'tt23', 'link26')"onMouseOut="HideTip('tt23')">mxUtils.parseXml</a> for parsing an XML string.</p><blockquote><preclass="prettyprint">var doc = mxUtils.parseXml(xmlString);
codec.decode(doc.documentElement, graph.getModel());</pre></blockquote><h4class=CHeading>Example</h4><p>This example demonstrates parsing a list of isolated cells into an existing graph model. Note that the cells do not have a parent reference so they can be added anywhere in the cell hierarchy after parsing.</p><blockquote><preclass="prettyprint">var xml = '<root><mxCell id="2" value="Hello," vertex="1"><mxGeometry x="20" y="20" width="80" height="30" as="geometry"/></mxCell><mxCell id="3" value="World!" vertex="1"><mxGeometry x="200" y="150" width="80" height="30" as="geometry"/></mxCell><mxCell id="4" value="" edge="1" source="2" target="3"><mxGeometry relative="1" as="geometry"/></mxCell></root>';
graph.addCells(cells);</pre></blockquote><h4class=CHeading>Example</h4><p>Using the following code, the selection cells of a graph are encoded and the output is displayed in a dialog box.</p><blockquote><preclass="prettyprint">var enc = new mxCodec();
mxUtils.alert(mxUtils.getPrettyXml(enc.encode(cells)));</pre></blockquote><p>Newlines in the XML can be converted to <br>, in which case a ‘<br>’ argument must be passed to <ahref="../util/mxUtils-js.html#mxUtils.getXml"class=LFunctionid=link27onMouseOver="ShowTip(event, 'tt24', 'link27')"onMouseOut="HideTip('tt24')">mxUtils.getXml</a> as the second argument.</p><h4class=CHeading>Debugging</h4><p>For debugging I/O you can use the following code to get the sequence of encoded objects:</p><blockquote><preclass="prettyprint">var oldEncode = mxCodec.prototype.encode;
};</pre></blockquote><p>Note that the I/O system adds object codecs for new object automatically. For decoding those objects, the constructor should be written as follows:</p><blockquote><preclass="prettyprint">var MyObj = function(name)
};</pre></blockquote><!--START_ND_SUMMARY--><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><trclass="SMain"><tdclass=SEntry><ahref="#mxCodec">mxCodec</a></td><tdclass=SDescription>XML codec for JavaScript object graphs. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodec.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.mxCodec"id=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">mxCodec</a></td><tdclass=SDescription>Constructs an XML encoder/decoder for the specified owner document.</td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodec.Variables">Variables</a></td><tdclass=SDescription></td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.document"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">document</a></td><tdclass=SDescription>The owner document of the codec.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxCodec.objects"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">objects</a></td><tdclass=SDescription>Maps from IDs to objects.</td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.elements"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">elements</a></td><tdclass=SDescription>Lookup table for resolving IDs to elements.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxCodec.encodeDefaults"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">encodeDefaults</a></td><tdclass=SDescription>Specifies if default values should be encoded. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxCodec.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.putObject"id=link6onMouseOver="ShowTip(event, 'tt6', 'link6')"onMouseOut="HideTip('tt6')">putObject</a></td><tdclass=SDescription>Assoiates the given object with the given ID and returns the given object.</td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.getObject"id=link7onMouseOver="ShowTip(event, 'tt7', 'link7')"onMouseOut="HideTip('tt7')">getObject</a></td><tdclass=SDescription>Returns the decoded object for the element with the specified ID in <ahref="#mxCodec.document"class=LVariableid=link8onMouseOver="ShowTip(event, 'tt2', 'link8')"onMouseOut="HideTip('tt2')">document</a>. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.lookup"id=link9onMouseOver="ShowTip(event, 'tt8', 'link9')"onMouseOut="HideTip('tt8')">lookup</a></td><tdclass=SDescription>Hook for subclassers to implement a custom lookup mechanism for cell IDs. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.getElementById"id=link10onMouseOver="ShowTip(event, 'tt9', 'link10')"onMouseOut="HideTip('tt9')">getElementById</a></td><tdclass=SDescription>Returns the element with the given ID from <ahref="#mxCodec.document"class=LVariableid=link11onMouseOver="ShowTip(event, 'tt2', 'link11')"onMouseOut="HideTip('tt2')">document</a>.</td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxCodec.addElement"id=link12onMouseOver="ShowTip(event, 'tt10', 'link12')"onMouseOut="HideTip('tt10')">addElement</a></td><tdclass=SDescription>Adds the given element to <ahref="#mxCodec.elements"class=LVariableid=link13onMouseOver="ShowTip(event, 'tt4', 'link13')"onMouseOut="HideTip('tt4')">elements</a> if it has an ID.</td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxCodec.getId"id=link14onMouseOver="ShowTip(event, 'tt11', 'link14')"onMouseOut="HideTip('tt11')">getId</a></td><tdclass=SDescription>Returns the ID of the specified object. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahre
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.mxCodec"></a>mxCodec</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>function mxCodec(</td><tdclass=PParameternowrap>document</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Constructs an XML encoder/decoder for the specified owner document.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>document</td><tdclass=CDLDescription>Optional XML document that contains the data. If no document is specified then a new document is created using <ahref="../util/mxUtils-js.html#mxUtils.createXmlDocument"class=LFunctionid=link28onMouseOver="ShowTip(event, 'tt25', 'link28')"onMouseOut="HideTip('tt25')">mxUtils.createXmlDocument</a>.</td></tr></table></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.document"></a>document</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.document</td></tr></table></blockquote><p>The owner document of the codec.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.objects"></a>objects</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.objects</td></tr></table></blockquote><p>Maps from IDs to objects.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.elements"></a>elements</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.elements</td></tr></table></blockquote><p>Lookup table for resolving IDs to elements.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxCodec.encodeDefaults"></a>encodeDefaults</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.encodeDefaults</td></tr></table></blockquote><p>Specifies if default values should be encoded. Default is false.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.putObject"></a>putObject</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.putObject = function(</td><tdclass=PParameternowrap>id,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Assoiates the given object with the given ID and returns the given object.</p><p>Parameters</p><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>id</td><tdclass=CDLDescription>ID for the object to be associated with.</td></tr><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be associated with the ID.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.getObject"></a>getObject</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getObject = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the decoded object for the element with the specified ID in <ahref="#mxCodec.document"class=LVariableid=link29onMouseOver="ShowTip(event, 'tt2', 'link29')"onMouseOut="HideTip('tt2')">document</a>. If the object is not known then <ahref="#mxCodec.lookup"class=LFunctionid=link30onMouseOver="ShowTip(event, 'tt8', 'link30')"onMouseOut="HideTip('tt8')">lookup</a> is used to find an object. If no object is found, then the element with the respective ID from the document is parsed using <ahref="#mxCodec.decode"class=LFunctionid=link31onMouseOver="ShowTip(event, 'tt14', 'link31')"onMouseOut="HideTip('tt14')">decode</a>.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.lookup"></a>lookup</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.lookup = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to implement a custom lookup mechanism for cell IDs. This implementation always returns null.</p><h4class=CHeading>Example</h4><blockquote><preclass="prettyprint">var codec = new mxCodec();
codec.lookup = function(id)
{
return model.getCell(id);
};</pre></blockquote><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>id</td><tdclass=CDLDescription>ID of the object to be returned.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.getElementById"></a>getElementById</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getElementById = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the element with the given ID from <ahref="#mxCodec.document"class=LVariableid=link32onMouseOver="ShowTip(event, 'tt2', 'link32')"onMouseOut="HideTip('tt2')">document</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>id</td><tdclass=CDLDescription>String that contains the ID.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.addElement"></a>addElement</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.addElement = function(</td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Adds the given element to <ahref="#mxCodec.elements"class=LVariableid=link33onMouseOver="ShowTip(event, 'tt4', 'link33')"onMouseOut="HideTip('tt4')">elements</a> if it has an ID.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.getId"></a>getId</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getId = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the ID of the specified object. This implementation calls <ahref="#mxCodec.reference"class=LFunctionid=link34onMouseOver="ShowTip(event, 'tt12', 'link34')"onMouseOut="HideTip('tt12')">reference</a> first and if that returns null handles the object as an <ahref="../model/mxCell-js.html#mxCell"class=LClassid=link35onMouseOver="ShowTip(event, 'tt26', 'link35')"onMouseOut="HideTip('tt26')">mxCell</a> by returning their IDs using <ahref="../model/mxCell-js.html#mxCell.getId"class=LFunctionid=link36onMouseOver="ShowTip(event, 'tt27', 'link36')"onMouseOut="HideTip('tt27')">mxCell.getId</a>. If no ID exists for the given cell, then an on-the-fly ID is generated using <ahref="../model/mxCellPath-js.html#mxCellPath.create"class=LFunctionid=link37onMouseOver="ShowTip(event, 'tt28', 'link37')"onMouseOut="HideTip('tt28')">mxCellPath.create</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to return the ID for.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.reference"></a>reference</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.reference = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to implement a custom method for retrieving IDs from objects. This implementation always returns null.</p><h4class=CHeading>Example</h4><blockquote><preclass="prettyprint">var codec = new mxCodec();
codec.reference = function(obj)
{
return obj.getCustomId();
};</pre></blockquote><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object whose ID should be returned.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.encode"></a>encode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.encode = function(</td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Encodes the specified object and returns the resulting XML node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>obj</td><tdclass=CDLDescription>Object to be encoded.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.decode"></a>decode</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.decode = function(</td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>into</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Decodes the given XML node. The optional “into” argument specifies an existing object to be used. If no object is given, then a new instance is created using the constructor from the codec.</p><p>The function returns the passed in object or the new instance if no object was given.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to be decoded.</td></tr><tr><tdclass=CDLEntry>into</td><tdclass=CDLDescription>Optional object to be decodec into.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.encodeCell"></a>encodeCell</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.encodeCell = function(</td><tdclass=PParameternowrap>cell,</td></tr><tr><td></td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>includeChildren</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>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. <ahref="mxModelCodec-js.html#mxModelCodec"class=LClassid=link38onMouseOver="ShowTip(event, 'tt29', 'link38')"onMouseOut="HideTip('tt29')">mxModelCodec</a>, <ahref="mxChildChangeCodec-js.html#mxChildChangeCodec"class=LClassid=link39onMouseOver="ShowTip(event, 'tt30', 'link39')"onMouseOut="HideTip('tt30')">mxChildChangeCodec</a> and <ahref="mxRootChangeCodec-js.html#mxRootChangeCodec"class=LClassid=link40onMouseOver="ShowTip(event, 'tt31', 'link40')"onMouseOut="HideTip('tt31')">mxRootChangeCodec</a>). 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.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>cell</td><tdclass=CDLDescription><ahref="../model/mxCell-js.html#mxCell"class=LClassid=link41onMouseOver="ShowTip(event, 'tt26', 'link41')"onMouseOut="HideTip('tt26')">mxCell</a> to be encoded.</td></tr><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>Parent XML node to add the encoded cell into.</td></tr><tr><tdclass=CDLEntry>includeChildren</td><tdclass=CDLDescription>Optional boolean indicating if the function should include all descendents. Default is true.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.isCellCodec"></a>isCellCodec</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.isCellCodec = function(</td><tdclass=PParameternowrap>codec</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given codec is a cell codec. This uses <ahref="mxCellCodec-js.html#mxCellCodec.isCellCodec"class=LFunctionid=link42onMouseOver="ShowTip(event, 'tt32', 'link42')"onMouseOut="HideTip('tt32')">mxCellCodec.isCellCodec</a> to check if the codec is of the given type.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.decodeCell"></a>decodeCell</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.decodeCell = function(</td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>restoreStructures</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Decodes cells that have been encoded using inversion, ie. where the user object is the enclosing node in the XML, and restores the group and graph structure in the cells. Returns a new <ahref="../model/mxCell-js.html#mxCell"class=LClassid=link43onMouseOver="ShowTip(event, 'tt26', 'link43')"onMouseOut="HideTip('tt26')">mxCell</a> instance that represents the given node.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node that contains the cell data.</td></tr><tr><tdclass=CDLEntry>restoreStructures</td><tdclass=CDLDescription>Optional boolean indicating whether the graph structure should be restored by calling insert and insertEdge on the parent and terminals, respectively. Default is true.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.insertIntoGraph"></a>insertIntoGraph</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.insertIntoGraph = function(</td><tdclass=PParameternowrap>cell</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Inserts the given cell into its parent and terminal cells.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxCodec.setAttribute"></a>setAttribute</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.setAttribute = function(</td><tdclass=PParameternowrap>node,</td></tr><tr><td></td><tdclass=PParameternowrap>attribute,</td></tr><tr><td></td><tdclass=PParameternowrap>value</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the attribute on the specified node to value. This is a helper method that makes sure the attribute and value arguments are not null.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>node</td><tdclass=CDLDescription>XML node to set the attribute for.</td></tr><tr><tdclass=CDLEntry>attributes</td><tdclass=CDLDescription>Attributename to be set.</td></tr><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>New value of the attribute.</td></tr></table></div></div></div>
</div><!--Content-->
<divid=Footer><ahref="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<divclass=CToolTipid="tt1"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>function mxCodec(</td><tdclass=PParameternowrap>document</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Constructs an XML encoder/decoder for the specified owner document.</div></div><divclass=CToolTipid="tt2"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.document</td></tr></table></blockquote>The owner document of the codec.</div></div><divclass=CToolTipid="tt3"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.objects</td></tr></table></blockquote>Maps from IDs to objects.</div></div><divclass=CToolTipid="tt4"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.elements</td></tr></table></blockquote>Lookup table for resolving IDs to elements.</div></div><divclass=CToolTipid="tt5"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td>mxCodec.prototype.encodeDefaults</td></tr></table></blockquote>Specifies if default values should be encoded. </div></div><divclass=CToolTipid="tt6"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.putObject = function(</td><tdclass=PParameternowrap>id,</td></tr><tr><td></td><tdclass=PParameternowrap>obj</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Assoiates the given object with the given ID and returns the given object.</div></div><divclass=CToolTipid="tt7"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getObject = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the decoded object for the element with the specified ID in document. </div></div><divclass=CToolTipid="tt8"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.lookup = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to implement a custom lookup mechanism for cell IDs. </div></div><divclass=CToolTipid="tt9"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.getElementById = function(</td><tdclass=PParameternowrap>id</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the element with the given ID from document.</div></div><divclass=CToolTipid="tt10"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.prototype.addElement = function(</td><tdclass=PParameternowrap>node</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Adds the given element to elements if it has an ID.</div></div><divclass=CToolTipid="tt11"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>mxCodec.pr