فهرست منبع

new API class

dominik.rieder 8 سال پیش
والد
کامیت
857e8ba88a
2فایلهای تغییر یافته به همراه66 افزوده شده و 0 حذف شده
  1. 62 0
      src/API/API.java
  2. 4 0
      src/ui/controller/SimulationManager.java

+ 62 - 0
src/API/API.java

@@ -0,0 +1,62 @@
+package API;
+
+import java.awt.Color;
+import java.util.ArrayList;
+
+import classes.CpsObject;
+import classes.subNet;
+import ui.controller.Control;
+import ui.controller.SimulationManager;
+
+public class API {
+	private Control controller;
+	private SimulationManager simManager;
+	
+	public API(Control cont){
+		this.controller = cont;
+		this.simManager = controller.getSimManager();
+	}
+	
+	/**
+	 * a SubNet contains all Components
+	 * @return all SubNets on Canvas
+	 */
+	public ArrayList<subNet> getSubNets(){
+		simManager.searchForSubNets();
+		return simManager.getSubNets();
+	}
+	
+	/**
+	 * 
+	 * @return all Objects on Canvas in no specific order
+	 */
+	public ArrayList<CpsObject> getAllObjectsOnCanvas(){
+
+		return controller.getModel().getObjectsOnCanvas();
+	}
+	
+	/**
+	 * prints a given text on the console
+	 * @param text
+	 */
+	public void consolePrint(String text){
+		controller.addTextToConsole(text);
+	}
+	
+	/**
+	 * prints a given text on the console with more details
+	 * @param text: the text that will be printed
+	 * @param color: the color the text will have
+	 * @param p: font size
+	 * @param bold: true or false
+	 * @param italic: true or false
+	 * @param nl: new line after text
+	 */
+	public void consolePrint(String text, Color color, int p, boolean bold, boolean italic, boolean nl){
+		controller.addTextToConsole(text, color, p, bold, italic, nl);
+	}
+	
+	public void setBorderColorForObject(CpsObject toChange, Color color){
+	}
+	
+}

+ 4 - 0
src/ui/controller/SimulationManager.java

@@ -387,5 +387,9 @@ public class SimulationManager {
 		copyObjects(model.getObjectsOnCanvas());
 	}
 	
+	public ArrayList<subNet> getSubNets(){
+		return subNets;
+	}
+	
 	
 }