首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

A小弟我自己写的connection连线算法Connection————8

2012-10-27 
A我自己写的connection连线算法Connection————8/** * 鼠标按住移动 */public void mouseDragged(MouseEven

A我自己写的connection连线算法Connection————8
/**
* 鼠标按住移动
*/
public void mouseDragged(MouseEvent e) {

Point p = e.getLocation();
Dimension delta = p.getDifference(chipLast);
chipLast = p;
// 获得你鼠标点击的figure
if (e.getSource() instanceof ChipFont) {
ChipFont f = (ChipFont) e.getSource();
// 设置拖动的Figure的位置
f.setBounds(f.getBounds().getTranslated(delta.width,
delta.height));

f.getChip().getBd().setBounds(
new Rectangle(f.getBounds().x - 20,
f.getBounds().y - 15, 135, 135));

// 拖动图形银角和图形一起动
f.getChip().getOutput().setBounds(
new Rectangle(f.getBounds().x - 12, f.getBounds().y,
20, 10));

f.getChip().getInput().setBounds(
new Rectangle(f.getBounds().x - 12,
f.getBounds().y + 20, 20, 10));

f.getChip().getOutputName().setBounds(new Rectangle(f.getChip().getOutput().getBounds().x+9, f.getChip().getOutput().getBounds().y, 8, 10));
         f.getChip().getInputName().setBounds(new Rectangle(f.getChip().getInput().getBounds().x+9, f.getChip().getInput().getBounds().y, 8, 10));
// 名字
f.getChip().setBounds(
new Rectangle(f.getBounds().x - 6, f.getBounds().y - 3,
115, 115));

}

}

热点排行