20 MonkeyBrainsDemo_SteeringBehaviors/nbproject/project.properties
... ...
@@ -1,7 +1,11 @@
1  
-application.title=MyGame
2  
-application.vendor=MyCompany
  1
+annotation.processing.enabled=true
  2
+annotation.processing.enabled.in.editor=false
  3
+annotation.processing.processors.list=
  4
+annotation.processing.run.all.processors=true
  5
+application.title=Steer Demos
  6
+application.vendor=Jes\u00fas Mart\u00edn Berlanga
3 7
 assets.jar.name=assets.jar
4  
-assets.excludes=**/*.j3odata,**/*.mesh,**/*.skeleton,**/*.mesh\.xml,**/*.skeleton\.xml,**/*.scene,**/*.material,**/*.obj,**/*.mtl,**/*.3ds,**/*.dae,**/*.blend,**/*.blend*[0-9]
  8
+assets.excludes=**/*.j3odata,**/*.mesh,**/*.skeleton,**/*.mesh.xml,**/*.skeleton.xml,**/*.scene,**/*.material,**/*.obj,**/*.mtl,**/*.3ds,**/*.dae,**/*.blend,**/*.blend*[0-9]
5 9
 assets.folder.name=assets
6 10
 assets.compress=true
7 11
 build.classes.dir=${build.dir}/classes
@@ -36,6 +40,8 @@ javac.classpath=\
36 40
 # Space-separated list of extra javac options
37 41
 javac.compilerargs=
38 42
 javac.deprecation=false
  43
+javac.processorpath=\
  44
+    ${javac.classpath}
39 45
 javac.source=1.5
40 46
 javac.target=1.5
41 47
 javac.test.classpath=\
@@ -58,12 +64,14 @@ jnlp.descriptor=application
58 64
 jnlp.enabled=false
59 65
 jnlp.offline-allowed=false
60 66
 jnlp.signed=false
61  
-main.class=mygame.Main
  67
+main.class=steeringDemos.demos.DemosLauncher
62 68
 meta.inf.dir=${src.dir}/META-INF
63 69
 manifest.file=MANIFEST.MF
  70
+mkdist.disabled=false
  71
+obfuscate.options=-keep public class * extends com.jme3.app.Application{public *;}\n-keep public class * extends com.jme3.system.JmeSystemDelegate{public *;}\n-keep public class * implements com.jme3.renderer.Renderer{public *;}\n-keep public class * implements com.jme3.asset.AssetLoader{public *;}\n-keep public class * implements com.jme3.asset.AssetLocator{public *;}\n-keep public class * implements de.lessvoid.nifty.screen.ScreenController{public *;}\n-dontwarn\n-dontnote\n
64 72
 platform.active=default_platform
65  
-project.AgentFramework=../JMEAI
66  
-reference.AgentFramework.jar=${project.AgentFramework}/dist/MyGame.jar
  73
+project.AgentFramework=../../JMEAI
  74
+reference.AgentFramework.jar=${project.AgentFramework}/dist/MonkeyBrains.jar
67 75
 run.classpath=\
68 76
     ${javac.classpath}:\
69 77
     ${build.classes.dir}:\
150 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/AlignmentDemo.java
... ...
@@ -0,0 +1,150 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.steering.AlignmentBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  18
+import com.jme3.math.FastMath;
  19
+import java.util.ArrayList;
  20
+
  21
+import steeringDemos.control.CustomSteerControl;
  22
+
  23
+import java.util.List;
  24
+import java.util.Arrays;
  25
+
  26
+/**
  27
+ * AI Steer Test - Testing the cohesion behaviour
  28
+ *
  29
+ * @author Jesús Martín Berlanga
  30
+ * @version 1.0
  31
+ */
  32
