Teh-Hai Julian Zheng 8 gadi atpakaļ
vecāks
revīzija
cafd807331

+ 2 - 1
src/classes/AbstractCpsObject.java

@@ -33,11 +33,12 @@ public abstract class AbstractCpsObject {
 	Color borderColor = Color.WHITE;
 	Color borderColor = Color.WHITE;
 	/* a Tag that can be used */
 	/* a Tag that can be used */
 	ArrayList<Integer> tags;
 	ArrayList<Integer> tags;
+	
 	/* a Tag that can be used */
 	/* a Tag that can be used */
 	ArrayList<Integer> pseudoTags;
 	ArrayList<Integer> pseudoTags;
 	
 	
 	/**
 	/**
-	 * Constructor for a CpsObejct with an unique ID.
+	 * Constructor for a CpsObejct
 	 * 
 	 * 
 	 * @param objName
 	 * @param objName
 	 *            of the Object
 	 *            of the Object

+ 1 - 1
src/classes/Category.java

@@ -16,7 +16,7 @@ public class Category {
 	// objects: is a ArrayList of all Objects that belongs to the Category
 	// objects: is a ArrayList of all Objects that belongs to the Category
 	private ArrayList<AbstractCpsObject> objects;
 	private ArrayList<AbstractCpsObject> objects;
 	// name: is a String chosen by the User
 	// name: is a String chosen by the User
-	private String name;
+	private String name; 
 	// ObjIdx: Index of each Category that corresponds to the order in the tree
 	// ObjIdx: Index of each Category that corresponds to the order in the tree
 	private HashMap<String, Integer> objIdx;
 	private HashMap<String, Integer> objIdx;
 
 

+ 1 - 1
src/classes/HolonElement.java

@@ -29,7 +29,7 @@ public class HolonElement {
 	/* Object where the Element is Stored */
 	/* Object where the Element is Stored */
 	private String obj;
 	private String obj;
 	/* Unique Id of the Element */
 	/* Unique Id of the Element */
-	private int id;
+	private int id; 
 	/*
 	/*
 	 * Energy at each point of the graph with 100 predefined points. At the
 	 * Energy at each point of the graph with 100 predefined points. At the
 	 * beginning, it starts with all values at energy
 	 * beginning, it starts with all values at energy

+ 4 - 3
src/tests/PraktikumHolonsTestAutoSaveController.java

@@ -22,7 +22,8 @@ public class PraktikumHolonsTestAutoSaveController {
 	}
 	}
 
 
 	/**
 	/**
-	 *  kommentar hier hin.
+	 *  Tests for the AutoSavController. 
+	 *  The AutoSaveController only contains indices for the actual save file.
 	 */
 	 */
 	@Test
 	@Test
 	public void testAutoSave() {
 	public void testAutoSave() {
@@ -34,13 +35,13 @@ public class PraktikumHolonsTestAutoSaveController {
 		for (int i = 0; i < 20; i++) {
 		for (int i = 0; i < 20; i++) {
 			controller.increaseAutoSaveNr();
 			controller.increaseAutoSaveNr();
 		}
 		}
-		
+		assertTrue("AutoSave Number not correct", controller.getAutoSaveNr() == 20);
 		assertTrue("Is Allowed not set", controller.allowed());
 		assertTrue("Is Allowed not set", controller.allowed());
 		
 		
 		for (int i = 0; i < 20; i++) {
 		for (int i = 0; i < 20; i++) {
 			controller.decreaseAutoSaveNr();;
 			controller.decreaseAutoSaveNr();;
 		}
 		}
-		
+		assertTrue("AutoSave Number not correct", controller.getAutoSaveNr() == 0);
 		
 		
 	}
 	}
 }
 }

+ 0 - 1
src/tests/PraktikumHolonsTestCanvasController.java

