changeset 144:e58794b067f5 working

demo for Open Source Conference improve
author sugi
date Fri, 21 Sep 2012 10:33:05 +0900
parents 0651fb36a369
children 5f37b57ff32d
files src/alice/test/topology/aquarium/KeyInput.java src/alice/test/topology/aquarium/KeyInputCodeSegment.java src/alice/test/topology/aquarium/ResetFish.java src/alice/test/topology/aquarium/SendLocation.java src/alice/test/topology/aquarium/Update.java
diffstat 5 files changed, 34 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/topology/aquarium/KeyInput.java	Thu Sep 20 22:44:11 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-package alice.test.topology.aquarium;
-
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-
-import javax.media.j3d.Transform3D;
-import javax.media.j3d.TransformGroup;
-import javax.vecmath.Vector3f;
-
-
-public class KeyInput implements KeyListener{
-
-	int KeyCode = 0;
-	Vector3f vector;
-	Transform3D transform;
-	TransformGroup transformGroup;
-	
-	public KeyInput(){
-		transform = new Transform3D();
-		transformGroup= new TransformGroup();
-		transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
-		vector = new Vector3f(0.0f,0.0f,0.0f);
-			
-	}
-	@Override
-	public void keyPressed(KeyEvent event) {
-		KeyCode = event.getKeyCode();
-		switch(KeyCode)
-		{
-		case 37:
-			vector.x -= 0.1f;
-			break;
-		case 38:
-			vector.y += 0.1f;
-			break;
-		case 39:
-			vector.x += 0.1f;
-			break;
-		case 40:
-		    vector.y -= 0.1f;
-		    break;
-		}
-		transform.setTranslation(vector);
-		transformGroup.setTransform(transform);
-	}
-
-	@Override
-	public void keyReleased(KeyEvent arg0) {
-		
-	}
-
-	@Override
-	public void keyTyped(KeyEvent arg0) {
-		
-	}
-
-}
\ No newline at end of file
--- a/src/alice/test/topology/aquarium/KeyInputCodeSegment.java	Thu Sep 20 22:44:11 2012 +0900
+++ b/src/alice/test/topology/aquarium/KeyInputCodeSegment.java	Fri Sep 21 10:33:05 2012 +0900
@@ -16,19 +16,28 @@
 		switch(event.getKeyCode())
 		{
 		case 37: // left
-			new SendLocation(-0.1f,0.0f); 
+			new SendLocation(-0.1f,0.0f,0.0f); 
 			break;
 		case 38: // up
-			new SendLocation(0.0f,0.1f);
+			new SendLocation(0.0f,0.1f,0.0f);
 			break;
 		case 39: // right
-			new SendLocation(0.1f,0.0f);
+			new SendLocation(0.1f,0.0f,0.0f);
 			break;
 		case 40: // down
-			new SendLocation(0.0f,-0.1f);
+			new SendLocation(0.0f,-0.1f,0.0f);
+			break;
+		case 76: // l
+			new SendLocation(0.0f,0.0f,0.1f);
+			break;
+		case 78: // "n"
+			new RefreshWindow(frame);
+			break;
+		case 79: // "o"
+			new SendLocation(0.0f,0.0f,-0.1f);
 			break;
 		case 82: // "r"
-			new RefreshWindow(frame);
+			new ResetFish().execute();
 			break;
 		}
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/ResetFish.java	Fri Sep 21 10:33:05 2012 +0900
@@ -0,0 +1,16 @@
+package alice.test.topology.aquarium;
+
+import alice.codesegment.CodeSegment;
+
+public class ResetFish extends CodeSegment {
+	
+	public ResetFish(){}
+
+	@Override
+	public void run() {
+		FishPoint fp = new FishPoint(0.0f,0.0f,0.0f);
+		ods.update("local", "fish", fp);
+		
+	}
+
+}
--- a/src/alice/test/topology/aquarium/SendLocation.java	Thu Sep 20 22:44:11 2012 +0900
+++ b/src/alice/test/topology/aquarium/SendLocation.java	Fri Sep 21 10:33:05 2012 +0900
@@ -10,31 +10,19 @@
 	private Receiver position = ids.create(CommandType.PEEK);
 	float x;
 	float y;
-	float max = 3.3f;
-	float min = -1.3f;
+	float z;
 	
-	public SendLocation(float x,float y){
+	public SendLocation(float x,float y,float z){
 		this.x = x;
 		this.y = y;
+		this.z = z;
 		position.setKey("local", "fish");
 	}
 	
 	@Override
 	public void run() {
 		FishPoint fp = this.position.asClass(FishPoint.class);
-		
-		fp.setXY(fp.getX()+this.x, fp.getY()+this.y);
-		/*
-		if (fp.getX()+this.x>max){
-			fp.setXY(-1.0f, fp.getY()+this.y);
-		} else if (fp.getX()+this.x< min){
-			fp.setXY(max, fp.getY()+this.y);
-		}
-		else {
-			fp.setXY(fp.getX()+this.x, fp.getY()+this.y);
-		}
-		*/
-		
+		fp.setXYZ(fp.getX()+x, fp.getY()+y, fp.getZ()+z);
 		ods.update("local", "fish", fp);
 		
 	}
--- a/src/alice/test/topology/aquarium/Update.java	Thu Sep 20 22:44:11 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package alice.test.topology.aquarium;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class Update extends CodeSegment {
-	
-	private Receiver list = ids.create(CommandType.PEEK);
-	private Receiver data;
-	private String key;
-	
-	public Update(String key,Receiver data){
-		this.key = key;
-		this.data = data;
-		this.list.setKey("local", "list");
-	}
-
-	@Override
-	public void run() {
-		RoutingTable rt = this.list.asClass(RoutingTable.class);
-		for (Routing r : rt.table) {
-			if (!r.name.equals(this.data.from)){
-				ods.update(r.name, this.key, this.data.val);
-			}
-			
-		}
-		new CheckLocalIndex(this.key,this.data.index);
-		
-	}
-
-}