+public class AlignmentDemo extends SimpleApplication {
  33
+
  34
+    private Game game = Game.getInstance(); //creating game
  35
+    //TEST SETTINGS - START
  36
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  37
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  38
+
  39
+    private final int NUMBER_NEIGHBOURS = 250;
  40
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  41
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  42
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  43
+    private final float NEIGHBOURS_MASS = 50;
  44
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  45
+    //TEST SETTINGS - END
  46
+
  47
+    public static void main(String[] args) {
  48
+        AlignmentDemo app = new AlignmentDemo();
  49
+        app.start();
  50
+    }
  51
+
  52
+    @Override
  53
+    public void simpleInitApp() {
  54
+        //defining rootNode for game processing
  55
+        game.setRootNode(rootNode);
  56
+
  57
+        game.setInputManager(inputManager);
  58
+        game.setGameControl(new CustomSteerControl(50f));
  59
+        game.getGameControl().loadInputManagerMapping();
  60
+
  61
+        this.setupCamera();
  62
+
  63
+        Vector3f[] spawnArea = null;
  64
+
  65
+        Agent[] boids = new Agent[this.NUMBER_NEIGHBOURS];
  66
+
  67
+        
  68
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  69
+            boids[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  70
+            boids[i].setRadius(0.1f);
  71
+            game.addAgent(boids[i]); //Add the neighbours to the game
  72
+            this.setStats(boids[i], this.NEIGHBOURS_MOVE_SPEED,
  73
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  74
+                    this.NEIGHBOURS_MAX_FORCE);
  75
+            game.getGameControl().spawn(boids[i], spawnArea);
  76
+        }
  77
+
  78
+        List<Agent> obstacles = new ArrayList<Agent>();
  79
+        obstacles.addAll(Arrays.asList(boids));
  80
+
  81
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[boids.length];
  82
+
  83
+        SeparationBehaviour[] separation = new SeparationBehaviour[boids.length];
  84
+        AlignmentBehaviour[] alignment = new AlignmentBehaviour[boids.length];
  85
+        WanderBehaviour[] wander = new WanderBehaviour[boids.length];
  86
+
  87
+        for (int i = 0; i < boids.length; i++) {
  88
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(boids[i]);
  89
+
  90
+
  91
+            separation[i] = new SeparationBehaviour(boids[i], obstacles);
  92
+            alignment[i] = new AlignmentBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4);
  93
+            wander[i] = new WanderBehaviour(boids[i]);
  94
+            wander[i].setArea(Vector3f.ZERO, new Vector3f(75, 75, 75));
  95
+
  96
+            separation[i].setupStrengthControl(0.85f);
  97
+            alignment[i].setupStrengthControl(2.15f);
  98
+            wander[i].setupStrengthControl(0.35f);
  99
+            
  100
+
  101
+            CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(boids[i]);
  102
+
  103
+           steer.addSteerBehaviour(alignment[i]);
  104
+           steer.addSteerBehaviour(separation[i]);
  105
+           steer.addSteerBehaviour(wander[i]);
  106
+           neighboursMainBehaviour[i].addBehaviour(steer);
  107
+            
  108
+           boids[i].setMainBehaviour(neighboursMainBehaviour[i]);
  109
+             
  110
+        }
  111
+
  112
+        game.start();
  113
+    }
  114
+
  115
+    private void setupCamera() {
  116
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  117
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  118
+        getFlyByCamera().setMoveSpeed(50);
  119
+
  120
+        flyCam.setDragToRotate(true);
  121
+        //flyCam.setEnabled(false);  
  122
+    }
  123
+
  124
+    //Create an agent with a name and a color
  125
+    private Agent createBoid(String name, ColorRGBA color) {
  126
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  127
+        boidSpatial.setLocalScale(0.1f); //Resize
  128
+
  129
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);
  130
+        mat.setColor("Color", color);
  131
+        boidSpatial.setMaterial(mat);
  132
+
  133
+        return new Agent(name, boidSpatial);
  134
+    }
  135
+
  136
+    //Setup the stats for an agent
  137
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  138
+            float mass, float maxForce) {
  139
+
  140
+        myAgent.setMoveSpeed(moveSpeed);
  141
+        myAgent.setRotationSpeed(rotationSpeed);
  142
+        myAgent.setMass(mass);
  143
+        myAgent.setMaxForce(maxForce);
  144
+    }
  145
+
  146
+    @Override
  147
+    public void simpleUpdate(float tpf) {
  148
+        game.update(tpf);
  149
+    }
  150
+}
182 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/ArriveDemo.java
... ...
@@ -0,0 +1,182 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  7
+import com.jme3.ai.agents.behaviours.npc.steering.ArriveBehaviour;
  8
+import com.jme3.ai.agents.util.control.Game;
  9
+import com.jme3.app.SimpleApplication;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.math.ColorRGBA;
  12
+import com.jme3.math.Vector3f;
  13
+import com.jme3.scene.Geometry;
  14
+import com.jme3.scene.Spatial;
  15
+import com.jme3.scene.shape.Sphere;
  16
+import steeringDemos.control.CustomSteerControl;
  17
+
  18
+/**
  19
+ * Demo for ArriveBehaviour
  20
+ *
  21
+ * @author Jesús Martín Berlanga
  22
+ */
  23
