-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDeployNodes.js
30 lines (29 loc) · 1.44 KB
/
DeployNodes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React, { Component } from 'react';
import _ from 'lodash'
import { tx, ty, kx, ky } from './CoordinatePoints'
import Svg,{ G, Text, Rect, Image } from 'react-native-svg'
export function DeployNodes(nodes)
{
const rectNodes = _.map(nodes,function (n,index) {
let text, imageWidth, imageHeight;
imageWidth = n.nodeImageStyle ? n.nodeImageStyle.imageWidth : 50
imageHeight = n.nodeImageStyle ? n.nodeImageStyle.imageHeight : 50
if(n.name)
{
text = <Text
x={tx(n)} y={ty(n) + imageHeight} {...n.nodeTextStyle} >{ n.name }</Text>
return (<G key={'tree_' + index}>
<Image
x={kx(n)}
y={ky(n)}
width={imageWidth}
height={imageHeight}
{...n.nodeImageStyle}
{...n.imageUrl}
/>
{text}
</G>)
}
})
return rectNodes
}