maxGraph/docs/js-api/files/index-txt.html

67 lines
50 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>API Specification</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="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="API_Specification"></a>API Specification</h1><div class=CBody><h4 class=CHeading>Overview</h4><p>This JavaScript library is divided into 8 packages.&nbsp; The top-level <a href="mxClient-js.html#mxClient" class=LClass id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">mxClient</a> class includes (or dynamically imports) everything else.&nbsp; The current version is stored in <a href="mxClient-js.html#mxClient.VERSION" class=LVariable id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">mxClient.VERSION</a>.</p><p>The <b>editor</b> package provides the classes required to implement a diagram editor.&nbsp; The main class in this package is <a href="editor/mxEditor-js.html#mxEditor" class=LClass id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">mxEditor</a>.</p><p>The <b>view</b> and <b>model</b> packages implement the graph component, represented by <a href="view/mxGraph-js.html#mxGraph" class=LClass id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">mxGraph</a>.&nbsp; It refers to a <a href="model/mxGraphModel-js.html#mxGraphModel" class=LClass id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">mxGraphModel</a> which contains <a href="model/mxCell-js.html#mxCell" class=LClass id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">mxCell</a>s and caches the state of the cells in a <a href="view/mxGraphView-js.html#mxGraphView" class=LClass id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">mxGraphView</a>.&nbsp; The cells are painted using a <a href="view/mxCellRenderer-js.html#mxCellRenderer" class=LClass id=link8 onMouseOver="ShowTip(event, 'tt8', 'link8')" onMouseOut="HideTip('tt8')">mxCellRenderer</a> based on the appearance defined in <a href="view/mxStylesheet-js.html#mxStylesheet" class=LClass id=link9 onMouseOver="ShowTip(event, 'tt9', 'link9')" onMouseOut="HideTip('tt9')">mxStylesheet</a>.&nbsp; Undo history is implemented in <a href="util/mxUndoManager-js.html#mxUndoManager" class=LClass id=link10 onMouseOver="ShowTip(event, 'tt10', 'link10')" onMouseOut="HideTip('tt10')">mxUndoManager</a>.&nbsp; To display an icon on the graph, <a href="view/mxCellOverlay-js.html#mxCellOverlay" class=LClass id=link11 onMouseOver="ShowTip(event, 'tt11', 'link11')" onMouseOut="HideTip('tt11')">mxCellOverlay</a> may be used.&nbsp; Validation rules are defined with <a href="view/mxMultiplicity-js.html#mxMultiplicity" class=LClass id=link12 onMouseOver="ShowTip(event, 'tt12', 'link12')" onMouseOut="HideTip('tt12')">mxMultiplicity</a>.</p><p>The <b>handler</b>, <b>layout</b> and <b>shape</b> packages contain event listeners, layout algorithms and shapes, respectively.&nbsp; The graph event listeners include <a href="handler/mxRubberband-js.html#mxRubberband" class=LClass id=link13 onMouseOver="ShowTip(event, 'tt13', 'link13')" onMouseOut="HideTip('tt13')">mxRubberband</a> for rubberband selection, <a href="handler/mxTooltipHandler-js.html#mxTooltipHandler" class=LClass id=link14 onMouseOver="ShowTip(event, 'tt14', 'link14')" onMouseOut="HideTip('tt14')">mxTooltipHandler</a> for tooltips and <a href="handler/mxGraphHandler-js.html#mxGraphHandler" class=LClass id=link15 onMouseOver="ShowTip(event, 'tt15', 'link15')" onMouseOut="HideTip('tt15')">mxGraphHandler</a> for basic cell modifications.&nbsp; <a href="layout/mxCompactTreeLayout-js.html#mxCompactTreeLayout" class=LClass id=link16 onMouseOver="ShowTip(event, 'tt16', 'link16')" onMouseOut="HideTip('tt16')">mxCompactTreeLayout</a> implements a tree layout algorithm, and the shape package provides various shapes, which are subclasses of <a href="shape/mxShape-js.html#mxShape" class=LClass id=link17 onMouseOver="ShowTip(event, 'tt17', 'link17')" onMouseOut="HideTip('tt17')">mxShape</a>.</p><p>The <b>util</b> package provides utility classes including <a href="util/mxClipboard-js.html#mx
image.src = url_to_image;</pre></blockquote><h4 class=CHeading>Deployment</h4><p>The client is added to the page using the following script tag inside the head of a document:</p><blockquote><pre class="prettyprint">&lt;script type=&quot;text/javascript&quot; src=&quot;js/mxClient.js&quot;&gt;&lt;/script&gt;</pre></blockquote><p>The deployment version of the mxClient.js file contains all required code in a single file.&nbsp; For deployment, the complete javascript/src directory is required.</p><h4 class=CHeading>Source Code</h4><p>If you are a source code customer and you wish to develop using the full source code, the commented source code is shipped in the javascript/devel/source.zip file.&nbsp; It contains one file for each class in mxGraph.&nbsp; To use the source code the source.zip file must be uncompressed and the mxClient.js URL in the HTML page must be changed to reference the uncompressed mxClient.js from the source.zip file.</p><h4 class=CHeading>Compression</h4><p>When using Apache2 with mod_deflate, you can use the following directive in src/js/.htaccess to speedup the loading of the JavaScript sources:</p><blockquote><pre class="prettyprint">SetOutputFilter DEFLATE</pre></blockquote><h4 class=CHeading>Classes</h4><p>There are two types of &ldquo;classes&rdquo; in mxGraph: classes and singletons (where only one instance exists).&nbsp; Singletons are mapped to global objects where the variable name equals the classname.&nbsp; For example mxConstants is an object with all the constants defined as object fields.&nbsp; Normal classes are mapped to a constructor function and a prototype which defines the instance fields and methods.&nbsp; For example, <a href="editor/mxEditor-js.html#mxEditor" class=LClass id=link59 onMouseOver="ShowTip(event, 'tt3', 'link59')" onMouseOut="HideTip('tt3')">mxEditor</a> is a function and mxEditor.prototype is the prototype for the object that the mxEditor function creates.&nbsp; The mx prefix is a convention that is used for all classes in the mxGraph package to avoid conflicts with other objects in the global namespace.</p><h4 class=CHeading>Subclassing</h4><p>For subclassing, the superclass must provide a constructor that is either parameterless or handles an invocation with no arguments.&nbsp; Furthermore, the special constructor field must be redefined after extending the prototype.&nbsp; For example, the superclass of mxEditor is <a href="util/mxEventSource-js.html#mxEventSource" class=LClass id=link60 onMouseOver="ShowTip(event, 'tt28', 'link60')" onMouseOut="HideTip('tt28')">mxEventSource</a>.&nbsp; This is represented in JavaScript by first &ldquo;inheriting&rdquo; all fields and methods from the superclass by assigning the prototype to an instance of the superclass, eg. mxEditor.prototype = new mxEventSource() and redefining the constructor field using mxEditor.prototype.constructor = mxEditor.&nbsp; The latter rule is applied so that the type of an object can be retrieved via the name of it<69>s constructor using mxUtils.getFunctionName(obj.constructor).</p><h4 class=CHeading>Constructor</h4><p>For subclassing in mxGraph, the same scheme should be applied.&nbsp; For example, for subclassing the <a href="view/mxGraph-js.html#mxGraph" class=LClass id=link61 onMouseOver="ShowTip(event, 'tt4', 'link61')" onMouseOut="HideTip('tt4')">mxGraph</a> class, first a constructor must be defined for the new class.&nbsp; The constructor calls the super constructor with any arguments that it may have using the call function on the mxGraph function object, passing along explitely each argument:</p><blockquote><pre class="prettyprint">function MyGraph(container)
{
mxGraph.call(this, container);
}</pre></blockquote><p>The prototype of MyGraph inherits from mxGraph as follows.&nbsp; As usual, the constructor is redefined after extending the superclass:</p><blockquote><pre class="prettyprint">MyGraph.prototype = new mxGraph();
MyGraph.prototype.constructor = MyGraph;</pre></blockquote><p>You may want to define the codec associated for the class after the above code.&nbsp; This code will be executed at class loading time and makes sure the same codec is used to encode instances of mxGraph and MyGraph.</p><blockquote><pre class="prettyprint">var codec = mxCodecRegistry.getCodec(mxGraph);
codec.template = new MyGraph();
mxCodecRegistry.register(codec);</pre></blockquote><h4 class=CHeading>Functions</h4><p>In the prototype for MyGraph, functions of mxGraph can then be extended as follows.</p><blockquote><pre class="prettyprint">MyGraph.prototype.isCellSelectable = function(cell)
{
var selectable = mxGraph.prototype.isSelectable.apply(this, arguments);
var geo = this.model.getGeometry(cell);
return selectable &amp;&amp; (geo == null || !geo.relative);
}</pre></blockquote><p>The supercall in the first line is optional.&nbsp; It is done using the apply function on the isSelectable function object of the mxGraph prototype, using the special this and arguments variables as parameters.&nbsp; Calls to the superclass function are only possible if the function is not replaced in the superclass as follows, which is another way of <20>subclassing<6E> in JavaScript.</p><blockquote><pre class="prettyprint">mxGraph.prototype.isCellSelectable = function(cell)
{
var geo = this.model.getGeometry(cell);
return selectable &amp;&amp;
(geo == null ||
!geo.relative);
}</pre></blockquote><p>The above scheme is useful if a function definition needs to be replaced completely.</p><p>In order to add new functions and fields to the subclass, the following code is used.&nbsp; The example below adds a new function to return the XML representation of the graph model:</p><blockquote><pre class="prettyprint">MyGraph.prototype.getXml = function()
{
var enc = new mxCodec();
return enc.encode(this.getModel());
}</pre></blockquote><h4 class=CHeading>Variables</h4><p>Likewise, a new field is declared and defined as follows.</p><blockquote><pre class="prettyprint">MyGraph.prototype.myField = 'Hello, World!';</pre></blockquote><p>Note that the value assigned to myField is created only once, that is, all instances of MyGraph share the same value.&nbsp; If you require instance-specific values, then the field must be defined in the constructor instead.</p><blockquote><pre class="prettyprint">function MyGraph(container)
{
mxGraph.call(this, container);
this.myField = new Array();
}</pre></blockquote><p>Finally, a new instance of MyGraph is created using the following code, where container is a DOM node that acts as a container for the graph view:</p><blockquote><pre class="prettyprint">var graph = new MyGraph(container);</pre></blockquote></div></div></div>
</div><!--Content-->
<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
2013-12-20 16:51:26 +00:00
<div id=Menu><div class=MEntry><div class=MFile id=MSelected>API Specification</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/mxPopupMenuHandler-js.html">mxPanningHandler</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/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="io/mxCellCodec-js.html">mxCellCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxChildChangeCodec-js.html">mxChildChangeCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxCodec-js.html">mxCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxCodecRegistry-js.html">mxCodecRegistry</a></div></div><div class=MEntry><div class=MFile><a href="io/mxDefaultKeyHandlerCodec-js.html">mxDefaultKeyHandlerCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxDefaultPopupMenuCodec-js.html">mxDefaultPopupMenuCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxDefaultToolbarCodec-js.html">mxDefaultToolbarCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxEditorCodec-js.html">mxEditorCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxGenericChangeCodec-js.html">mxGenericChangeCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxGraphCodec-js.html">mxGraphCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxGraphViewCodec-js.html">mxGraphViewCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxModelCodec-js.html">mxModelCodec</a></div></div><div class=MEntry><div class=MFile><a href="io/mxObjectCodec-js.html">mxObjectCodec</a></div></div><div cl
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([1], 13);// --></script></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CClass>Bootstrapping mechanism for the mxGraph thin client. </div></div><div class=CToolTip id="tt2"><div class=CVariable>Contains the current version of the mxGraph library. </div></div><div class=CToolTip id="tt3"><div class=CClass>Extends mxEventSource to implement a application wrapper for a graph that adds actions, I/O using mxCodec, auto-layout using mxLayoutManager, command history using undoManager, and standard dialogs and widgets, eg. </div></div><div class=CToolTip id="tt4"><div class=CClass>Extends mxEventSource to implement a graph component for the browser. </div></div><div class=CToolTip id="tt5"><div class=CClass>Extends mxEventSource to implement a graph model. </div></div><div class=CToolTip id="tt6"><div class=CClass>Cells are the elements of the graph model. </div></div><div class=CToolTip id="tt7"><div class=CClass>Extends mxEventSource to implement a view for a graph. </div></div><div class=CToolTip id="tt8"><div class=CClass>Renders cells into a document object model. </div></div><div class=CToolTip id="tt9"><div class=CClass>Defines the appearance of the cells in a graph. </div></div><div class=CToolTip id="tt10"><div class=CClass>Implements a command history. </div></div><div class=CToolTip id="tt11"><div class=CClass>Extends mxEventSource to implement a graph overlay, represented by an icon and a tooltip. </div></div><div class=CToolTip id="tt12"><div class=CClass>Defines invalid connections along with the error messages that they produce. </div></div><div class=CToolTip id="tt13"><div class=CClass>Event handler that selects rectangular regions. </div></div><div class=CToolTip id="tt14"><div class=CClass>Graph event handler that displays tooltips. </div></div><div class=CToolTip id="tt15"><div class=CClass>Graph event handler that handles selection. </div></div><div class=CToolTip id="tt16"><div class=CClass>Extends mxGraphLayout to implement a compact tree (Moen) algorithm. </div></div><div class=CToolTip id="tt17"><div class=CClass>Base class for all shapes. </div></div><div class=CToolTip id="tt18"><div class=CClass>Singleton that implements a clipboard for graph cells.</div></div><div class=CToolTip id="tt19"><div class=CClass>Defines various global constants.</div></div><div class=CToolTip id="tt20"><div class=CClass>Cross-browser DOM event support. </div></div><div class=CToolTip id="tt21"><div class=CClass>A singleton class that provides cross-browser helper methods. </div></div><div class=CToolTip id="tt22"><div class=CClass>Implements internationalization. </div></div><div class=CToolTip id="tt23"><div class=CClass>A singleton class that implements a simple console.</div></div><div class=CToolTip id="tt24"><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><div class=CToolTip id="tt25"><div class=CClass>XML codec for JavaScript object graphs. </div></div><div class=CToolTip id="tt26"><div class=CClass>Singleton class that acts as a global registry for codecs.</div></div><div class=CToolTip id="tt27"><div class=CClass>The mxEventObject is a wrapper for all properties of a single event. </div></div><div class=CToolTip id="tt28"><div class=CClass>Base class for objects that dispatch named events. </div></div><div class=CToolTip id="tt29"><div class=CClass>Base class for all mouse events in mxGraph. </div></div><div class=CToolTip id="tt30"><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>mxEventSource.prototype.fireEvent = function(</td><td class=PParameter nowrap>evt,</td></tr><tr><td></td><td class=PParameter nowrap>sender</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Dispatches the given event to the listeners which are registered for the event. </div></div><div class=CToolTip id="tt31"><div class=CFu
<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>