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

54 lines
28 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>mxCodecRegistry</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="mxCodecRegistry"></a>mxCodecRegistry</h1><div class=CBody><p>Singleton class that acts as a global registry for codecs.</p><h4 class=CHeading>Adding an <a href="mxCodec-js.html#mxCodec" class=LClass id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">mxCodec</a></h4><p>1.&nbsp; Define a default codec with a new instance of the object to be handled.</p><blockquote><pre class="prettyprint">var codec = new mxObjectCodec(new mxGraphModel());</pre></blockquote><p>2.&nbsp; Define the functions required for encoding and decoding objects.</p><blockquote><pre class="prettyprint">codec.encode = function(enc, obj) { ... }
codec.decode = function(dec, node, into) { ... }</pre></blockquote><p>3.&nbsp; Register the codec in the <a href="#mxCodecRegistry" class=LClass id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">mxCodecRegistry</a>.</p><blockquote><pre class="prettyprint">mxCodecRegistry.register(codec);</pre></blockquote><p><a href="mxObjectCodec-js.html#mxObjectCodec.decode" class=LFunction id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">mxObjectCodec.decode</a> may be used to either create a new instance of an object or to configure an existing instance, in which case the into argument points to the existing object.&nbsp; In this case, we say the codec &ldquo;configures&rdquo; the object.</p><!--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="#mxCodecRegistry" >mxCodecRegistry</a></td><td class=SDescription>Singleton class that acts as a global registry for codecs.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#mxCodecRegistry.Variables" >Variables</a></td><td class=SDescription></td></tr><tr class="SVariable SIndent2 SMarked"><td class=SEntry><a href="#mxCodecRegistry.codecs" >codecs</a></td><td class=SDescription>Maps from constructor names to codecs.</td></tr><tr class="SVariable SIndent2"><td class=SEntry><a href="#mxCodecRegistry.aliases" >aliases</a></td><td class=SDescription>Maps from classnames to codecnames.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#mxCodecRegistry.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodecRegistry.register" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">register</a></td><td class=SDescription>Registers a new codec and associates the name of the template constructor in the codec with the codec object.</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#mxCodecRegistry.addAlias" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">addAlias</a></td><td class=SDescription>Adds an alias for mapping a classname to a codecname.</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#mxCodecRegistry.getCodec" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">getCodec</a></td><td class=SDescription>Returns a codec that handles objects that are constructed using the given constructor.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.Variables"></a>Variables</h3></div></div>
<div class="CVariable"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.codecs"></a>codecs</h3><div class=CBody><p>Maps from constructor names to codecs.</p></div></div></div>
<div class="CVariable"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.aliases"></a>aliases</h3><div class=CBody><p>Maps from classnames to codecnames.</p></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.Functions"></a>Functions</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.register"></a>register</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>register: function(</td><td class=PParameter nowrap>codec</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Registers a new codec and associates the name of the template constructor in the codec with the codec object.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>codec</td><td class=CDLDescription><a href="mxObjectCodec-js.html#mxObjectCodec" class=LClass id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">mxObjectCodec</a> to be registered.</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.addAlias"></a>addAlias</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>addAlias: function(</td><td class=PParameter nowrap>classname,</td></tr><tr><td></td><td class=PParameter nowrap>codecname</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Adds an alias for mapping a classname to a codecname.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="mxCodecRegistry.getCodec"></a>getCodec</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>getCodec: function(</td><td class=PParameter nowrap>ctor</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns a codec that handles objects that are constructed using the given constructor.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>ctor</td><td class=CDLDescription>JavaScript constructor function.</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-03-14 13:24:50 +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></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><a href="mxCodec-js.html">mxCodec</a></div></div><div class=MEntry><div class=MFile id=MSelected>mxCodecRegistry</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">mxModelCodec</a></div></div><div class=MEntry><div class=MFile><a href="mxObjectCodec-js.html">mxObjectCodec</a></
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-->
<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>register: function(</td><td class=PParameter nowrap>codec</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Registers a new codec and associates the name of the template constructor in the codec with the codec object.</div></div><div class=CToolTip id="tt2"><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>addAlias: function(</td><td class=PParameter nowrap>classname,</td></tr><tr><td></td><td class=PParameter nowrap>codecname</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Adds an alias for mapping a classname to a codecname.</div></div><div class=CToolTip id="tt3"><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>getCodec: function(</td><td class=PParameter nowrap>ctor</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns a codec that handles objects that are constructed using the given constructor.</div></div><div class=CToolTip id="tt4"><div class=CClass>XML codec for JavaScript object graphs. </div></div><div class=CToolTip id="tt5"><div class=CClass>Singleton class that acts as a global registry for codecs.</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>mxObjectCodec.prototype.decode = function(</td><td class=PParameter nowrap>dec,</td></tr><tr><td></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>Parses the given node into the object or returns a new object representing the given node.</div></div><div class=CToolTip id="tt7"><div class=CClass>Generic codec for JavaScript objects that implements a mapping between JavaScript objects and XML nodes that maps each field or element to an attribute or child node, and vice versa.</div></div><!--END_ND_TOOLTIPS-->
<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>