jTopo学习笔记4——容器布局

var container = new JTopo.Container('边界自动变化');
scene.add(container);
for(var i=0; i<5; i++){
   var node = new JTopo.Node("A_"+i);
   node.textPosition = "Middle_Center";
   node.setLocation(300+ Math.random() * 300, 200+ Math.random() * 200);
   scene.add(node);
   container.add(node);
}
scene.add(new JTopo.Link(container.childs[0], container.childs[1]));
scene.add(new JTopo.Link(container.childs[2], container.childs[3]));
// 流式布局(水平、垂直间隔均为10)
var flowLayout = JTopo.layout.FlowLayout(10, 10);

// 网格布局(4行3列)
var gridLayout = JTopo.layout.GridLayout(4, 3);
container.layout = flowLayout;
container2.click(function(){
    if(container2.layout === flowLayout){
        container2.layout = gridLayout;
    }else{
        container2.layout = flowLayout;
    }
});复制代码

node.layout = {type: 'circle', radius: 80}; 圆形布局 半径80

JTopo.layout.layoutNode(scene, cloudNode, true); // scene 场景 cloudNode 定位目标

cloudNode.layout = {type: 'tree', direction: 'top',width:180, height: 100} 树形布局 子元素间距180 距离定位点高度100

direction: 'top','left','right','bottom'


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值