# HG changeset patch # User one # Date 1359192585 -32400 # Node ID b997f2ce1a04ea20318f9b1049e8c831438538be # Parent 6f44308ee519cd89b2e7faaca7590d63317777fd add Controller Class diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/Aquarium.java --- 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()); - } - -} diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/AquariumController.java --- /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; + } + + } +} diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/CheckMyName.java --- 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(); } } diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/FishData.java --- /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; + } + +} diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/OtherNode.java --- 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"); - } } diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/RegistRoutingTable.java --- 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(); + } } diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/Share.java --- /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); + } + +} diff -r 6f44308ee519 -r b997f2ce1a04 src/alice/test/topology/aquarium/fx/StartAquarium.java --- /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()); + } + +}