Mercurial > hg > Members > tatsuki > Alice
changeset 375:e58f5f74748e multicast
create foundation
author | sugi |
---|---|
date | Wed, 04 Jun 2014 00:24:07 +0900 |
parents | 5ceb1c4db167 |
children | f0a7ca4728c7 |
files | src/main/java/alice/test/topology/aquarium/fx/Aquarium.java src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java src/main/java/alice/test/topology/aquarium/fx/SceneController.java src/main/java/alice/test/topology/aquarium/fx/StartAquariumFX.java src/main/java/alice/test/topology/aquarium/fx/StartCodeSegment.java src/main/java/alice/test/topology/aquarium/fx/aquarium.fxml |
diffstat | 6 files changed, 136 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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); + } + +}
--- /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); + } +}
--- /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; + } + + } +}
--- /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(); + } + } + +}
--- /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(); + } + +}
--- /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 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.text.*?> +<?import java.lang.*?> +<?import java.util.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.image.*?> +<?import javafx.scene.layout.*?> +<?import javafx.scene.paint.*?> +<?import javafx.scene.shape.*?> + +<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onKeyPressed="#pressedKey" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="alice.test.topology.aquarium.fx.SceneController"> + <children> + <ImageView fx:id="background" fitHeight="800.0" fitWidth="800.0" layoutX="0.0" layoutY="0.0" pickOnBounds="true" preserveRatio="true" /> + <TextField fx:id="text" layoutX="-1" layoutY="-1" minWidth="1.0" onKeyPressed="#pressedKey" prefWidth="1.0" /> + </children> +</AnchorPane>