import {Serializer} from 'canvas-graph-creator/src/js/util/graph-serialize.js'
Serializer
Serializer class takes care of saving and loading graph via JSON manipulation
Constructor Summary
Public Constructor | ||
public |
constructor(graph: Graph, resetFn: function) Serializer constructor |
Member Summary
Public Members | ||
public |
currentGraph: * |
|
public |
downloadBtn: * |
|
public |
exportBtn: * |
|
public |
importBtn: * |
|
public |
|
|
public |
reader: * |
|
public |
resetFn: * |
|
public |
uploader: * |
Method Summary
Public Methods | ||
public |
allocateElement(name: string): Object Helper function to construct empty objects by class name |
|
public |
deserializeGraph(obj: Object): Object Reads the graph data and creates new elements accordingly |
|
public |
Is called when user wants to download the graph |
|
public |
exportElement(elem: Object, cache: Object, path: string): Object Exports element of graph in object form |
|
public |
Sets value of textbox to the serialzed graph in JSON form |
|
public |
Reads the elem contents and converts it to a raw JSON object newElem |
|
public |
Imports the graph from JSON string |
|
public |
resetGraph(newGraph: Graph) Resets the graph |
|
public |
Abstracts graph into outputOBj |
|
public |
Will not run if the JSON reader fails. |
Public Constructors
Public Members
public currentGraph: * source
public downloadBtn: * source
public exportBtn: * source
public importBtn: * source
public reader: * source
public resetFn: * source
public uploader: * source
Public Methods
public allocateElement(name: string): Object source
Helper function to construct empty objects by class name
Params:
Name | Type | Attribute | Description |
name | string | Name of element type to allocate |
public deserializeGraph(obj: Object): Object source
Reads the graph data and creates new elements accordingly
Params:
Name | Type | Attribute | Description |
obj | Object | The pre-parsed serial graph data |
public exportElement(elem: Object, cache: Object, path: string): Object source
Exports element of graph in object form
public importElement(elem: Object, newElem: Object, nodeCache: Object, edgeCache: Object): Object source
Reads the elem contents and converts it to a raw JSON object newElem
public resetGraph(newGraph: Graph) source
Resets the graph
Params:
Name | Type | Attribute | Description |
newGraph | Graph | The graph data to reset with |