Browse Source

HolonElement Back-End Control

Teh-Hai Julian Zheng 8 years ago
parent
commit
3d31e4d84d

BIN
bin/classes/HolonObject.class


BIN
bin/ui/controller/ObjectControl.class


+ 15 - 15
src/ui/controller/ObjectControl.java

@@ -65,8 +65,8 @@ public class ObjectControl {
 	 * @param element
 	 * @param type
 	 */
-	public void addElementIntoCanvasObject(HolonObject object, HolonElement element, Type type) {
-		addElement(object, element, type);
+	public void addElementIntoCanvasObject(String object, HolonElement element, Type type) {
+		addElement(searchHolonObject(object, M.getObjectsOnCanvas()), element, type);
 	}
 
 	/**
@@ -79,8 +79,7 @@ public class ObjectControl {
 	 * @param type
 	 */
 	public void addNewElementIntoCanvasObject(String object, String eleName, int amount, float energy, Type type) {
-		addElementIntoCanvasObject(searchHolonObject(object, M.getObjectsOnCanvas()),
-				new HolonElement(eleName, amount, energy), type);
+		addElementIntoCanvasObject(object, new HolonElement(eleName, amount, energy), type);
 	}
 
 	/**
@@ -90,8 +89,17 @@ public class ObjectControl {
 	 * @param element
 	 * @param type
 	 */
-	public void addElementIntoCategoryObject(HolonObject object, HolonElement element, Type type) {
-		addElement(object, element, type);
+	public void addElementIntoCategoryObject(String category, String object, HolonElement element, Type type) {
+		Category cat = null;
+
+		for (Category cats : M.getCategories()) {
+			if (cats.getName().equals(category)) {
+				cat = cats;
+				break;
+			}
+		}
+
+		addElement(searchHolonObject(object, cat.getObjects()), element, type);
 	}
 
 	/**
@@ -106,16 +114,8 @@ public class ObjectControl {
 	 */
 	public void addNewElementIntoCategoryObject(String category, String object, String eleName, int amount,
 			float energy, Type type) {
-		Category cat = null;
 
-		for (Category cats : M.getCategories()) {
-			if (cats.getName().equals(category)) {
-				cat = cats;
-				break;
-			}
-		}
-		addElementIntoCategoryObject(searchHolonObject(object, cat.getObjects()),
-				new HolonElement(eleName, amount, energy), type);
+		addElementIntoCategoryObject(category, object, new HolonElement(eleName, amount, energy), type);
 	}
 
 	/**