浏览代码

Only unique HolonObj are added to the tracking Array

Edgardo Palza 8 年之前
父节点
当前提交
71dbdef39c
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      src/ui/view/MyCanvas.java

+ 12 - 1
src/ui/view/MyCanvas.java

@@ -131,9 +131,20 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			public void actionPerformed(ActionEvent e) {
 				for (AbstractCpsObject o : model.getSelectedCpsObjects()) {
 					if (o instanceof HolonObject) {
-						control.addTrackingObj((HolonObject) o);
+						boolean found = false;
+						if (control.getTrackingObj() != null) {
+							for (HolonObject obj : control.getTrackingObj()) {
+								if (obj.getID() == o.getID()) {
+									found = true;
+								}
+							}
+						}
+						if (!found) {
+							control.addTrackingObj((HolonObject) o);
+						}
 					}
 				}
+				System.out.println(control.getTrackingObj());
 			}
 		});