| 99 | } |
| 100 | |
| 101 | private getShapeAttrs( |
| 102 | shape: 'circle' | 'rect' | 'ellipse', |
| 103 | attrs: NodeShapeAttrs |
| 104 | ) { |
| 105 | const newAttrs: NodeShapeAttrs = {}; |
| 106 | switch (shape) { |
| 107 | case 'circle': |
| 108 | newAttrs.r = attrs.r || 15; |
| 109 | break; |
| 110 | case 'rect': |
| 111 | newAttrs.width = attrs.width || 25; |
| 112 | newAttrs.height = attrs.height || newAttrs.width * 0.8; |
| 113 | newAttrs.rx = attrs.rx || 0; |
| 114 | newAttrs.ry = attrs.ry || 0; |
| 115 | break; |
| 116 | case 'ellipse': |
| 117 | newAttrs.rx = attrs.rx || 20; |
| 118 | newAttrs.ry = attrs.ry || newAttrs.rx * 0.6; |
| 119 | break; |
| 120 | default: |
| 121 | console.log('Invalid shape passed - ', shape); |
| 122 | } |
| 123 | return newAttrs; |
| 124 | } |
| 125 | |
| 126 | private updateNodeData() { |
| 127 | const x = this.get('x') || []; |