+public class ArriveDemo extends SimpleApplication {
  24
+    
  25
+    private Game game = Game.getInstance(); //creating game
  26
+    //TEST SETTINGS - START
  27
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  28
+    private final String MATERIAL_1 = "Common/MatDefs/Misc/Unshaded.j3md";
  29
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  30
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  31
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  32
+    private final float NEIGHBOURS_MASS = 50;
  33
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  34
+    //TEST SETTINGS - END
  35
+    private Agent[] agents = new Agent[3];
  36
+    private Agent target;
  37
+    private ArriveBehaviour[] arrive;
  38
+    private int[] upadtes = new int[3];
  39
+    
  40
+    public static void main(String[] args) {
  41
+        ArriveDemo app = new ArriveDemo();
  42
+        app.start();
  43
+    }
  44
+    
  45
+    @Override
  46
+    public void simpleInitApp() {
  47
+        game.setRootNode(rootNode);
  48
+        game.setInputManager(inputManager);
  49
+        game.setGameControl(new CustomSteerControl(50f));
  50
+        game.getGameControl().loadInputManagerMapping();
  51
+        this.setupCamera();
  52
+        
  53
+        this.target = this.createSphere("target", ColorRGBA.Red);
  54
+        game.addAgent(target);
  55
+        game.getGameControl().spawn(target, new Vector3f());
  56
+        
  57
+        for (int i = 0; i < this.agents.length; i++) {
  58
+            agents[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  59
+            agents[i].setRadius(0.1f);
  60
+            game.addAgent(agents[i]); //Add the neighbours to the game
  61
+            this.setStats(agents[i], this.NEIGHBOURS_MOVE_SPEED,
  62
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  63
+                    this.NEIGHBOURS_MAX_FORCE);
  64
+        }
  65
+        
  66
+        game.getGameControl().spawn(agents[0], new Vector3f(-10, 0, 0));
  67
+        game.getGameControl().spawn(agents[1], new Vector3f(8, 0, 0));
  68
+        game.getGameControl().spawn(agents[2], new Vector3f(0, 13, 2));
  69
+        
  70
+        arrive = new ArriveBehaviour[3];
  71
+        
  72
+        SimpleMainBehaviour main0 = new SimpleMainBehaviour(agents[0]);
  73
+        SimpleMainBehaviour main1 = new SimpleMainBehaviour(agents[1]);
  74
+        SimpleMainBehaviour main2 = new SimpleMainBehaviour(agents[2]);
  75
+        
  76
+        arrive[0] = new ArriveBehaviour(agents[0], target, 5f, 0.0035f);
  77
+        arrive[1] = new ArriveBehaviour(agents[1], target, 3f, 0.01f);
  78
+        arrive[2] = new ArriveBehaviour(agents[2], target);
  79
+        arrive[2].getSlow().setUnitIncrementSlow(0.0085f);
  80
+        
  81
+        main0.addBehaviour(arrive[0]);
  82
+        main1.addBehaviour(arrive[1]);
  83
+        main2.addBehaviour(arrive[2]);
  84
+        
  85
+        agents[0].setMainBehaviour(main0);
  86
+        agents[1].setMainBehaviour(main1);
  87
+        agents[2].setMainBehaviour(main2);
  88
+        
  89
+        SimpleMainBehaviour targetMain = new SimpleMainBehaviour(target);
  90
+        target.setMainBehaviour(targetMain);
  91
+        
  92
+        game.start();
  93
+    }
  94
+    
  95
+    private void setupCamera() {
  96
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  97
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  98
+        getFlyByCamera().setMoveSpeed(50);
  99
+        
  100
+        flyCam.setDragToRotate(true);
  101
+        //flyCam.setEnabled(false);
  102
+    }
  103
+    
  104
+    //Create an agent with a name and a color
  105
+    private Agent createBoid(String name, ColorRGBA color) {
  106
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  107
+        boidSpatial.setLocalScale(0.1f); //Resize
  108
+        
  109
+        Material mat = new Material(assetManager, this.MATERIAL_1);
  110
+        mat.setColor("Color", color);
  111
+        boidSpatial.setMaterial(mat);
  112
+        
  113
+        return new Agent(name, boidSpatial);
  114
+    }
  115
+    
  116
+    //Create a sphere
  117
+    private Agent createSphere(String name, ColorRGBA color) {
  118
+        Sphere sphere = new Sphere(10, 10, 0.25f);
  119
+        Geometry sphereG = new Geometry("Sphere Geometry", sphere);
  120
+        Spatial spatial = sphereG;
  121
+        
  122
+        spatial.setLocalScale(0.1f); //Resize0
  123
+        
  124
+        Material mat = new Material(assetManager, this.MATERIAL_1);
  125
+        mat.setColor("Color", color);
  126
+        spatial.setMaterial(mat);
  127
+        
  128
+        return new Agent(name, spatial);
  129
+    }
  130
+    
  131
+    //Setup the stats for an agent
  132
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  133
+            float mass, float maxForce) {
  134
+        
  135
+        myAgent.setMoveSpeed(moveSpeed);
  136
+        myAgent.setRotationSpeed(rotationSpeed);
  137
+        myAgent.setMass(mass);
  138
+        myAgent.setMaxForce(maxForce);
  139
+    }
  140
+    
  141
+    @Override
  142
+    public void simpleUpdate(float tpf) {
  143
+        game.update(tpf);
  144
+        
  145
+        for(int i = 0; i < this.arrive.length; i++)
  146
+        {
  147
+            if(this.arrive[i].getFreezeTheMovement() == true)
  148
+            {
  149
+                if( this.upadtes[i] > 60)
  150
+                {
  151
+                    Vector3f resetPosition;
  152
+                    
  153
+                    switch(i)
  154
+                    {
  155
+                        case 0:
  156
+                            resetPosition = new Vector3f(-10, 0, 0);
  157
+                            break;
  158
+                            
  159
+                        case 1:
  160
+                            resetPosition = new Vector3f(8, 0, 0);
  161
+                            break;
  162
+                            
  163
+                        case 2:
  164
+                            resetPosition = new Vector3f(0, 13, 2);
  165
+                            break;
  166
+                            
  167
+                        default:
  168
+                            resetPosition = new Vector3f();
  169
+                    }
  170
+                    
  171
+                    this.agents[i].setLocalTranslation(resetPosition);
  172
+                    
  173
+                    this.arrive[i].getSlow().resetSlow();
  174
+                    this.arrive[i].setFreezeTheMovement(false);
  175
+                    this.upadtes[i] = 0;
  176
+                }
  177
+                else
  178
+                    this.upadtes[i]++;
  179
+            }
  180
+        }
  181
+    }
  182
+}
155 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/CohesionAndAlignmentDemo.java
... ...
@@ -0,0 +1,155 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.steering.AlignmentBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.CohesionBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  18
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  19
+import com.jme3.math.FastMath;
  20