@@ -198,7 +198,6 @@ public class PraktikumHolonsTestCanvasController {
 		controller.addNewObject(b);
 		controller.addNewObject(b);
 		controller.addNewObject(c);
 		controller.addNewObject(c);
 		controller.cutObjects();
 		controller.cutObjects();
-		assertTrue("Objects still on canvas", model.getObjectsOnCanvas().isEmpty());
 		
 		
 	}
 	}
 }
 }

+ 21 - 5
src/tests/PraktikumHolonsTestClasses.java

@@ -11,6 +11,9 @@ import org.junit.Test;
 
 
 public class PraktikumHolonsTestClasses {
 public class PraktikumHolonsTestClasses {
 
 
+	/**
+	 * Tests for the Category Class.
+	 */
 	@Test
 	@Test
 	public void testCategory() {
 	public void testCategory() {
 		Category test1 = new Category("Test1");
 		Category test1 = new Category("Test1");
@@ -35,6 +38,9 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("Shoud not be empty", !arr.isEmpty());
 		assertTrue("Shoud not be empty", !arr.isEmpty());
 	}
 	}
 
 
+	/**
+	 * Tests for the HolonObject Class.
+	 */
 	@Test
 	@Test
 	public void testHolonObject() {
 	public void testHolonObject() {
 
 
@@ -42,9 +48,7 @@ public class PraktikumHolonsTestClasses {
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test3 = new HolonObject(test1);
 		HolonObject test3 = new HolonObject(test1);
 		HolonElement ele = new HolonElement("Element", 1, 10);
 		HolonElement ele = new HolonElement("Element", 1, 10);
-
 		ArrayList<HolonElement> arr = new ArrayList<>();
 		ArrayList<HolonElement> arr = new ArrayList<>();
-
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		test1.setElements(arr);
 		test1.setElements(arr);
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
@@ -61,7 +65,6 @@ public class PraktikumHolonsTestClasses {
 		test2.deleteElement(0);
 		test2.deleteElement(0);
 		test2.addElements(ele);
 		test2.addElements(ele);
 		assertTrue("Current Energy not corrent", test2.getCurrentEnergy() == 20);
 		assertTrue("Current Energy not corrent", test2.getCurrentEnergy() == 20);
-
 		assertTrue("Should be Empty", test3.getElements().isEmpty());
 		assertTrue("Should be Empty", test3.getElements().isEmpty());
 		test3.setElements(test2.copyElements(test2.getElements()));
 		test3.setElements(test2.copyElements(test2.getElements()));
 		assertTrue("Should be Empty", !test3.getElements().isEmpty());
 		assertTrue("Should be Empty", !test3.getElements().isEmpty());
@@ -86,18 +89,19 @@ public class PraktikumHolonsTestClasses {
 		Color color = test3.getColor();
 		Color color = test3.getColor();
 		test3.setColor(new Color(0, 255, 255));
 		test3.setColor(new Color(0, 255, 255));
 		assertTrue(color.getBlue() != test3.getColor().getBlue());
 		assertTrue(color.getBlue() != test3.getColor().getBlue());
-
 		test3.addElements(new HolonElement("Element3", 3, 50));
 		test3.addElements(new HolonElement("Element3", 3, 50));
 		test3.setState();
 		test3.setState();
 		assertTrue("Should be state 3", test3.getState() == 3);
 		assertTrue("Should be state 3", test3.getState() == 3);
 		test1.setState();
 		test1.setState();
 		assertTrue("Should be state 0", test1.getState() == 0);
 		assertTrue("Should be state 0", test1.getState() == 0);
 		test2.setState();
 		test2.setState();
-		
 		test2.setBorderColor(color);
 		test2.setBorderColor(color);
 		assertTrue("Color not Same", color == test2.getBorderColor());
 		assertTrue("Color not Same", color == test2.getBorderColor());
 	}
 	}
 
 
+	/**
+	 * Tests for HolonSwitch Class.
+	 */
 	@Test
 	@Test
 	public void testHolonSwitch() {
 	public void testHolonSwitch() {
 		HolonSwitch test1 = new HolonSwitch("Test1");
 		HolonSwitch test1 = new HolonSwitch("Test1");
@@ -123,6 +127,9 @@ public class PraktikumHolonsTestClasses {
 		assertTrue(test1.getGraphPoints() == test2.getGraphPoints());
 		assertTrue(test1.getGraphPoints() == test2.getGraphPoints());
 	}
 	}
 
 
+	/**
+	 * Tests for CpsEdge Class.
+	 */
 	@Test
 	@Test
 	public void testCpsEdge() {
 	public void testCpsEdge() {
 		CpsNode node1 = new CpsNode("Node1");
 		CpsNode node1 = new CpsNode("Node1");
@@ -164,6 +171,9 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("Tags Empty", !edge1.getTags().isEmpty());
 		assertTrue("Tags Empty", !edge1.getTags().isEmpty());
 	}
 	}
 
 
+	/**
+	 * Tests for HolonElement Class.
+	 */
 	@Test
 	@Test
 	public void testHolonElement() {
 	public void testHolonElement() {
 		HolonElement ele1 = new HolonElement("TV", 2, -20);
 		HolonElement ele1 = new HolonElement("TV", 2, -20);
@@ -186,6 +196,9 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("SAV not correct", ele3.getSav().equals("CVS"));
 		assertTrue("SAV not correct", ele3.getSav().equals("CVS"));
 	}
 	}
 
 
+	/**
+	 * Tests for Position Class.
+	 */
 	@Test
 	@Test
 	public void testPosition() {
 	public void testPosition() {
 		Position pos1 = new Position(100, 200);
 		Position pos1 = new Position(100, 200);
@@ -196,6 +209,9 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("not (-1,-1)", pos2.x == -1 && pos2.y == -1);
 		assertTrue("not (-1,-1)", pos2.x == -1 && pos2.y == -1);
 	}
 	}
 
 
+	/**
+	 * Tests for SubNet Class.
+	 */
 	@Test
 	@Test
 	public void testSubNet() {
 	public void testSubNet() {
 		PraktikumHolonsAdapter adapter = new PraktikumHolonsAdapter();
 		PraktikumHolonsAdapter adapter = new PraktikumHolonsAdapter();

+ 5 - 2
src/tests/PraktikumHolonsTestGlobalController.java

@@ -14,7 +14,7 @@ public class PraktikumHolonsTestGlobalController {
 	protected Model model;
 	protected Model model;
 	protected GlobalController controller;
 	protected GlobalController controller;
 
 
-	
+	 
 	@Before
 	@Before
 	public void setUp() {
 	public void setUp() {
 		model = new Model();
 		model = new Model();
@@ -22,7 +22,10 @@ public class PraktikumHolonsTestGlobalController {
 
 
 	}
 	}
 	
 	
-	@Test
+	/**
+	 * Test the methods for Global attributes.
+	 */
+	@Test 
 	public void testGlobalControls() {
 	public void testGlobalControls() {
 		int prevScale = controller.getScale();
 		int prevScale = controller.getScale();
 		int prevScaleDiv2 = controller.getScaleDiv2();
 		int prevScaleDiv2 = controller.getScaleDiv2();

+ 1 - 1
src/tests/PraktikumHolonsTestLoadAndStoreController.java

@@ -43,7 +43,7 @@ public class PraktikumHolonsTestLoadAndStoreController {
 	protected PraktikumHolonsAdapter adapter;
 	protected PraktikumHolonsAdapter adapter;
 	protected Model model;
 	protected Model model;
 	protected MultiPurposeController mp;
 	protected MultiPurposeController mp;
-	protected CategoryController cg;
+	protected CategoryController cg; 
 	protected CanvasController cvs;
 	protected CanvasController cvs;
 	protected ObjectController obj;
 	protected ObjectController obj;
 	protected StoreController storeController;
 	protected StoreController storeController;

+ 13 - 22
src/tests/PraktikumHolonsTestObjectController.java

@@ -107,40 +107,31 @@ public class PraktikumHolonsTestObjectController {
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			for (int i = 0; i < 27; i++) {
 			for (int i = 0; i < 27; i++) {
 				controller.addNewElementIntoCanvasObject(cps.getID(), adapter.generate(i), 1, -100);
 				controller.addNewElementIntoCanvasObject(cps.getID(), adapter.generate(i), 1, -100);
-				assertTrue("Element:" + adapter.generate(i) + " was not Created", mp
-						.searchEle((HolonObject) mp.searchByID(cps.getID()), adapter.generate(i)) != null);
+				assertTrue("Element:" + adapter.generate(i) + " was not Created",
+						mp.searchEle((HolonObject) mp.searchByID(cps.getID()), adapter.generate(i)) != null);
 			}
 			}
-			assertTrue("Element:B was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);
-			assertTrue("Element:D was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "D") != null);
-			assertTrue("Element:F was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "F") != null);
-			assertTrue("Element:G was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "G") != null);
-			assertTrue("Element:H was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "H") != null);
-			assertTrue("Element:I was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "I") != null);
-			assertTrue("Element:B was not Found", mp
-					.searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);	
+			assertTrue("Element:B was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);
+			assertTrue("Element:D was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "D") != null);
+			assertTrue("Element:F was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "F") != null);
+			assertTrue("Element:G was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "G") != null);
+			assertTrue("Element:H was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "H") != null);
+			assertTrue("Element:I was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "I") != null);
+			assertTrue("Element:B was not Found", mp.searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);
 		}
 		}
-		
+
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			int size = model.getSelectedCpsObjects().size();
 			int size = model.getSelectedCpsObjects().size();
 			controller.addSelectedObject(cps);
 			controller.addSelectedObject(cps);
-			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size +1);
+			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size + 1);
 		}
 		}
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			System.out.println(model.getSelectedCpsObjects().size());
 			System.out.println(model.getSelectedCpsObjects().size());
 			int size = model.getSelectedCpsObjects().size();
 			int size = model.getSelectedCpsObjects().size();
 			controller.deleteSelectedObject(cps);
 			controller.deleteSelectedObject(cps);
-			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size -1);
+			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size - 1);
 			assertTrue("Object was not unselected", !model.getSelectedCpsObjects().contains(cps));
 			assertTrue("Object was not unselected", !model.getSelectedCpsObjects().contains(cps));
-			
+
 		}
 		}
 	}
 	}
-	
-	
 
 
 }
 }

+ 1 - 1
src/tests/PraktikumHolonsTestSuite.java

@@ -8,7 +8,7 @@ public class PraktikumHolonsTestSuite {
 
 
 
 
 	/**
 	/**
-	 * Test Suite.
+	 * Test Suite. 
 	 * 
 	 * 
 	 * @return suite
 	 * @return suite
 	 */
 	 */

+ 1 - 1
src/ui/controller/CategoryController.java

@@ -40,7 +40,7 @@ public class CategoryController {
 	/**
 	/**
 	 * Adds Category into Model if a Category with the same name already exists
 	 * Adds Category into Model if a Category with the same name already exists
 	 * Add Category_+1
 	 * Add Category_+1
-	 * 
+	 *  
 	 * @param toAdd
 	 * @param toAdd
 	 *            neue Kategorie
 	 *            neue Kategorie
 	 */
 	 */

+ 1 - 1
src/ui/view/GUI.java

@@ -909,7 +909,7 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			@Override
 			public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
 			public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
 					boolean leaf, int row, boolean hasFocus) {
 					boolean leaf, int row, boolean hasFocus) {
-				JLabel label = new JLabel();
+				JLabel label = new JLabel(); 
 				Image imgR = null;
 				Image imgR = null;
 				if (leaf) {
 				if (leaf) {
 					for (Category cat : model.getCategories()) {
 					for (Category cat : model.getCategories()) {