maxGraph/docs/js-api/files/io/mxCodec-js.html

115 lines
57 KiB
HTML
Raw Normal View History

2012-05-21 20:32:26 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>mxCodec</title><link rel="stylesheet" type="text/css" href="../../styles/main.css"><script language=JavaScript src="../../javascript/main.js"></script><script language=JavaScript src="../../javascript/prettify.js"></script><script language=JavaScript src="../../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>
<!-- Generated by Natural Docs, version 1.5 -->
<!-- http://www.naturaldocs.org -->
<!-- saved from url=(0026)http://www.naturaldocs.org -->
<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="mxCodec"></a>mxCodec</h1><div class=CBody><p>XML codec for JavaScript object graphs.&nbsp; See <a href="mxObjectCodec-js.html#mxObjectCodec" class=LClass id=link20 onMouseOver="ShowTip(event, 'tt18', 'link20')" onMouseOut="HideTip('tt18')">mxObjectCodec</a> for a description of the general encoding/decoding scheme.&nbsp; This class uses the codecs registered in <a href="mxCodecRegistry-js.html#mxCodecRegistry" class=LClass id=link21 onMouseOver="ShowTip(event, 'tt19', 'link21')" onMouseOut="HideTip('tt19')">mxCodecRegistry</a> for encoding/decoding each object.</p><h4 class=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><h4 class=CHeading>Examples</h4><p>The following code is used to encode a graph model.</p><blockquote><pre class="prettyprint">var encoder = new mxCodec();
var result = encoder.encode(graph.getModel());
2013-12-09 08:35:20 +00:00
var xml = mxUtils.getXml(result);</pre></blockquote><h4 class=CHeading>Example</h4><p>Using the code below, an XML document is decoded into an existing model.&nbsp; The document may be obtained using one of the functions in mxUtils for loading an XML file, eg.&nbsp; <a href="../util/mxUtils-js.html#mxUtils.get" class=LFunction id=link22 onMouseOver="ShowTip(event, 'tt20', 'link22')" onMouseOut="HideTip('tt20')">mxUtils.get</a>, or using <a href="../util/mxUtils-js.html#mxUtils.parseXml" class=LFunction id=link23 onMouseOver="ShowTip(event, 'tt21', 'link23')" onMouseOut="HideTip('tt21')">mxUtils.parseXml</a> for parsing an XML string.</p><blockquote><pre class="prettyprint">var doc = mxUtils.parseXml(xmlString);
var codec = new mxCodec(doc);
decoder.decode(doc.documentElement, graph.getModel());</pre></blockquote><h4 class=CHeading>Example</h4><p>This example demonstrates parsing a list of isolated cells into an existing graph model.&nbsp; Note that the cells do not have a parent reference so they can be added anywhere in the cell hierarchy after parsing.</p><blockquote><pre class="prettyprint">var xml = '&lt;root&gt;&lt;mxCell id=&quot;2&quot; value=&quot;Hello,&quot; vertex=&quot;1&quot;&gt;&lt;mxGeometry x=&quot;20&quot; y=&quot;20&quot; width=&quot;80&quot; height=&quot;30&quot; as=&quot;geometry&quot;/&gt;&lt;/mxCell&gt;&lt;mxCell id=&quot;3&quot; value=&quot;World!&quot; vertex=&quot;1&quot;&gt;&lt;mxGeometry x=&quot;200&quot; y=&quot;150&quot; width=&quot;80&quot; height=&quot;30&quot; as=&quot;geometry&quot;/&gt;&lt;/mxCell&gt;&lt;mxCell id=&quot;4&quot; value=&quot;&quot; edge=&quot;1&quot; source=&quot;2&quot; target=&quot;3&quot;&gt;&lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;/&gt;&lt;/mxCell&gt;&lt;/root&gt;';
var doc = mxUtils.parseXml(xml);
var codec = new mxCodec(doc);
var elt = doc.documentElement.firstChild;
var cells = [];
while (elt != null)
{
cells.push(codec.decode(elt));
elt = elt.nextSibling;
}
graph.addCells(cells);</pre></blockquote><h4 class=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><pre class="prettyprint">var enc = new mxCodec();
2012-05-21 20:32:26 +00:00
var cells = graph.getSelectionCells();
2013-12-09 08:35:20 +00:00
mxUtils.alert(mxUtils.getPrettyXml(enc.encode(cells)));</pre></blockquote><p>Newlines in the XML can be converted to &lt;br&gt;, in which case a &lsquo;&lt;br&gt;&rsquo; argument must be passed to <a href="../util/mxUtils-js.html#mxUtils.getXml" class=LFunction id=link24 onMouseOver="ShowTip(event, 'tt22', 'link24')" onMouseOut="HideTip('tt22')">mxUtils.getXml</a> as the second argument.</p><h4 class=CHeading>Debugging</h4><p>For debugging I/O you can use the following code to get the sequence of encoded objects:</p><blockquote><pre class="prettyprint">var oldEncode = mxCodec.prototype.encode;
2012-05-21 20:32:26 +00:00
mxCodec.prototype.encode = function(obj)
{
mxLog.show();
mxLog.debug('mxCodec.encode: obj='+mxUtils.getFunctionName(obj.constructor));
return oldEncode.apply(this, arguments);
2013-08-21 09:32:40 +00:00
};</pre></blockquote><p>Note that the I/O system adds object codecs for new object automatically.&nbsp; For decoding those objects, the constructor should be written as follows:</p><blockquote><pre class="prettyprint">var MyObj = function(name)
{
// ...
2012-05-21 20:32:26 +00:00
};</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#mxCodec" >mxCodec</a></td><td class=SDescription>XML codec for JavaScript object graphs. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#mxCodec.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.mxCodec" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">mxCodec</a></td><td class=SDescription>Constructs an XML encoder/decoder for the specified owner document.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#mxCodec.Variables" >Variables</a></td><td class=SDescription></td></tr><tr class="SVariable SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.document" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">document</a></td><td class=SDescription>The owner document of the codec.</td></tr><tr class="SVariable SIndent2"><td class=SEntry><a href="#mxCodec.objects" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">objects</a></td><td class=SDescription>Maps from IDs to objects.</td></tr><tr class="SVariable SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.encodeDefaults" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">encodeDefaults</a></td><td class=SDescription>Specifies if default values should be encoded. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#mxCodec.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.putObject" id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">putObject</a></td><td class=SDescription>Assoiates the given object with the given ID and returns the given object.</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#mxCodec.getObject" id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">getObject</a></td><td class=SDescription>Returns the decoded object for the element with the specified ID in <a href="#mxCodec.document" class=LVariable id=link7 onMouseOver="ShowTip(event, 'tt2', 'link7')" onMouseOut="HideTip('tt2')">document</a>. </td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.lookup" id=link8 onMouseOver="ShowTip(event, 'tt7', 'link8')" onMouseOut="HideTip('tt7')">lookup</a></td><td class=SDescription>Hook for subclassers to implement a custom lookup mechanism for cell IDs. </td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#mxCodec.getElementById" id=link9 onMouseOver="ShowTip(event, 'tt8', 'link9')" onMouseOut="HideTip('tt8')">getElementById</a></td><td class=SDescription>Returns the element with the given ID from <a href="#mxCodec.document" class=LVariable id=link10 onMouseOver="ShowTip(event, 'tt2', 'link10')" onMouseOut="HideTip('tt2')">document</a>. </td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.getId" id=link11 onMouseOver="ShowTip(event, 'tt9', 'link11')" onMouseOut="HideTip('tt9')">getId</a></td><td class=SDescription>Returns the ID of the specified object. </td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#mxCodec.reference" id=link12 onMouseOver="ShowTip(event, 'tt10', 'link12')" onMouseOut="HideTip('tt10')">reference</a></td><td class=SDescription>Hook for subclassers to implement a custom method for retrieving IDs from objects. </td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodec.encode" id=link13 onMouseOver="ShowTip(event, 'tt11', 'link13')" onMouseOut="HideTip('tt11')">encode</a></td><td class=SDescription>Encodes the specified object and returns the resulting XML node.</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#mxCodec.decode" id=link14 onMouseOver="ShowTip(event, 'tt12', 'link14')" onMouse
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="mxCodec.Functions"></a>Functions</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.mxCodec"></a>mxCodec</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function mxCodec(</td><td class=PParameter nowrap>document</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Constructs an XML encoder/decoder for the specified owner document.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>document</td><td class=CDLDescription>Optional XML document that contains the data.&nbsp; If no document is specified then a new document is created using <a href="../util/mxUtils-js.html#mxUtils.createXmlDocument" class=LFunction id=link25 onMouseOver="ShowTip(event, 'tt23', 'link25')" onMouseOut="HideTip('tt23')">mxUtils.createXmlDocument</a>.</td></tr></table></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="mxCodec.Variables"></a>Variables</h3></div></div>
<div class="CVariable"><div class=CTopic><h3 class=CTitle><a name="mxCodec.document"></a>document</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td>mxCodec.prototype.document</td></tr></table></blockquote><p>The owner document of the codec.</p></div></div></div>
<div class="CVariable"><div class=CTopic><h3 class=CTitle><a name="mxCodec.objects"></a>objects</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td>mxCodec.prototype.objects</td></tr></table></blockquote><p>Maps from IDs to objects.</p></div></div></div>
<div class="CVariable"><div class=CTopic><h3 class=CTitle><a name="mxCodec.encodeDefaults"></a>encodeDefaults</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td>mxCodec.prototype.encodeDefaults</td></tr></table></blockquote><p>Specifies if default values should be encoded.&nbsp; Default is false.</p></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="mxCodec.Functions"></a>Functions</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.putObject"></a>putObject</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.putObject = function(</td><td class=PParameter nowrap>id,</td></tr><tr><td></td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</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><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>id</td><td class=CDLDescription>ID for the object to be associated with.</td></tr><tr><td class=CDLEntry>obj</td><td class=CDLDescription>Object to be associated with the ID.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.getObject"></a>getObject</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.getObject = function(</td><td class=PParameter nowrap>id</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the decoded object for the element with the specified ID in <a href="#mxCodec.document" class=LVariable id=link26 onMouseOver="ShowTip(event, 'tt2', 'link26')" onMouseOut="HideTip('tt2')">document</a>.&nbsp; If the object is not known then <a href="#mxCodec.lookup" class=LFunction id=link27 onMouseOver="ShowTip(event, 'tt7', 'link27')" onMouseOut="HideTip('tt7')">lookup</a> is used to find an object.&nbsp; If no object is found, then the element with the respective ID from the document is parsed using <a href="#mxCodec.decode" class=LFunction id=link28 onMouseOver="ShowTip(event, 'tt12', 'link28')" onMouseOut="HideTip('tt12')">decode</a>.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.lookup"></a>lookup</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.lookup = function(</td><td class=PParameter nowrap>id</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to implement a custom lookup mechanism for cell IDs.&nbsp; This implementation always returns null.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">var codec = new mxCodec();
codec.lookup = function(id)
{
return model.getCell(id);
};</pre></blockquote><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>id</td><td class=CDLDescription>ID of the object to be returned.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.getElementById"></a>getElementById</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.getElementById = function(</td><td class=PParameter nowrap>id,</td></tr><tr><td></td><td class=PParameter nowrap>attr</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the element with the given ID from <a href="#mxCodec.document" class=LVariable id=link29 onMouseOver="ShowTip(event, 'tt2', 'link29')" onMouseOut="HideTip('tt2')">document</a>.&nbsp; The optional attr argument specifies the name of the ID attribute.&nbsp; Default is &ldquo;id&rdquo;.&nbsp; The XPath expression used to find the element is //*[@attr=&rsquo;arg&rsquo;] where attr is the name of the ID attribute and arg is the given id.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>id</td><td class=CDLDescription>String that contains the ID.</td></tr><tr><td class=CDLEntry>attr</td><td class=CDLDescription>Optional string for the attributename.&nbsp; Default is &ldquo;id&rdquo;.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.getId"></a>getId</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.getId = function(</td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the ID of the specified object.&nbsp; This implementation calls <a href="#mxCodec.reference" class=LFunction id=link30 onMouseOver="ShowTip(event, 'tt10', 'link30')" onMouseOut="HideTip('tt10')">reference</a> first and if that returns null handles the object as an <a href="../model/mxCell-js.html#mxCell" class=LClass id=link31 onMouseOver="ShowTip(event, 'tt24', 'link31')" onMouseOut="HideTip('tt24')">mxCell</a> by returning their IDs using <a href="../model/mxCell-js.html#mxCell.getId" class=LFunction id=link32 onMouseOver="ShowTip(event, 'tt25', 'link32')" onMouseOut="HideTip('tt25')">mxCell.getId</a>.&nbsp; If no ID exists for the given cell, then an on-the-fly ID is generated using <a href="../model/mxCellPath-js.html#mxCellPath.create" class=LFunction id=link33 onMouseOver="ShowTip(event, 'tt26', 'link33')" onMouseOut="HideTip('tt26')">mxCellPath.create</a>.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>obj</td><td class=CDLDescription>Object to return the ID for.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.reference"></a>reference</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.reference = function(</td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to implement a custom method for retrieving IDs from objects.&nbsp; This implementation always returns null.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">var codec = new mxCodec();
codec.reference = function(obj)
{
return obj.getCustomId();
};</pre></blockquote><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>obj</td><td class=CDLDescription>Object whose ID should be returned.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.encode"></a>encode</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.encode = function(</td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Encodes the specified object and returns the resulting XML node.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>obj</td><td class=CDLDescription>Object to be encoded.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.decode"></a>decode</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.decode = function(</td><td class=PParameter nowrap>node,</td></tr><tr><td></td><td class=PParameter nowrap>into</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Decodes the given XML node.&nbsp; The optional &ldquo;into&rdquo; argument specifies an existing object to be used.&nbsp; 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><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>node</td><td class=CDLDescription>XML node to be decoded.</td></tr><tr><td class=CDLEntry>into</td><td class=CDLDescription>Optional object to be decodec into.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.encodeCell"></a>encodeCell</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.encodeCell = function(</td><td class=PParameter nowrap>cell,</td></tr><tr><td></td><td class=PParameter nowrap>node,</td></tr><tr><td></td><td class=PParameter nowrap>includeChildren</td><td class=PAfterParameters nowrap>)</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.&nbsp; <a href="mxModelCodec-js.html#mxModelCodec" class=LClass id=link34 onMouseOver="ShowTip(event, 'tt27', 'link34')" onMouseOut="HideTip('tt27')">mxModelCodec</a>, <a href="mxChildChangeCodec-js.html#mxChildChangeCodec" class=LClass id=link35 onMouseOver="ShowTip(event, 'tt28', 'link35')" onMouseOut="HideTip('tt28')">mxChildChangeCodec</a> and <a href="mxRootChangeCodec-js.html#mxRootChangeCodec" class=LClass id=link36 onMouseOver="ShowTip(event, 'tt29', 'link36')" onMouseOut="HideTip('tt29')">mxRootChangeCodec</a>).&nbsp; This implementation writes the given cell and its children as a (flat) sequence into the given node.&nbsp; The children are not encoded if the optional includeChildren is false.&nbsp; The function is in charge of adding the result into the given node and has no return value.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>cell</td><td class=CDLDescription><a href="../model/mxCell-js.html#mxCell" class=LClass id=link37 onMouseOver="ShowTip(event, 'tt24', 'link37')" onMouseOut="HideTip('tt24')">mxCell</a> to be encoded.</td></tr><tr><td class=CDLEntry>node</td><td class=CDLDescription>Parent XML node to add the encoded cell into.</td></tr><tr><td class=CDLEntry>includeChildren</td><td class=CDLDescription>Optional boolean indicating if the function should include all descendents.&nbsp; Default is true.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.isCellCodec"></a>isCellCodec</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.isCellCodec = function(</td><td class=PParameter nowrap>codec</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns true if the given codec is a cell codec.&nbsp; This uses <a href="mxCellCodec-js.html#mxCellCodec.isCellCodec" class=LFunction id=link38 onMouseOver="ShowTip(event, 'tt30', 'link38')" onMouseOut="HideTip('tt30')">mxCellCodec.isCellCodec</a> to check if the codec is of the given type.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.decodeCell"></a>decodeCell</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.decodeCell = function(</td><td class=PParameter nowrap>node,</td></tr><tr><td></td><td class=PParameter nowrap>restoreStructures</td><td class=PAfterParameters nowrap>)</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.&nbsp; Returns a new <a href="../model/mxCell-js.html#mxCell" class=LClass id=link39 onMouseOver="ShowTip(event, 'tt24', 'link39')" onMouseOut="HideTip('tt24')">mxCell</a> instance that represents the given node.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>node</td><td class=CDLDescription>XML node that contains the cell data.</td></tr><tr><td class=CDLEntry>restoreStructures</td><td class=CDLDescription>Optional boolean indicating whether the graph structure should be restored by calling insert and insertEdge on the parent and terminals, respectively.&nbsp; Default is true.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.insertIntoGraph"></a>insertIntoGraph</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.insertIntoGraph = function(</td><td class=PParameter nowrap>cell</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Inserts the given cell into its parent and terminal cells.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodec.setAttribute"></a>setAttribute</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.setAttribute = function(</td><td class=PParameter nowrap>node,</td></tr><tr><td></td><td class=PParameter nowrap>attribute,</td></tr><tr><td></td><td class=PParameter nowrap>value</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the attribute on the specified node to value.&nbsp; This is a helper method that makes sure the attribute and value arguments are not null.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>node</td><td class=CDLDescription>XML node to set the attribute for.</td></tr><tr><td class=CDLEntry>attributes</td><td class=CDLDescription>Attributename to be set.</td></tr><tr><td class=CDLEntry>value</td><td class=CDLDescription>New value of the attribute.</td></tr></table></div></div></div>
</div><!--Content-->
<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
2014-11-10 09:02:21 +00:00
<div id=Menu><div class=MEntry><div class=MFile><a href="../index-txt.html">API Specification</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Editor</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile><a href="../editor/mxDefaultKeyHandler-js.html">mxDefaultKeyHandler</a></div></div><div class=MEntry><div class=MFile><a href="../editor/mxDefaultPopupMenu-js.html">mxDefaultPopupMenu</a></div></div><div class=MEntry><div class=MFile><a href="../editor/mxDefaultToolbar-js.html">mxDefaultToolbar</a></div></div><div class=MEntry><div class=MFile><a href="../editor/mxEditor-js.html">mxEditor</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Handler</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MFile><a href="../handler/mxCellHighlight-js.html">mxCellHighlight</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxCellMarker-js.html">mxCellMarker</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxCellTracker-js.html">mxCellTracker</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxConnectionHandler-js.html">mxConnectionHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxConstraintHandler-js.html">mxConstraintHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxEdgeHandler-js.html">mxEdgeHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxEdgeSegmentHandler-js.html">mxEdgeSegmentHandler.js</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxElbowEdgeHandler-js.html">mxElbowEdgeHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxGraphHandler-js.html">mxGraphHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxKeyHandler-js.html">mxKeyHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxPanningHandler-js.html">mxPanningHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxPopupMenuHandler-js.html">mxPopupMenuHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxRubberband-js.html">mxRubberband</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxSelectionCellsHandler-js.html">mxSelectionCellsHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxTooltipHandler-js.html">mxTooltipHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxVertexHandler-js.html">mxVertexHandler</a></div></div><div class=MEntry><div class=MFile><a href="../handler/mxHandle-js.html">mxVertexHandler</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent3')">Io</a><div class=MGroupContent id=MGroupContent3><div class=MEntry><div class=MFile><a href="mxCellCodec-js.html">mxCellCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxChildChangeCodec-js.html">mxChildChangeCodec</a></div></div><div class=MEntry><div class=MFile id=MSelected>mxCodec</div></div><div class=MEntry><div class=MFile><a href="mxCodecRegistry-js.html">mxCodecRegistry</a></div></div><div class=MEntry><div class=MFile><a href="mxDefaultKeyHandlerCodec-js.html">mxDefaultKeyHandlerCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxDefaultPopupMenuCodec-js.html">mxDefaultPopupMenuCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxDefaultToolbarCodec-js.html">mxDefaultToolbarCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxEditorCodec-js.html">mxEditorCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxGenericChangeCodec-js.html">mxGenericChangeCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxGraphCodec-js.html">mxGraphCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxGraphViewCodec-js.html">mxGraphViewCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxModelCodec-js.html">mx
2012-05-21 20:32:26 +00:00
var searchPanel = new SearchPanel("searchPanel", "HTML", "../../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option id=MSearchEverything selected value="General">Everything</option><option value="Classes">Classes</option><option value="Cookies">Cookies</option><option value="Events">Events</option><option value="Files">Files</option><option value="Functions">Functions</option><option value="Variables">Variables</option></select></div><script language=JavaScript><!--
HideAllBut([3], 13);// --></script></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
2013-12-09 08:35:20 +00:00
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function mxCodec(</td><td class=PParameter nowrap>document</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Constructs an XML encoder/decoder for the specified owner document.</div></div><div class=CToolTip id="tt2"><div class=CVariable><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td>mxCodec.prototype.document</td></tr></table></blockquote>The owner document of the codec.</div></div><div class=CToolTip id="tt3"><div class=CVariable><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td>mxCodec.prototype.objects</td></tr></table></blockquote>Maps from IDs to objects.</div></div><div class=CToolTip id="tt4"><div class=CVariable><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td>mxCodec.prototype.encodeDefaults</td></tr></table></blockquote>Specifies if default values should be encoded. </div></div><div class=CToolTip id="tt5"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.putObject = function(</td><td class=PParameter nowrap>id,</td></tr><tr><td></td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Assoiates the given object with the given ID and returns the given object.</div></div><div class=CToolTip id="tt6"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.getObject = function(</td><td class=PParameter nowrap>id</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns the decoded object for the element with the specified ID in document. </div></div><div class=CToolTip id="tt7"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.lookup = function(</td><td class=PParameter nowrap>id</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to implement a custom lookup mechanism for cell IDs. </div></div><div class=CToolTip id="tt8"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.getElementById = function(</td><td class=PParameter nowrap>id,</td></tr><tr><td></td><td class=PParameter nowrap>attr</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns the element with the given ID from document. </div></div><div class=CToolTip id="tt9"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.getId = function(</td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns the ID of the specified object. </div></div><div class=CToolTip id="tt10"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>mxCodec.prototype.reference = function(</td><td class=PParameter nowrap>obj</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to implement a custom method for retrievin
2012-05-21 20:32:26 +00:00
<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>
<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>