+import java.util.ArrayList;
  21
+
  22
+import steeringDemos.control.CustomSteerControl;
  23
+
  24
+import java.util.List;
  25
+import java.util.Arrays;
  26
+
  27
+/**
  28
+ * AI Steer Test - Testing the cohesion and the alignment behaviours
  29
+ *
  30
+ * @author Jesús Martín Berlanga
  31
+ * @version 1.0
  32
+ */
  33
+public class CohesionAndAlignmentDemo extends SimpleApplication {
  34
+
  35
+    private Game game = Game.getInstance(); //creating game
  36
+    //TEST SETTINGS - START
  37
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  38
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  39
+
  40
+    private final int NUMBER_NEIGHBOURS = 250;
  41
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  42
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  43
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  44
+    private final float NEIGHBOURS_MASS = 50;
  45
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  46
+    //TEST SETTINGS - END
  47
+
  48
+    public static void main(String[] args) {
  49
+        CohesionAndAlignmentDemo app = new CohesionAndAlignmentDemo();
  50
+        app.start();
  51
+    }
  52
+
  53
+    @Override
  54
+    public void simpleInitApp() {
  55
+        //defining rootNode for game processing
  56
+        game.setRootNode(rootNode);
  57
+
  58
+        game.setInputManager(inputManager);
  59
+        game.setGameControl(new CustomSteerControl(50f));
  60
+        game.getGameControl().loadInputManagerMapping();
  61
+
  62
+        this.setupCamera();
  63
+
  64
+        Vector3f[] spawnArea = null;
  65
+
  66
+        Agent[] boids = new Agent[this.NUMBER_NEIGHBOURS];
  67
+
  68
+        
  69
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  70
+            boids[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  71
+            boids[i].setRadius(0.1f);
  72
+            game.addAgent(boids[i]); //Add the neighbours to the game
  73
+            this.setStats(boids[i], this.NEIGHBOURS_MOVE_SPEED,
  74
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  75
+                    this.NEIGHBOURS_MAX_FORCE);
  76
+            game.getGameControl().spawn(boids[i], spawnArea);
  77
+        }
  78
+
  79
+        List<Agent> obstacles = new ArrayList<Agent>();
  80
+        obstacles.addAll(Arrays.asList(boids));
  81
+
  82
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[boids.length];
  83
+
  84
+        SeparationBehaviour[] separation = new SeparationBehaviour[boids.length];
  85
+        CohesionBehaviour[] cohesion = new CohesionBehaviour[boids.length];
  86
+        AlignmentBehaviour[] alignment = new AlignmentBehaviour[boids.length];
  87
+        WanderBehaviour[] wander = new WanderBehaviour[boids.length];
  88
+
  89
+        for (int i = 0; i < boids.length; i++) {
  90
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(boids[i]);
  91
+
  92
+
  93
+            separation[i] = new SeparationBehaviour(boids[i], obstacles);
  94
+            cohesion[i] = new CohesionBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4);
  95
+            alignment[i] = new AlignmentBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4.2f);
  96
+            wander[i] = new WanderBehaviour(boids[i]);
  97
+            wander[i].setArea(Vector3f.ZERO, new Vector3f(75, 75, 75));
  98
+
  99
+            separation[i].setupStrengthControl(0.85f);
  100
+            cohesion[i].setupStrengthControl(2.15f);
  101
+            alignment[i].setupStrengthControl(0.25f);
  102
+            wander[i].setupStrengthControl(0.35f);
  103
+            
  104
+
  105
+            CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(boids[i]);
  106
+
  107
+           steer.addSteerBehaviour(cohesion[i]);
  108
+           steer.addSteerBehaviour(alignment[i]);
  109
+           steer.addSteerBehaviour(separation[i]);
  110
+           steer.addSteerBehaviour(wander[i]);
  111
+           neighboursMainBehaviour[i].addBehaviour(steer);
  112
+            
  113
+           boids[i].setMainBehaviour(neighboursMainBehaviour[i]);
  114
+             
  115
+        }
  116
+
  117
+        game.start();
  118
+    }
  119
+
  120
+    private void setupCamera() {
  121
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  122
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  123
+        getFlyByCamera().setMoveSpeed(50);
  124
+
  125
+        flyCam.setDragToRotate(true);
  126
+        //flyCam.setEnabled(false);  
  127
+    }
  128
