View unanswered posts | View active topics It is currently 2018-08-20 9:20



Reply to topic  [ 10 posts ] 
 twaver 中这个DEMO( LinkEditorDemo.html)中问题 
Author Message
新手上路

Joined: 2017-06-01 17:02
Posts: 47
Post twaver 中这个DEMO( LinkEditorDemo.html)中问题
我拖拽的时候让线动起来了,
link.setStyle('link.pattern', [15, 15]);
link.setStyle('link.flow.color', '#10F000');
link.setStyle("link.flow", true);
link.setStyle('link.color', 'white');
为什么我点击保存的时候线就变成红色的了?


2018-08-09 11:17
Profile
TWaver开发组
User avatar

Joined: 2018-04-16 13:27
Posts: 27
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
流动效果可以添加network.setLinkFlowEnabled(true),使之生效。通过network.setLinkFlowInterval(value); value为时间间隔,控制流动的速度。
您所描述的问题是因为link.flow.color在序列化时未保存,所以导致了保存时线条变成红色。
当前版本无法修复。


2018-08-13 9:59
Profile
新手上路

Joined: 2017-06-01 17:02
Posts: 47
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
那现在是解决不了吗?


2018-08-13 10:46
Profile
TWaver开发组
User avatar

Joined: 2018-04-16 13:27
Posts: 27
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
只能通过修改默认值的方式修改:添加 twaver.Defaults.NETWORK_LINK_FLOW_COLOR = "#10F000"; 即可


2018-08-13 11:42
Profile
新手上路

Joined: 2017-06-01 17:02
Posts: 47
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
点击保存的时候线的颜色是不变了,怎么在保存的JSON数据中没有link.flow.color这项,我反序列出来在另一个页面还是红色的线


2018-08-13 13:51
Profile
TWaver开发组
User avatar

Joined: 2018-04-16 13:27
Posts: 27
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
目前版本在序列化时,没有保存link.flow.color这项,还需后续版本更新添加。
您可以使用的方法是:将link.flow.color这一项设置为client属性,并将这个数据序列化进去,在另一个页面导入时,需手动设置link.flow.color颜色。

如:link.setClient('link.flow.color','#10f000');
序列化之前需添加 twaver.SerializationSettings.setClientType('link.flow.color','string');
这样序列化时,在用户自定义属性中就有link.flow.color这一项


2018-08-13 14:16
Profile
新手上路

Joined: 2017-06-01 17:02
Posts: 47
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
这是json 数据,link.flow.color有了,但是没有生效,还是红色?


data: "{\"version\":\"5.8.3\",\"platform\":\"html5\",\"images\":{},\"dataBox\":{\"class\":\"twaver.ElementBox\",\"layers\":[{\"name\":\"Default\",\"visible\":true,\"editable\":true,\"movable\":true}]},\"datas\":[{\"class\":\"twaver.Node\",\"ref\":0,\"p\":{\"image\":\"linux\",\"location\":{\"x\":324,\"y\":60}},\"id\":\"DE7562866192456B833F7A0994ED1626\"},{\"class\":\"twaver.Node\",\"ref\":1,\"p\":{\"image\":\"HAProxy\",\"location\":{\"x\":178,\"y\":185}},\"id\":\"A2B44FA11EB64D78B852BD24BF075D36\"},{\"class\":\"twaver.Node\",\"ref\":2,\"p\":{\"image\":\"INTARWEB\",\"location\":{\"x\":536,\"y\":176}},\"id\":\"7241A253EF244A5394BF9E70565D742A\"},{\"class\":\"twaver.Link\",\"ref\":3,\"p\":{\"fromNode\":0,\"toNode\":2},\"s\":{\"link.type\":\"extend.right\",\"arrow.to\":true,\"arrow.to.color\":\"#07ffff\",\"arrow.from.color\":\"#07ffff\",\"link.pattern\":[15,15],\"link.flow\":true,\"link.color\":\"white\",\"link.flow.offset\":24},\"c\":{\"link.flow.color\":\"#10f000\"},\"id\":\"8DE8DCB9B7A942828DB3F13AD8F6B425\"},{\"class\":\"twaver.Link\",\"ref\":4,\"p\":{\"fromNode\":0,\"toNode\":1},\"s\":{\"link.type\":\"extend.left\",\"arrow.to\":true,\"arrow.to.color\":\"#07ffff\",\"arrow.from.color\":\"#07ffff\",\"link.pattern\":[15,15],\"link.flow\":true,\"link.color\":\"white\",\"link.flow.offset\":15},\"c\":{\"link.flow.color\":\"#10f000\"}[/color],[/color]\"id\":\"CEFBEDAC14724DA68DFB68C201ED4AF4\"}]}"


2018-08-13 15:29
Profile
TWaver开发组
User avatar

Joined: 2018-04-16 13:27
Posts: 27
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
读取出来之后,手动设置link.flow.color的颜色
可以通过box去拿到所有的连线,去设置


2018-08-13 16:21
Profile
新手上路

Joined: 2017-06-01 17:02
Posts: 47
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
怎么获取所有的link?我们获取到所有的id,通过上面的json数据

box.getDatas().forEach(element => {
console.log(element.getId());
if(element.getName()=='test1'){
addAlarm("alarm 4", element.getId(), twaver.AlarmSeverity.CRITICAL, box.getAlarmBox());
}
});


2018-08-14 10:06
Profile
TWaver开发组
User avatar

Joined: 2018-04-16 16:11
Posts: 66
Post Re: twaver 中这个DEMO( LinkEditorDemo.html)中问题
Code:
box.getDatas().forEach(function(element){
    if(element instanceof twaver.Link){
        // code start here
   
    }
})


2018-08-14 10:15
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: