jtopo node.text换行_求助:jtopo node文字换行问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

在jtopo 生成前,粘贴以下代码

CanvasRenderingContext2D.prototype.wrapText = function(str,x,y){

var textArray = str.split('\n');

if(textArray==undefined||textArray==null)return false;

var rowCnt = textArray.length;

var i = 0,imax = rowCnt,maxLength = 0;maxText = textArray[0];

for(;i

var nowText = textArray[i],textLength = nowText.length;

if(textLength >=maxLength){

maxLength = textLength;

maxText = nowText;

}

}

var maxWidth = this.measureText(maxText).width;

var lineHeight = this.measureText("元").width;

x-= lineHeight*2;

for(var j= 0;j

var words = textArray[j];

this.fillText(words,-(maxWidth/2),y-textArray.length*lineHeight/100);

y+= lineHeight;

}

};

然后

var node = new JTopo.Node(data[i].name+"\n"+data[i].xinxi); // 创建一个节点

node.paintText = function(a){

a.beginPath(),

a.font = this.font,

a.wrapText(this.text,this.height/2,this.height);

a.closePath()

};

即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解释一下这段代码 def add_seq_to_prefix_tree(self, root_node, cluster: LogCluster): token_count = len(cluster.log_template_tokens) token_count_str = str(token_count) if token_count_str not in root_node.key_to_child_node: first_layer_node = Node() root_node.key_to_child_node[token_count_str] = first_layer_node else: first_layer_node = root_node.key_to_child_node[token_count_str] cur_node = first_layer_node if token_count == 0: cur_node.cluster_ids = [cluster.cluster_id] return current_depth = 1 for token in cluster.log_template_tokens: if current_depth >= self.max_node_depth or current_depth >= token_count: new_cluster_ids = [] for cluster_id in cur_node.cluster_ids: if cluster_id in self.id_to_cluster: new_cluster_ids.append(cluster_id) new_cluster_ids.append(cluster.cluster_id) cur_node.cluster_ids = new_cluster_ids break if token not in cur_node.key_to_child_node: if self.parametrize_numeric_tokens and self.has_numbers(token): if self.param_str not in cur_node.key_to_child_node: new_node = Node() cur_node.key_to_child_node[self.param_str] = new_node cur_node = new_node else: cur_node = cur_node.key_to_child_node[self.param_str] else: if self.param_str in cur_node.key_to_child_node: if len(cur_node.key_to_child_node) < self.max_children: new_node = Node() cur_node.key_to_child_node[token] = new_node cur_node = new_node else: cur_node = cur_node.key_to_child_node[self.param_str] else: if len(cur_node.key_to_child_node) + 1 < self.max_children: new_node = Node() cur_node.key_to_child_node[token] = new_node cur_node = new_node elif len(cur_node.key_to_child_node) + 1 == self.max_children: new_node = Node() cur_node.key_to_child_node[self.param_str] = new_node cur_node = new_node else: cur_node = cur_node.key_to_child_node[self.param_str] else: cur_node = cur_node.key_to_child_node[token] current_depth += 1
最新发布
03-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值