View unanswered posts | View active topics It is currently 2019-06-27 18:15



This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
 重写NodeUI 
Author Message
新手上路

Joined: 2015-01-28 16:37
Posts: 31
Post 重写NodeUI
我写的一点代码 :
@Override
public void paintBody(Graphics2D g2d){
super.paintBody(g2d) ;
DevFollow dev = this.node ;

Integer squareMargin = dev.get_squareMargin() ;
g2d.setStroke(new BasicStroke(2f)) ; // 边框宽度
g2d.setColor(new Color(0,128,255)) ; // 边框颜色


//g2d.drawRect((int)dev.getX()-squareMargin, (int)dev.getY()-squareMargin, dev.getWidth()+squareMargin*2, dev.getHeight()+squareMargin*2);
//super.paintBody(g2d) ;


}

就是简单把之前的node节点样式改成我画的矩形,运行的结果好像没什么问题:
Attachment:
运行结果.png
运行结果.png [ 780 Bytes | Viewed 5690 times ]

但是点击蓝线是没有选中的效果,只有在点击矩形里面才出现下面的效果:
Attachment:
选中结果图.png
选中结果图.png [ 1.42 KiB | Viewed 5690 times ]

我不太明白,我重画的矩形不算是节点里面的内容吗,为什么点篮框不能选中呢?请各位老师帮忙看看 谢谢 grin


2017-02-07 14:18
Profile
初级会员

Joined: 2016-03-15 10:43
Posts: 169
Post Re: 重写NodeUI
您好,因为您所画的矩形超过了边框的宽度,所以点击蓝线,没有选中效果。点击矩形内也就是 网元的bounds范围内,才会出现选中的效果。


2017-02-08 17:01
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron