Newer
Older
import { Graph } from "./graph";
import { SerializableItem } from "../helper/serializableitem";
export class GraphElement extends SerializableItem {
protected isNode: boolean;
protected isLink: boolean;
constructor(graph: Graph = undefined) {
super();
this.graph = graph;
this.isNode = false;
this.isLink = false;
}
public get node(): boolean {
return this.isNode;
}
public get link(): boolean {
return this.isLink;
}
/**
* Removes element from its parent graph.
* @returns True, if successful.
*/
public delete(): boolean {
throw new Error('Function "delete()" has not been implemented.');
}
/**
* Adds the element to the given graph.
* @param graph Graph to add element to.
* @returns True, if successful.
*/
public add(graph: Graph = this.graph): boolean {
throw new Error('Function "add(graph)" has not been implemented.');
}
/**
* Needs to be implemented to create a filtered version for storing in the data history.
* @returns Filtered object.
*/
public getCleanInstance(): any {
throw new Error(
'Function "getCleanInstance()" has not been implemented.'
);
/**
* Compares to objects. Can be a custom implementation.
* @returns True, if given object is identical.
*/
public equals(other: GraphElement): boolean {
return (
other.node == this.node &&
other.link == this.link &&
other.id == this.id
);
}