+
  129
+    //Create an agent with a name and a color
  130
+    private Agent createBoid(String name, ColorRGBA color) {
  131
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  132
+        boidSpatial.setLocalScale(0.1f); //Resize
  133
+
  134
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);
  135
+        mat.setColor("Color", color);
  136
+        boidSpatial.setMaterial(mat);
  137
+
  138
+        return new Agent(name, boidSpatial);
  139
+    }
  140
+
  141
+    //Setup the stats for an agent
  142
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  143
+            float mass, float maxForce) {
  144
+
  145
+        myAgent.setMoveSpeed(moveSpeed);
  146
+        myAgent.setRotationSpeed(rotationSpeed);
  147
+        myAgent.setMass(mass);
  148
+        myAgent.setMaxForce(maxForce);
  149
+    }
  150
+
  151
+    @Override
  152
+    public void simpleUpdate(float tpf) {
  153
+        game.update(tpf);
  154
+    }
  155
+}
150 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/CohesionDemo.java
... ...
@@ -0,0 +1,150 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+import com.jme3.ai.agents.Agent;
  6
+import com.jme3.ai.agents.util.control.Game;
  7
+import com.jme3.app.SimpleApplication;
  8
+import com.jme3.math.ColorRGBA;
  9
+import com.jme3.math.Vector3f;
  10
+import com.jme3.material.Material;
  11
+import com.jme3.scene.Spatial;
  12
+
  13
+import com.jme3.ai.agents.behaviours.npc.steering.SeparationBehaviour;
  14
+import com.jme3.ai.agents.behaviours.npc.SimpleMainBehaviour;
  15
+import com.jme3.ai.agents.behaviours.npc.steering.CohesionBehaviour;
  16
+import com.jme3.ai.agents.behaviours.npc.steering.CompoundSteeringBehaviour;
  17
+import com.jme3.ai.agents.behaviours.npc.steering.WanderBehaviour;
  18
+import com.jme3.math.FastMath;
  19
+import java.util.ArrayList;
  20
+
  21
+import steeringDemos.control.CustomSteerControl;
  22
+
  23
+import java.util.List;
  24
+import java.util.Arrays;
  25
+
  26
+/**
  27
+ * AI Steer Test - Testing the cohesion behaviour
  28
+ *
  29
+ * @author Jesús Martín Berlanga
  30
+ * @version 1.0
  31
+ */
  32
+public class CohesionDemo extends SimpleApplication {
  33
+
  34
+    private Game game = Game.getInstance(); //creating game
  35
+    //TEST SETTINGS - START
  36
+    private final String BOID_MODEL_NAME = "Models/boid.j3o";
  37
+    private final String BOID_MATERIAL_NAME = "Common/MatDefs/Misc/Unshaded.j3md";
  38
+
  39
+    private final int NUMBER_NEIGHBOURS = 250;
  40
+    private final ColorRGBA NEIGHBOURS_COLOR = ColorRGBA.Blue;
  41
+    private final float NEIGHBOURS_MOVE_SPEED = 0.96f;
  42
+    private final float NEIGHBOURS_ROTATION_SPEED = 30f;
  43
+    private final float NEIGHBOURS_MASS = 50;
  44
+    private final float NEIGHBOURS_MAX_FORCE = 20;
  45
+    //TEST SETTINGS - END
  46
+
  47
+    public static void main(String[] args) {
  48
+        CohesionDemo app = new CohesionDemo();
  49
+        app.start();
  50
+    }
  51
+
  52
+    @Override
  53
+    public void simpleInitApp() {
  54
+        //defining rootNode for game processing
  55
+        game.setRootNode(rootNode);
  56
+
  57
+        game.setInputManager(inputManager);
  58
+        game.setGameControl(new CustomSteerControl(50f));
  59
+        game.getGameControl().loadInputManagerMapping();
  60
+
  61
+        this.setupCamera();
  62
+
  63
+        Vector3f[] spawnArea = null;
  64
+
  65
+        Agent[] boids = new Agent[this.NUMBER_NEIGHBOURS];
  66
+
  67
+        
  68
+        for (int i = 0; i < this.NUMBER_NEIGHBOURS; i++) {
  69
+            boids[i] = this.createBoid("boid " + i, this.NEIGHBOURS_COLOR);
  70
+            boids[i].setRadius(0.1f);
  71
+            game.addAgent(boids[i]); //Add the neighbours to the game
  72
+            this.setStats(boids[i], this.NEIGHBOURS_MOVE_SPEED,
  73
+                    this.NEIGHBOURS_ROTATION_SPEED, this.NEIGHBOURS_MASS,
  74
+                    this.NEIGHBOURS_MAX_FORCE);
  75
+            game.getGameControl().spawn(boids[i], spawnArea);
  76
+        }
  77
+
  78
+        List<Agent> obstacles = new ArrayList<Agent>();
  79
+        obstacles.addAll(Arrays.asList(boids));
  80
+
  81
+        SimpleMainBehaviour[] neighboursMainBehaviour = new SimpleMainBehaviour[boids.length];
  82
+
  83
+        SeparationBehaviour[] separation = new SeparationBehaviour[boids.length];
  84
+        CohesionBehaviour[] cohesion = new CohesionBehaviour[boids.length];
  85
+        WanderBehaviour[] wander = new WanderBehaviour[boids.length];
  86
+
  87
+        for (int i = 0; i < boids.length; i++) {
  88
+            neighboursMainBehaviour[i] = new SimpleMainBehaviour(boids[i]);
  89
+
  90
+
  91
+            separation[i] = new SeparationBehaviour(boids[i], obstacles);
  92
+            cohesion[i] = new CohesionBehaviour(boids[i], obstacles, 5f,  FastMath.PI / 4);
  93
+            wander[i] = new WanderBehaviour(boids[i]);
  94
+            wander[i].setArea(Vector3f.ZERO, new Vector3f(75, 75, 75));
  95
+
  96
+            separation[i].setupStrengthControl(0.85f);
  97
+            cohesion[i].setupStrengthControl(2.15f);
  98
+            wander[i].setupStrengthControl(0.35f);
  99
+            
  100
+
  101
+            CompoundSteeringBehaviour steer = new CompoundSteeringBehaviour(boids[i]);
  102
+
  103
+           steer.addSteerBehaviour(cohesion[i]);
  104
+           steer.addSteerBehaviour(separation[i]);
  105
+           steer.addSteerBehaviour(wander[i]);
  106
+           neighboursMainBehaviour[i].addBehaviour(steer);
  107
+            
  108
+           boids[i].setMainBehaviour(neighboursMainBehaviour[i]);
  109
+             
  110
+        }
  111
+
  112
+        game.start();
  113
+    }
  114
+
  115
+    private void setupCamera() {
  116
+        getCamera().setLocation(new Vector3f(0, 20, 0));
  117
+        getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_X);
  118
+        getFlyByCamera().setMoveSpeed(50);
  119
+
  120
+        flyCam.setDragToRotate(true);
  121
+        //flyCam.setEnabled(false);  
  122
+    }
  123
