changeset 1:b997f2ce1a04

add Controller Class
author one
date Sat, 26 Jan 2013 18:29:45 +0900
parents 6f44308ee519
children 611b5be7f58c
files src/alice/test/topology/aquarium/fx/Aquarium.java src/alice/test/topology/aquarium/fx/AquariumController.java src/alice/test/topology/aquarium/fx/CheckMyName.java src/alice/test/topology/aquarium/fx/FishData.java src/alice/test/topology/aquarium/fx/OtherNode.java src/alice/test/topology/aquarium/fx/RegistRoutingTable.java src/alice/test/topology/aquarium/fx/Share.java src/alice/test/topology/aquarium/fx/StartAquarium.java
diffstat 8 files changed, 132 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/topology/aquarium/fx/Aquarium.java	Thu Jan 24 02:16:17 2013 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-package alice.test.topology.aquarium.fx;
-
-import alice.topology.node.TopologyNode;
-
-public class Aquarium {
-	public static void main(String[] args){
-		AquariumConfig conf = new AquariumConfig(args);
-		new TopologyNode(conf, new StartCodeSegment());
-	}
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/AquariumController.java	Sat Jan 26 18:29:45 2013 +0900
@@ -0,0 +1,56 @@
+package alice.test.topology.aquarium.fx;
+
+import example.UpdateData;
+import javafx.fxml.FXML;
+import javafx.scene.control.TextField;
+import javafx.scene.image.ImageView;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.shape.Rectangle;
+
+public class AquariumController {
+	
+	@FXML private Rectangle rect1;
+	@FXML private Rectangle rect2;
+	@FXML private TextField text;
+	@FXML private ImageView image;
+	
+	public AquariumController(){
+		System.out.println("run app");
+		
+	}
+	
+	@FXML
+	public void PressedKey1(KeyEvent ke){
+		
+	}
+	
+	@FXML
+	public void PressedKey2(KeyEvent ke){
+		
+	}
+	
+	@FXML
+	public void PressedKey3(KeyEvent ke){
+		switch (ke.getCode()){
+		case RIGHT:
+			new UpdateData("image1", new FishData(image.getTranslateX()+10,image.getTranslateY(),image.getTranslateZ())).execute();
+			// rect1.setTranslateX(rect1.getTranslateX()+10.0);
+			break;
+		case LEFT:
+			new UpdateData("image1", new FishData(image.getTranslateX()-10,image.getTranslateY(),image.getTranslateZ())).execute();
+			// rect1.setTranslateX(rect1.getTranslateX()-10.0);
+			break;
+		case UP:
+			new UpdateData("image1", new FishData(image.getTranslateX(),image.getTranslateY()-10,image.getTranslateZ())).execute();
+			// rect1.setTranslateY(rect1.getTranslateY()-10.0);
+			break;
+		case DOWN:
+			new UpdateData("image1", new FishData(image.getTranslateX(),image.getTranslateY()+10,image.getTranslateZ())).execute();
+			// rect1.setTranslateY(rect1.getTranslateY()+10.0);
+			break;
+		default:
+			break;
+		}
+		
+	}
+}
--- a/src/alice/test/topology/aquarium/fx/CheckMyName.java	Thu Jan 24 02:16:17 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/CheckMyName.java	Sat Jan 26 18:29:45 2013 +0900
@@ -24,12 +24,12 @@
 		String type = matcher.group(1);
 		int num = new Integer(matcher.group(2));
 		if (type.equals("cli")){
-			new OtherNode();
+			new OtherNode().execute();
 		} else if (type.equals("node")){
 			if (num==0) {
-				new TopNode();
+				new TopNode().execute();
 			} else {
-				new OtherNode();
+				new OtherNode().execute();
 			}
 		}
 		
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/FishData.java	Sat Jan 26 18:29:45 2013 +0900
@@ -0,0 +1,26 @@
+package alice.test.topology.aquarium.fx;
+
+import java.util.Random;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class FishData {
+	public double x;
+	public double y;
+	public double z;
+	
+	public FishData(){
+		Random rnd = new Random();
+		x = (double) rnd.nextInt(800);
+		y = (double) rnd.nextInt(800);
+		z = (double) rnd.nextInt(800);
+	}
+	
+	public FishData(double _x, double _y, double _z){
+		x = _x;
+		y = _y;
+		z = _z;
+	}
+
+}
--- a/src/alice/test/topology/aquarium/fx/OtherNode.java	Thu Jan 24 02:16:17 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/OtherNode.java	Sat Jan 26 18:29:45 2013 +0900
@@ -10,7 +10,6 @@
 		new RegistRoutingTable();
 		ods.put("parent", "member", "ADD_MEM");
 		
-		
 	}
 
 }
--- a/src/alice/test/topology/aquarium/fx/RegistRoutingTable.java	Thu Jan 24 02:16:17 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/RegistRoutingTable.java	Sat Jan 26 18:29:45 2013 +0900
@@ -22,6 +22,7 @@
 		ods.update("local", "list", routing);
 		new RegistRoutingTable();
 		
+		
 	}
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/Share.java	Sat Jan 26 18:29:45 2013 +0900
@@ -0,0 +1,35 @@
+package alice.test.topology.aquarium.fx;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+
+public class Share extends CodeSegment {
+
+	private Receiver data = ids.create(CommandType.PEEK);
+	private Receiver list = ids.create(CommandType.PEEK);
+	
+	public Share(String key) {
+		list.setKey("list");
+		data.setKey(key);
+	}
+	
+	public Share(String key, int index) {
+		list.setKey("list");
+		data.setKey(key, index);
+	}
+	
+	@Override
+	public void run() {
+		RoutingTable rt = this.list.asClass(RoutingTable.class);
+		for (RoutingData r : rt.table) {
+			if (!r.name.equals(data.from)) { 
+				ods.update(r.name, data.key, data.val);
+			}
+		}
+		
+		new Share(data.key,data.index);
+	}	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/StartAquarium.java	Sat Jan 26 18:29:45 2013 +0900
@@ -0,0 +1,11 @@
+package alice.test.topology.aquarium.fx;
+
+import alice.topology.node.TopologyNode;
+
+public class StartAquarium {
+	public static void main(String[] args){
+		AquariumConfig conf = new AquariumConfig(args);
+		new TopologyNode(conf, new StartCodeSegment());
+	}
+
+}