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

for (int a = z + 1; a <= 16; a++) {
if (((ChipTrough) map.get(a)).isSaveCome()) {
x = ((ChipTrough) map.get(a)).getXy().getX();
y = ((ChipTrough) map.get(a)).getXy().getY();
// 芯片
node = new Chip(outputRole, inputRole, null, null,
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+9, outputRole.getBounds().y, 8, 10));
                           inputRoleName.setForegroundColor(ColorConstants.black);
                           inputRoleName.setBounds(new Rectangle(inputRole.getBounds().x+9, 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));
//
((ChipTrough) map.get(a)).setSaveCome(false);
// break 是中断循环 不再判断下一个芯片槽是否有芯片 因为这个要增加的芯片已经增加
break;
} else {
// 继续循环 因为下个芯片槽还是存在芯片
continue;
}

}
}

panel.add(bd);
panel.add(node);
panel.add(outputRole);
panel.add(inputRole);
panel.add(chipLabel);
panel.add(inputRoleName);
panel.add(outputRoleName);

new Dragger(chipLabel);
new Dragger(outputRole);
new Dragger(inputRole);
new Dragger(panel);
}

});
b1.setBounds(new Rectangle(300, 0, 90, 30));

panel.add(b1);

panel.addFigureListener(new FigureListener() {

@Override
public void figureMoved(IFigure source) {
// TODO Auto-generated method stub

}
});

Display display = Display.getDefault();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

}

你可能感兴趣的:(算法)