+
  124
+    //Create an agent with a name and a color
  125
+    private Agent createBoid(String name, ColorRGBA color) {
  126
+        Spatial boidSpatial = assetManager.loadModel(this.BOID_MODEL_NAME);
  127
+        boidSpatial.setLocalScale(0.1f); //Resize
  128
+
  129
+        Material mat = new Material(assetManager, this.BOID_MATERIAL_NAME);
  130
+        mat.setColor("Color", color);
  131
+        boidSpatial.setMaterial(mat);
  132
+
  133
+        return new Agent(name, boidSpatial);
  134
+    }
  135
+
  136
+    //Setup the stats for an agent
  137
+    private void setStats(Agent myAgent, float moveSpeed, float rotationSpeed,
  138
+            float mass, float maxForce) {
  139
+
  140
+        myAgent.setMoveSpeed(moveSpeed);
  141
+        myAgent.setRotationSpeed(rotationSpeed);
  142
+        myAgent.setMass(mass);
  143
+        myAgent.setMaxForce(maxForce);
  144
+    }
  145
+
  146
+    @Override
  147
+    public void simpleUpdate(float tpf) {
  148
+        game.update(tpf);
  149
+    }
  150
+}
141 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/DemosLauncher.form
... ...
@@ -0,0 +1,141 @@
  1
+<?xml version="1.0" encoding="UTF-8" ?>
  2
+
  3
+<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
  4
+  <Properties>
  5
+    <Property name="defaultCloseOperation" type="int" value="2"/>
  6
+    <Property name="resizable" type="boolean" value="false"/>
  7
+  </Properties>
  8
+  <SyntheticProperties>
  9
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
  10
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
  11
+  </SyntheticProperties>
  12
+  <AuxValues>
  13
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
  14
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
  15
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
  16
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
  17
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
  18
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
  19
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
  20
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
  21
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
  22
+  </AuxValues>
  23
+
  24
+  <Layout>
  25
+    <DimensionLayout dim="0">
  26
+      <Group type="103" groupAlignment="0" attributes="0">
  27
+          <Group type="102" alignment="0" attributes="0">
  28
+              <EmptySpace max="-2" attributes="0"/>
  29
+              <Component id="jPanel1" max="32767" attributes="0"/>
  30
+              <EmptySpace max="-2" attributes="0"/>
  31
+          </Group>
  32
+      </Group>
  33
+    </DimensionLayout>
  34
+    <DimensionLayout dim="1">
  35
+      <Group type="103" groupAlignment="0" attributes="0">
  36
+          <Group type="102" alignment="0" attributes="0">
  37
+              <EmptySpace max="-2" attributes="0"/>
  38
+              <Component id="jPanel1" max="32767" attributes="0"/>
  39
+              <EmptySpace max="-2" attributes="0"/>
  40
+          </Group>
  41
+      </Group>
  42
+    </DimensionLayout>
  43
+  </Layout>
  44
+  <SubComponents>
  45
+    <Container class="javax.swing.JPanel" name="jPanel1">
  46
