import * as d3 from "d3" ; /**
 * Model of the nodes.
 */ export default class Node implements NodeProperties { public id : string ; public parent : Node ; public k : number ; public name : string ; public dimensions : Dimensions ; public coordinates : Coordinates ; public image : Image ; public colors : Colors ; public font : Font ; public locked : boolean ; public dom : SVGGElement ; param { NodeProperties } properties constructor ( properties ) { this . id = properties . id ; this . parent = properties . parent ; this . name = properties . name ; this . coordinates = properties . coordinates ; this . colors = properties . colors ; this . image = properties . image ; this . font = properties . font ; this . locked = properties . locked ; this . dimensions = { width : 0 , height : 0 } ; this . k = properties . k || d3 . randomUniform ( - 20 , 20 ) ( ) ; } returns { boolean } public isRoot ( ) { let words = this . id . split ( "_" ) ; return words [ words . length - 1 ] === "0" ; } returns { number } public getLevel ( ) { let level = 1 , parent = this . parent ; while ( parent ) { level ++ ; parent = parent . parent ; } return level ; } returns { HTMLDivElement } public getNameDOM ( ) { return this . dom . querySelector ( "foreignObject > div" ) ; } returns { SVGPathElement } public getBackgroundDOM ( ) { return this . dom . querySelector ( "path" ) ; } returns { SVGImageElement } public getImageDOM ( ) { return this . dom . querySelector ( "image" ) ; } } export interface UserNodeProperties { name : string ; coordinates : Coordinates ; image : Image ; colors : Colors ; font : Font ; locked : boolean ; } export interface NodeProperties extends UserNodeProperties { id : string ; parent : Node ; k ? : number ; } export interface ExportNodeProperties extends UserNodeProperties { id : string ; parent : string ; k : number ; } export interface Coordinates { x : number ; y : number ; } export interface Dimensions { width : number ; height : number ; } export interface Image { src : string ; size : number ; } export interface Colors { name : string ; background : string ; branch : string ; } export interface Font { size : number ; style : string ; weight : string ; decoration : string ; }