Home Reference Source Test Repository
public class | source

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
public
public
public
public
public

reader: *

public

resetFn: *

public

Method Summary

Public Methods
public

Helper function to construct empty objects by class name

public

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

importElement(elem: Object, newElem: Object, nodeCache: Object, edgeCache: Object): Object

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 constructor(graph: Graph, resetFn: function) source

Serializer constructor

Params:

NameTypeAttributeDescription
graph Graph

Current graph structure

resetFn function

Function to reset graph

Public Members

public currentGraph: * source

public downloadBtn: * source

public exportBtn: * source

public importBtn: * source

public quickString: string 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:

NameTypeAttributeDescription
name string

Name of element type to allocate

Return:

Object

outObj The constructed object

public deserializeGraph(obj: Object): Object source

Reads the graph data and creates new elements accordingly

Params:

NameTypeAttributeDescription
obj Object

The pre-parsed serial graph data

Return:

Object

importResult Data containing the graph and nodes and edge counts

public downloadGraph() source

Is called when user wants to download the graph

public exportElement(elem: Object, cache: Object, path: string): Object source

Exports element of graph in object form

Params:

NameTypeAttributeDescription
elem Object

The element of graph to be exported

cache Object

A remnant of the original serializer

path string

A remnant of the original serializer

Return:

Object

outputObj Contains the element object data

public exportGraph() source

Sets value of textbox to the serialzed graph in JSON 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

Params:

NameTypeAttributeDescription
elem Object

The element of graph to be imported

newElem Object

The return element and contains the imported data

nodeCache Object

Allows for loading references to existing nodes

edgeCache Object

Allows for loading references to existing edges

Return:

Object

newElem A fully initialized graph element.

public importGraph() source

Imports the graph from JSON string

public resetGraph(newGraph: Graph) source

Resets the graph

Params:

NameTypeAttributeDescription
newGraph Graph

The graph data to reset with

public serializeGraph(): Object source

Abstracts graph into outputOBj

Return:

Object

outputObj JSON object that can be stringified, contains graph data

public uploadGraph() source

Will not run if the JSON reader fails. Loads the graph from JSON file