+
  47
+      <Layout>
  48
+        <DimensionLayout dim="0">
  49
+          <Group type="103" groupAlignment="0" attributes="0">
  50
+              <Group type="102" attributes="0">
  51
+                  <EmptySpace max="-2" attributes="0"/>
  52
+                  <Group type="103" groupAlignment="0" attributes="0">
  53
+                      <Component id="jButton1" alignment="1" max="32767" attributes="0"/>
  54
+                      <Component id="jButton2" alignment="1" max="32767" attributes="0"/>
  55
+                      <Component id="jButton3" alignment="0" pref="329" max="32767" attributes="0"/>
  56
+                      <Component id="jButton4" alignment="1" max="32767" attributes="0"/>
  57
+                      <Component id="jButton5" alignment="0" max="32767" attributes="0"/>
  58
+                      <Component id="jButton6" alignment="1" max="32767" attributes="0"/>
  59
+                  </Group>
  60
+                  <EmptySpace max="-2" attributes="0"/>
  61
+                  <Component id="jScrollBar1" min="-2" max="-2" attributes="0"/>
  62
+                  <EmptySpace max="-2" attributes="0"/>
  63
+              </Group>
  64
+          </Group>
  65
+        </DimensionLayout>
  66
+        <DimensionLayout dim="1">
  67
+          <Group type="103" groupAlignment="0" attributes="0">
  68
+              <Group type="102" alignment="0" attributes="0">
  69
+                  <EmptySpace max="-2" attributes="0"/>
  70
+                  <Component id="jButton1" min="-2" max="-2" attributes="0"/>
  71
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  72
+                  <Component id="jButton2" min="-2" max="-2" attributes="0"/>
  73
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  74
+                  <Component id="jButton3" min="-2" max="-2" attributes="0"/>
  75
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  76
+                  <Component id="jButton4" min="-2" max="-2" attributes="0"/>
  77
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  78
+                  <Component id="jButton5" min="-2" max="-2" attributes="0"/>
  79
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
  80
+                  <Component id="jButton6" min="-2" max="-2" attributes="0"/>
  81
+                  <EmptySpace pref="129" max="32767" attributes="0"/>
  82
+              </Group>
  83
+              <Component id="jScrollBar1" alignment="1" max="32767" attributes="0"/>
  84
+          </Group>
  85
+        </DimensionLayout>
  86
+      </Layout>
  87
+      <SubComponents>
  88
+        <Component class="javax.swing.JButton" name="jButton1">
  89
+          <Properties>
  90
+            <Property name="text" type="java.lang.String" value="Cohesion Demo"/>
  91
+          </Properties>
  92
+          <Events>
  93
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
  94
+          </Events>
  95
+        </Component>
  96
+        <Component class="javax.swing.JButton" name="jButton2">
  97
+          <Properties>
  98
+            <Property name="text" type="java.lang.String" value="Alignment Demo"/>
  99
+          </Properties>
  100
+          <Events>
  101
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
  102
+          </Events>
  103
+        </Component>
  104
+        <Component class="javax.swing.JButton" name="jButton3">
  105
+          <Properties>
  106
+            <Property name="text" type="java.lang.String" value="Cohesion and Alignment Demo"/>
  107
+          </Properties>
  108
+          <Events>
  109
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
  110
+          </Events>
  111
+        </Component>
  112
+        <Component class="javax.swing.JButton" name="jButton4">
  113
+          <Properties>
  114
+            <Property name="text" type="java.lang.String" value="Slow Demo"/>
  115
+          </Properties>
  116
+          <Events>
  117
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
  118
+          </Events>
  119
+        </Component>
  120
+        <Component class="javax.swing.JButton" name="jButton5">
  121
+          <Properties>
  122
+            <Property name="text" type="java.lang.String" value="Arrive Demo"/>
  123
+          </Properties>
  124
+          <Events>
  125
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton5ActionPerformed"/>
  126
+          </Events>
  127
+        </Component>
  128
+        <Component class="javax.swing.JButton" name="jButton6">
  129
+          <Properties>
  130
+            <Property name="text" type="java.lang.String" value="Leader Following Demo"/>
  131
+          </Properties>
  132
+          <Events>
  133
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton6ActionPerformed"/>
  134
+          </Events>
  135
+        </Component>
  136
+        <Component class="javax.swing.JScrollBar" name="jScrollBar1">
  137
+        </Component>
  138
+      </SubComponents>
  139
+    </Container>
  140
+  </SubComponents>
  141
+</Form>
273 MonkeyBrainsDemo_SteeringBehaviors/src/steeringDemos/demos/DemosLauncher.java
... ...
@@ -0,0 +1,273 @@
  1
+//Copyright (c) 2014, Jesús Martín Berlanga. All rights reserved. Distributed under the BSD licence. Read "com/jme3/ai/license.txt".
  2
+
  3
+package steeringDemos.demos;
  4
+
  5
+/**
  6
+ * Demos laucher
  7
+ * @author Jesús Martín Berlanga
  8
+ */
  9
