|
@@ -0,0 +1,47 @@
|
|
|
+Create a new Java Project and add the jars "CpsClassesModelController" and "CpsAlgorithm" to your Build Path.
|
|
|
+Then create a new Package and create a new Class.
|
|
|
+That Class has to implement the Interface "cpsAlgorithm".
|
|
|
+Your Class then has to implement the method RunAlgorithm.
|
|
|
+This Method gets a Model and the Controller.
|
|
|
+You can access all Data via the Model.
|
|
|
+The Controller has several Methods you can use as well.
|
|
|
+
|
|
|
+Your Class should look something like this:
|
|
|
+
|
|
|
+package projectPackage;
|
|
|
+
|
|
|
+import java.awt.Color;
|
|
|
+import classes.HolonObject;
|
|
|
+import classes.SubNet;
|
|
|
+import cpsAlgorithm.CpsAlgorithm;
|
|
|
+import ui.controller.Control;
|
|
|
+import ui.model.Model;
|
|
|
+
|
|
|
+public class Test implements CpsAlgorithm {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void RunAlgorithm(Model model, Control control) {
|
|
|
+ Color c = Color.RED;
|
|
|
+ for (SubNet s : control.getSimManager().getSubNets()) {
|
|
|
+ if (c == Color.RED) {
|
|
|
+ c = Color.CYAN;
|
|
|
+ } else if (c == Color.CYAN) {
|
|
|
+ c = Color.PINK;
|
|
|
+ } else {
|
|
|
+ c = Color.RED;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (HolonObject cps : s.getObjects()) {
|
|
|
+ cps.setBorderColor(c);
|
|
|
+ controller.addTextToConsole(cps.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+Then in the program click on the Algorithm Button in the Simulation Menu.
|
|
|
+Go to your project and select the folder where your .java files are.
|
|
|
+Then you can Select the Algorithm you want to use in the ComboBox.
|
|
|
+Then Click on the Simulation Radio Button to switch to Simulation Mode.
|
|
|
+
|
|
|
+Your algorithm will now be used.
|