import { Rect } from '../models/rect' ; import { Point } from '../models/point' ; import { Node } from '../models/node' ; import { Line } from '../models/line' ; import { rectangle } from './nodes/rectangle' ; import { circle } from './nodes/circle' ; import { triangle } from './nodes/triangle' ; import { diamond } from './nodes/diamond' ; import { leftArrow , rightArrow , twowayArrow } from './nodes/arrow' ; import { text } from './nodes/text' ; import { line as nodeLine } from './nodes/line' ; import { triangleAnchors } from './nodes/triangle.anchor' ; import { arrowAnchors } from './nodes/arrow.anchor' ; import { lineAnchors } from './nodes/line.anchor' ; import { circleIconRect , circleTextRect } from './nodes/circle.rect' ; import { triangleIconRect , triangleTextRect } from './nodes/triangle.rect' ; import { diamondIconRect , diamondTextRect } from './nodes/diamond.rect' ; import { twowayArrowIconRect , twowayArrowTextRect , leftArrowIconRect , leftArrowTextRect , rightArrowIconRect , rightArrowTextRect , } from './nodes/arrow.rect' ; import { lineIconRect , lineTextRect } from './nodes/line.rect' ; import { line , lineControlPoints , calcLineControlPoints } from './lines/line' ; import { polyline , polylineControlPoints , pointInPolyline , calcPolylineControlPoints , dockPolylineControlPoint , } from './lines/polyline' ; import { curve , curveControlPoints , pointInCurve , calcCurveControlPoints , } from './lines/curve' ; import { calcMindControlPoints , } from './lines/mind' ; import { triangleSolid , triangle as arrowTriangle } from './arrows/triangle' ; import { diamondSolid , diamond as arrowDiamond } from './arrows/diamond' ; import { circleSolid , circle as arrowCircle } from './arrows/circle' ; import { circleAnchors } from './nodes/circle.anchor' ; import { lineUp , lineDown , line as arrowLine } from './arrows/line' ; import { pentagon } from './nodes/pentagon' ; import { pentagonIconRect , pentagonTextRect } from './nodes/pentagon.rect' ; import { pentagonAnchors } from './nodes/pentagon.anchor' ; import { hexagon } from './nodes/hexagon' ; import { hexagonAnchors } from './nodes/hexagon.anchor' ; import { hexagonIconRect , hexagonTextRect } from './nodes/hexagon.rect' ; import { pentagram } from './nodes/pentagram' ; import { pentagramAnchors } from './nodes/pentagram.anchor' ; import { pentagramIconRect , pentagramTextRect } from './nodes/pentagram.rect' ; import { cloud } from './nodes/cloud' ; import { cloudAnchors } from './nodes/cloud.anchor' ; import { cloudIconRect , cloudTextRect } from './nodes/cloud.rect' ; import { message } from './nodes/message' ; import { messageIconRect , messageTextRect } from './nodes/message.rect' ; import { messageAnchors } from './nodes/message.anchor' ; import { file } from './nodes/file' ; import { imageIconRect , imageTextRect } from './nodes/image.rect' ; import { imageAnchors } from './nodes/image.anchor' ; import { cube } from './nodes/cube' ; import { cubeAnchors } from './nodes/cube.anchor' ; import { cubeIconRect , cubeTextRect } from './nodes/cube.rect' ; import { people } from './nodes/people' ; import { peopleIconRect , peopleTextRect } from './nodes/people.rect' ; import { rectangleIconRect , rectangleTextRect } from './nodes/rectangle.rect' ; import { graffiti } from './nodes/graffiti' ; import { graffitiAnchors } from './nodes/graffiti.anchor' ; import { mindNodeAnchors } from './nodes/mindNode.anchor' ; import { mindLine } from './nodes/mindLine' ; import { mindLineAnchors } from './nodes/mindLine.anchor' ; import { lines } from './nodes/lines' ; export const drawNodeFns = { } ; export const iconRectFns = { } ; export const textRectFns = { } ; export const anchorsFns = { } ; export const drawLineFns = { } ; export const drawArrowFns = { } ; function init ( ) { drawNodeFns . combine = rectangle ; drawNodeFns . div = rectangle ; drawNodeFns . graffiti = graffiti ; anchorsFns . graffiti = graffitiAnchors ; drawNodeFns . lines = lines ; drawNodeFns . square = rectangle ; drawNodeFns . rectangle = rectangle ; iconRectFns . rectangle = rectangleIconRect ; textRectFns . rectangle = rectangleTextRect ; drawNodeFns . circle = circle ; iconRectFns . circle = circleIconRect ; textRectFns . circle = circleTextRect ; anchorsFns . circle = circleAnchors ; drawNodeFns . triangle = triangle ; anchorsFns . triangle = triangleAnchors ; iconRectFns . triangle = triangleIconRect ; textRectFns . triangle = triangleTextRect ; drawNodeFns . diamond = diamond ; iconRectFns . diamond = diamondIconRect ; textRectFns . diamond = diamondTextRect ; drawNodeFns . hexagon = hexagon ; iconRectFns . hexagon = hexagonIconRect ; textRectFns . hexagon = hexagonTextRect ; anchorsFns . hexagon = hexagonAnchors ; drawNodeFns . pentagon = pentagon ; iconRectFns . pentagon = pentagonIconRect ; textRectFns . pentagon = pentagonTextRect ; anchorsFns . pentagon = pentagonAnchors ; drawNodeFns . pentagram = pentagram ; iconRectFns . pentagram = pentagramIconRect ; textRectFns . pentagram = pentagramTextRect ; anchorsFns . pentagram = pentagramAnchors ; drawNodeFns . leftArrow = leftArrow ; anchorsFns . leftArrow = arrowAnchors ; iconRectFns . leftArrow = leftArrowIconRect ; textRectFns . leftArrow = leftArrowTextRect ; drawNodeFns . rightArrow = rightArrow ; anchorsFns . rightArrow = arrowAnchors ; iconRectFns . rightArrow = rightArrowIconRect ; textRectFns . rightArrow = rightArrowTextRect ; drawNodeFns . twowayArrow = twowayArrow ; anchorsFns . twowayArrow = arrowAnchors ; iconRectFns . twowayArrow = twowayArrowIconRect ; textRectFns . twowayArrow = twowayArrowTextRect ; drawNodeFns . cloud = cloud ; anchorsFns . cloud = cloudAnchors ; iconRectFns . cloud = cloudIconRect ; textRectFns . cloud = cloudTextRect ; drawNodeFns . message = message ; anchorsFns . message = messageAnchors ; iconRectFns . message = messageIconRect ; textRectFns . message = messageTextRect ; drawNodeFns . file = file ; drawNodeFns . text = text ; iconRectFns . text = lineIconRect ; drawNodeFns . line = nodeLine ; anchorsFns . line = lineAnchors ; iconRectFns . line = lineIconRect ; textRectFns . line = lineTextRect ; drawNodeFns . image = ( ctx , node ) => { } ; iconRectFns . image = imageIconRect ; textRectFns . image = imageTextRect ; anchorsFns . image = imageAnchors ; drawNodeFns . cube = cube ; anchorsFns . cube = cubeAnchors ; iconRectFns . cube = cubeIconRect ; textRectFns . cube = cubeTextRect ; drawNodeFns . people = people ; iconRectFns . people = peopleIconRect ; textRectFns . people = peopleTextRect ; drawNodeFns . mindNode = rectangle ; anchorsFns . mindNode = mindNodeAnchors ; iconRectFns . mindNode = rectangleIconRect ; textRectFns . mindNode = rectangleTextRect ; drawNodeFns . mindLine = mindLine ; anchorsFns . mindLine = mindLineAnchors ; drawLineFns . line = { drawFn : line , drawControlPointsFn : lineControlPoints , controlPointsFn : calcLineControlPoints , pointIn : pointInPolyline , } ; drawLineFns . polyline = { drawFn : polyline , drawControlPointsFn : polylineControlPoints , controlPointsFn : calcPolylineControlPoints , dockControlPointFn : dockPolylineControlPoint , pointIn : pointInPolyline , } ; drawLineFns . curve = { drawFn : curve , drawControlPointsFn : curveControlPoints , controlPointsFn : calcCurveControlPoints , pointIn : pointInCurve , } ; drawLineFns . mind = { drawFn : curve , drawControlPointsFn : curveControlPoints , controlPointsFn : calcMindControlPoints , pointIn : pointInCurve , } ; drawArrowFns . triangleSolid = triangleSolid ; drawArrowFns . triangle = arrowTriangle ; drawArrowFns . diamondSolid = diamondSolid ; drawArrowFns . diamond = arrowDiamond ; drawArrowFns . circleSolid = circleSolid ; drawArrowFns . circle = arrowCircle ; drawArrowFns . line = arrowLine ; drawArrowFns . lineUp = lineUp ; drawArrowFns . lineDown = lineDown ; } init ( ) ; export function registerNode ( name , drawFn , anchorsFn ? , iconRectFn ? , textRectFn ? , protect ? ) { if ( drawNodeFns [ name ] && protect ) { return false ; } drawNodeFns [ name ] = drawFn ; anchorsFns [ name ] = anchorsFn ; iconRectFns [ name ] = iconRectFn ; textRectFns [ name ] = textRectFn ; return true ; } export function registerLine ( name , drawFn , drawControlPointsFn ? , controlPointsFn ? , dockControlPointFn ? , pointInFn ? , getLength ? , getCenter ? , getPointByPos ? , force = true ) { if ( drawLineFns [ name ] && ! force ) { return false ; } drawLineFns [ name ] = { drawFn : drawFn , drawControlPointsFn : drawControlPointsFn , controlPointsFn : controlPointsFn , dockControlPointFn , pointIn : pointInFn , getLength , getCenter , getPointByPos , } ; return true ; } export function registerArrow ( name , drawFn , protect ? ) { if ( drawArrowFns [ name ] && protect ) { return false ; } drawArrowFns [ name ] = drawFn ; return true ; } ( window as any ) . registerTopologyNode = registerNode ; ( window as any ) . registerTopologyLine = registerLine ;