+public class DemosLauncher extends javax.swing.JFrame {
  10
+
  11
+    private Thread appThread;
  12
+    
  13
+    /**
  14
+     * Creates new form laucherForm
  15
+     */
  16
+    public DemosLauncher() {
  17
+        initComponents();
  18
+    }
  19
+
  20
+    /**
  21
+     * This method is called from within the constructor to initialize the form.
  22
+     * WARNING: Do NOT modify this code. The content of this method is always
  23
+     * regenerated by the Form Editor.
  24
+     */
  25
+    @SuppressWarnings("unchecked")
  26
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  27
+    private void initComponents() {
  28
+
  29
+        jPanel1 = new javax.swing.JPanel();
  30
+        jButton1 = new javax.swing.JButton();
  31
+        jButton2 = new javax.swing.JButton();
  32
+        jButton3 = new javax.swing.JButton();
  33
+        jButton4 = new javax.swing.JButton();
  34
+        jButton5 = new javax.swing.JButton();
  35
+        jButton6 = new javax.swing.JButton();
  36
+        jScrollBar1 = new javax.swing.JScrollBar();
  37
+
  38
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  39
+        setResizable(false);
  40
+
  41
+        jButton1.setText("Cohesion Demo");
  42
+        jButton1.addActionListener(new java.awt.event.ActionListener() {
  43
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  44
+                jButton1ActionPerformed(evt);
  45
+            }
  46
+        });
  47
+
  48
+        jButton2.setText("Alignment Demo");
  49
+        jButton2.addActionListener(new java.awt.event.ActionListener() {
  50
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  51
+                jButton2ActionPerformed(evt);
  52
+            }
  53
+        });
  54
+
  55
+        jButton3.setText("Cohesion and Alignment Demo");
  56
+        jButton3.addActionListener(new java.awt.event.ActionListener() {
  57
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  58
+                jButton3ActionPerformed(evt);
  59
+            }
  60
+        });
  61
+
  62
+        jButton4.setText("Slow Demo");
  63
+        jButton4.addActionListener(new java.awt.event.ActionListener() {
  64
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  65
+                jButton4ActionPerformed(evt);
  66
+            }
  67
+        });
  68
+
  69
+        jButton5.setText("Arrive Demo");
  70
+        jButton5.addActionListener(new java.awt.event.ActionListener() {
  71
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  72
+                jButton5ActionPerformed(evt);
  73
+            }
  74
+        });
  75
+
  76
+        jButton6.setText("Leader Following Demo");
  77
+        jButton6.addActionListener(new java.awt.event.ActionListener() {
  78
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
  79
+                jButton6ActionPerformed(evt);
  80
+            }
  81
+        });
  82
+
  83
+        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  84
+        jPanel1.setLayout(jPanel1Layout);
  85
+        jPanel1Layout.setHorizontalGroup(
  86
+            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  87
+            .addGroup(jPanel1Layout.createSequentialGroup()
  88
+                .addContainerGap()
  89
+                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  90
+                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  91
+                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  92
+                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE)
  93
+                    .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  94
+                    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  95
+                    .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  96
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  97
+                .addComponent(jScrollBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  98
+                .addContainerGap())
  99
+        );
  100
+        jPanel1Layout.setVerticalGroup(
  101
+            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  102
+            .addGroup(jPanel1Layout.createSequentialGroup()
  103
+                .addContainerGap()
  104
+                .addComponent(jButton1)
  105
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  106
+                .addComponent(jButton2)
  107
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  108
+                .addComponent(jButton3)
  109
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  110
+                .addComponent(jButton4)
  111
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  112
+                .addComponent(jButton5)
  113
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  114
+                .addComponent(jButton6)
  115
+                .addContainerGap(129, Short.MAX_VALUE))
  116
+            .addComponent(jScrollBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  117
+        );
  118
+
  119
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  120
+        getContentPane().setLayout(layout);
  121
+        layout.setHorizontalGroup(
  122
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  123
+            .addGroup(layout.createSequentialGroup()
  124
+                .addContainerGap()
  125
+                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  126
+                .addContainerGap())
  127
+        );
  128
+        layout.setVerticalGroup(
  129
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  130
+            .addGroup(layout.createSequentialGroup()
  131
+                .addContainerGap()
  132
+                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  133
+                .addContainerGap())
  134
+        );
  135
+
  136
+        pack();
  137
+    }// </editor-fold>//GEN-END:initComponents
  138
+
  139
+    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  140
+      
  141
+        this.appThread = new Thread(new Runnable() 
  142
+        {
  143
+            public void run() 
  144
+            {
  145
+            AlignmentDemo.main(null);
  146
+            }
  147
+        });
  148
+        
  149
+        this.appThread.start();
  150
+        
  151
+        this.dispose();
  152
+    }//GEN-LAST:event_jButton2ActionPerformed
  153
+
  154
+    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  155
+       
  156
+        this.appThread = new Thread(new Runnable() 
  157
+        {
  158
+            public void run() 
  159
+            {
  160
+            SlowDemo.main(null);
  161
+            }
  162
+        });