A我自己写的connection连线算法Connection————11
// 初始化芯片槽
public static void initChipTrough() {
int k = 0;
// 槽的初始化
for (int i = 40; i <= 720; i = i + 200) {
for (int j = 40; j <= 720; j = j + 200) {
k++;
PointXY temp = new PointXY(j, i);
Button label = new Button();
// 初始化的芯片槽都没有芯片
chipTrough = new ChipTrough(k, new PointXY(j, i), true);
chipTrough.setEnabled(false);
chipTrough.setBounds(new Rectangle(j, i, 135, 135));
chipTrough.setBackgroundColor(ColorConstants.gray);
panel.add(chipTrough);
// 把芯片槽加到map中 id是KEY 值是坐标
map.put(chipTrough.getCid(), chipTrough);
}
}
}
// 遍历芯片槽打印坐标
public static void printChipTrough() {
Set entries = map.entrySet();
Iterator iter = entries.iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object value = entry.getValue();
System.out.print(" key=" + key + " value="
+ ((ChipTrough) value).getXy().getX() + "----"
+ ((ChipTrough) value).getXy().getY() + " ");
}
}
}