227 lines
4.8 KiB
TypeScript
227 lines
4.8 KiB
TypeScript
/**
|
|
* @author Martin Karkowski
|
|
* @email m.karkowski@zema.de
|
|
* @create date 2020-03-11 16:24:48
|
|
* @modify date 2020-03-31 17:59:26
|
|
* @desc [description]
|
|
*/
|
|
|
|
import { IClusters } from './/IClusters';
|
|
import { EventEmitter } from 'events';
|
|
import { IBaseNodeOptions } from './/IBaseNodeOptions';
|
|
import { IBaseEdgeOptions } from './/IBaseEdgeOptions';
|
|
import { INetwork } from './/INetwork';
|
|
import { IEvent } from './IEvents';
|
|
|
|
export interface IBaseGraph<N, E> {
|
|
|
|
/**
|
|
* The Original VISJS Network
|
|
*/
|
|
network: any;
|
|
|
|
/**
|
|
* Contained Edges
|
|
*/
|
|
edges: Array<IBaseEdgeOptions<E>>;
|
|
|
|
/**
|
|
* Contained Nodes
|
|
*/
|
|
nodes: Array<IBaseNodeOptions<N>>;
|
|
|
|
/**
|
|
* Contained Data
|
|
*/
|
|
data: {
|
|
edges: any;
|
|
nodes: any;
|
|
}
|
|
|
|
/**
|
|
* Flag to enable / disable the Version Control of Files
|
|
*/
|
|
useVersionControl: boolean;
|
|
|
|
/**
|
|
* The current Version to handle.
|
|
*/
|
|
version: string;
|
|
|
|
/**
|
|
* Emitter
|
|
*/
|
|
emitter: EventEmitter;
|
|
|
|
/**
|
|
* Function to add Node(s)
|
|
* @param nodes The Node/Nodes
|
|
*/
|
|
addNode(nodes: Array<IBaseNodeOptions<N>> | IBaseNodeOptions<N>): void;
|
|
|
|
/**
|
|
* Function to Remove a Node
|
|
* @param id
|
|
*/
|
|
removeNode(id: string | number): void;
|
|
|
|
/**
|
|
* Function to update Node(s)
|
|
* @param nodes The Node/Nodes
|
|
*/
|
|
updateNode(nodes: Array<IBaseNodeOptions<N>> | IBaseNodeOptions<N>): void;
|
|
|
|
/**
|
|
* Function to Delete all Nodes
|
|
*/
|
|
clearNodes(): void;
|
|
|
|
/**
|
|
* Function to Get a Node
|
|
* @param id The Id of the Node
|
|
*/
|
|
getNode<T=N>(id): IBaseNodeOptions<T>;
|
|
|
|
/**
|
|
* Function to Test, whether the Node exists or not
|
|
* @param id The Id of the Node
|
|
*/
|
|
hasNode(id: string): boolean;
|
|
|
|
/**
|
|
* Function to add Edge(s)
|
|
* @param element The Edge(s)
|
|
*/
|
|
addEdge(element: Array<IBaseEdgeOptions<E>> | IBaseEdgeOptions<E>): void;
|
|
|
|
/**
|
|
* Function to Remove the Edge with the given ID
|
|
* @param id Id of the Edge
|
|
*/
|
|
removeEdge(id: string | number): void;
|
|
|
|
/**
|
|
* Function to Update Edge(s)
|
|
* @param edges The Updated Content
|
|
*/
|
|
updateEdge(edges: Array<IBaseEdgeOptions<E>> | IBaseEdgeOptions<E>): void;
|
|
|
|
/**
|
|
* Function to delete all Edges
|
|
*/
|
|
clearEdges(): void;
|
|
|
|
/**
|
|
* Function to Get the Edge with the given ID
|
|
* @param id The Id of the Edge
|
|
*/
|
|
getEdge<T=E>(id): IBaseEdgeOptions<T>
|
|
|
|
/**
|
|
* Clear the Complete Graph
|
|
*/
|
|
clear(): void;
|
|
|
|
/**
|
|
* Destroy the Graph
|
|
*/
|
|
destroy(): void;
|
|
|
|
/**
|
|
* Fit the Graph
|
|
* @param options Settings for the Fitting
|
|
*/
|
|
fit(options?: {
|
|
/** Focus the provided Nodes */
|
|
nodes?: Array<string>,
|
|
/** Animate the Fit */
|
|
animation?: boolean | {
|
|
duration?: number,
|
|
easingFunction?: String
|
|
}
|
|
}): void;
|
|
|
|
/**
|
|
* Function to resize the Element.
|
|
*/
|
|
resize(): void;
|
|
|
|
/**
|
|
* Function, to subscribe to Events
|
|
* @param eventName Event
|
|
* @param callback The Callback (see original VISJS Docu)
|
|
*/
|
|
on(eventName: IEvent, callback: (...args) => void): () => void;
|
|
|
|
/**
|
|
* Function, to subscribe to Events but just for one notification
|
|
* @param eventName Event
|
|
* @param callback The Callback (see original VISJS Docu)
|
|
*/
|
|
once(eventName: IEvent, callback: (...args) => void): () => void;
|
|
|
|
/**
|
|
* Function to get Cluster-Structure
|
|
*/
|
|
getClusters(): IClusters;
|
|
|
|
/**
|
|
* Function to Load a Cluster-Structure
|
|
* @param clusters the Cluster-Structure
|
|
*/
|
|
readinClusters(clusters: IClusters): void;
|
|
|
|
/**
|
|
* Function to get the current Graph Data
|
|
*/
|
|
getData(name?: string, id?: string, version?: string): INetwork<N,E>
|
|
|
|
/**
|
|
* Function to Load / Import the Graph
|
|
* @param data The Graph Structure
|
|
* @param overwrite Flag, to overwrite the old Graph or extend it
|
|
* @param cluster Flag, to determine, whether to load Clusters or not.
|
|
*/
|
|
loadData(data: INetwork<N,E>,
|
|
overwrite?: boolean,
|
|
cluster?: boolean): void;
|
|
}
|
|
|
|
export interface IUndoRedoGraph<N, E> extends IBaseGraph<N,E> {
|
|
|
|
/**
|
|
* Flag to Toggle Loading and disabling
|
|
* Elements
|
|
*/
|
|
disableStoringContent: boolean;
|
|
|
|
/**
|
|
* Flag, showing whether Undo is Enabled or not
|
|
*/
|
|
undoEnabled: boolean;
|
|
|
|
/**
|
|
* Flag, showing whether Redo is Enabled or not
|
|
*/
|
|
redoEnabled: boolean;
|
|
|
|
/**
|
|
* Function to Save the Current State
|
|
*/
|
|
save(): void;
|
|
|
|
/**
|
|
* Function to Undo the Last Change
|
|
*/
|
|
undo(): void;
|
|
|
|
/**
|
|
* Function to Redo the Last Change
|
|
*/
|
|
redo():void;
|
|
|
|
/**
|
|
* Reset the Complete History
|
|
*/
|
|
resetHistory():void;
|
|
} |