A我自己写的connection连线算法Connection————2

public static void main(String args[]) {

chipName = "SD5880 0";
outputName = "1";
inputName = "0";
point = new PointXY(x, y);
map = new HashMap();
Shell shell = new Shell();
shell.setBackground(ColorConstants.darkGray);
shell.setSize(900, 600);
shell.open();
shell.setText("Connection Demo");
conn1 = new PolylineConnection();
fontRegistry = new FontRegistry();
FontData fontData = new FontData("隶书", 15, SWT.BOLD);
fontRegistry.put(FONT_ONE, new FontData[] { fontData });

fontData = new FontData("隶书", 10, SWT.BOLD);
fontRegistry.put(THREE, new FontData[] { fontData });

fontData = new FontData("楷体", 15, SWT.NORMAL);
fontRegistry.put(FONT_TWO, new FontData[] { fontData });

LightweightSystem lws = new LightweightSystem(shell);

lws.setContents(panel);

// 初始化的槽ID
initChipTrough();
// 遍历芯片槽打印芯片槽坐标
printChipTrough();
// 增加芯片button
Button b1 = new Button("增加芯片");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
// 银角
inputRole = new Role(id++);
outputRole = new Role(id++);
// 银角名字
outputRoleName = new RoleName(outputName, node);
inputRoleName = new RoleName(inputName, node);

bd = new NodeBd(id++);

// 判断芯片槽是否已经存放芯片
if (((ChipTrough) map.get(z)).isSaveCome()) {
// 芯片槽的坐标值
x = ((ChipTrough) map.get(z)).getXy().getX();
y = ((ChipTrough) map.get(z)).getXy().getY();

// 芯片
node = new Chip(outputRole, inputRole, outputRoleName, inputRoleName, bd);
chipLabel = new ChipFont(chipName, node);
node.setBackgroundColor(ColorConstants.black);
node.setBounds(new Rectangle(x + 14, y + 12, 115, 115));
node.setBorder(new FocusBorder());

// 边框
bd.setBackgroundColor(ColorConstants.darkGreen);
bd.setBounds(new Rectangle(x, y, 135, 135));

// 输出银角
outputRole.setBounds(new Rectangle(x + 8,node.getBounds().y + 2, 20, 10));
// 输入眼角
inputRole.setBounds(new Rectangle(x + 8,node.getBounds().y + 20, 20, 10));

inputRole.setBackgroundColor(ColorConstants.yellow);
outputRole.setBackgroundColor(ColorConstants.cyan);

// 银角名字对象的设置
outputRoleName.setForegroundColor(ColorConstants.black);
outputRoleName.setBounds(new Rectangle(outputRole.getBounds().x+8, outputRole.getBounds().y, 8, 10));


inputRoleName.setForegroundColor(ColorConstants.black);
inputRoleName.setBounds(new Rectangle(inputRole.getBounds().x+8, inputRole.getBounds().y, 8, 10));

// 名字
chipLabel.setForegroundColor(ColorConstants.white);
chipLabel.setFont(fontRegistry.getItalic(FONT_ONE));
chipLabel
.setBounds(new Rectangle(x + 20, y + 15, 115, 115));

// 設置初始化的所有槽都是false可以存放芯片
((ChipTrough) map.get(z)).setSaveCome(false);
z++;
} else {
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值