# HG changeset patch # User sugi # Date 1401809047 -32400 # Node ID e58f5f74748e744e11bb13fca011ae4ad4893d9c # Parent 5ceb1c4db167fac791b5fe1384085c266b327884 create foundation diff -r 5ceb1c4db167 -r e58f5f74748e src/main/java/alice/test/topology/aquarium/fx/Aquarium.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Wed Jun 04 00:24:07 2014 +0900 @@ -0,0 +1,27 @@ +package alice.test.topology.aquarium.fx; + +import java.io.IOException; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; + +public class Aquarium extends Application { + + @Override + public void start(Stage primaryStage) throws IOException { + primaryStage.setTitle("Aquarium "+ getParameters().getRaw().get(0)); + primaryStage.setResizable(false); + Pane myPane = (Pane)FXMLLoader.load(getClass().getResource("aquarium.fxml")); + Scene myScene = new Scene(myPane); + primaryStage.setScene(myScene); + primaryStage.show(); + } + + public static void main(String[] args) { + launch(args); + } + +} diff -r 5ceb1c4db167 -r e58f5f74748e src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java Wed Jun 04 00:24:07 2014 +0900 @@ -0,0 +1,29 @@ +package alice.test.topology.aquarium.fx; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class CheckMyName extends CodeSegment { + private Receiver host = ids.create(CommandType.PEEK); + private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$"); + + public CheckMyName(){ + host.setKey("host"); + } + + @Override + public void run() { + String name = host.asString(); + Matcher matcher = pattern.matcher(name); + matcher.find(); + + String type = matcher.group(1); + int num = new Integer(matcher.group(2)); + String[] args = {type+num}; + Aquarium.main(args); + } +} diff -r 5ceb1c4db167 -r e58f5f74748e src/main/java/alice/test/topology/aquarium/fx/SceneController.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/SceneController.java Wed Jun 04 00:24:07 2014 +0900 @@ -0,0 +1,33 @@ +package alice.test.topology.aquarium.fx; + +import javafx.fxml.FXML; +import javafx.scene.control.TextField; +import javafx.scene.image.ImageView; +import javafx.scene.input.KeyEvent; + +public class SceneController { + + @FXML + private TextField text; + @FXML + private ImageView background; + + @FXML + public void pressedKey(KeyEvent ke){ + switch (ke.getCode()){ + case RIGHT: + System.out.println("press RIGHT"); + break; + case LEFT: + System.out.println("press LEFT"); + break; + case UP: + break; + case DOWN: + break; + default: + break; + } + + } +} diff -r 5ceb1c4db167 -r e58f5f74748e src/main/java/alice/test/topology/aquarium/fx/StartAquariumFX.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/StartAquariumFX.java Wed Jun 04 00:24:07 2014 +0900 @@ -0,0 +1,18 @@ +package alice.test.topology.aquarium.fx; + +import alice.topology.node.TopologyNode; +import alice.topology.node.TopologyNodeConfig; + +public class StartAquariumFX { + public static void main(String args[]){ + TopologyNodeConfig conf = new TopologyNodeConfig(args); + if (conf.getManagerHostName() !=null){ + new TopologyNode(conf, new StartCodeSegment()); + } else { + StartCodeSegment cs = new StartCodeSegment(); + cs.ods.put("host", "local0"); + cs.execute(); + } + } + +} diff -r 5ceb1c4db167 -r e58f5f74748e src/main/java/alice/test/topology/aquarium/fx/StartCodeSegment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/StartCodeSegment.java Wed Jun 04 00:24:07 2014 +0900 @@ -0,0 +1,12 @@ +package alice.test.topology.aquarium.fx; + +import alice.codesegment.CodeSegment; + +public class StartCodeSegment extends CodeSegment{ + + @Override + public void run() { + new CheckMyName(); + } + +} diff -r 5ceb1c4db167 -r e58f5f74748e src/main/java/alice/test/topology/aquarium/fx/aquarium.fxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/aquarium.fxml Wed Jun 04 00:24:07 2014 +0900 @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + +