forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphControl.js
More file actions
39 lines (33 loc) · 1.22 KB
/
GraphControl.js
File metadata and controls
39 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/// <reference name="MicrosoftAjax.js"/>
Type.registerNamespace("aspnet");
aspnet.GraphControl = function(element) {
aspnet.GraphControl.initializeBase(this, [element]);
}
aspnet.GraphControl.prototype = {
initialize: function() {
aspnet.GraphControl.callBaseMethod(this, 'initialize');
// Constructs a graph instance for the given element
this._graph = new mxGraph(this.get_element());
// Enables rubberband selection
this._rubberband = new mxRubberband(this._graph);
},
dispose: function() {
this._graph.destroy();
aspnet.GraphControl.callBaseMethod(this, 'dispose');
},
get_graph: function() {
return this._graph;
},
decode: function(node) {
// Decodes the given node into the graph model.
var enc = new mxCodec(node.ownerDocument);
enc.decode(node, this._graph.getModel());
},
encode: function() {
// Returns the XML node that represents the graph model.
var enc = new mxCodec();
return enc.encode(this._graph.getModel());
}
}
aspnet.GraphControl.registerClass('aspnet.GraphControl', Sys.UI.Control);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();