Mercurial > hg > Members > sugi > javafx
changeset 10:bf24d5200770
executable
author | e095732 |
---|---|
date | Tue, 29 Jan 2013 15:00:40 +0900 |
parents | 4823e45e8a2c |
children | 26e1da66ffe1 |
files | build.xml fxml/Hello.fxml fxml/LoginDemo.fxml fxml/aquarium.fxml image/fish.jpg src/alice/test/topology/aquarium/fx/AddObject.java src/alice/test/topology/aquarium/fx/Aquarium.java src/alice/test/topology/aquarium/fx/CheckMyName.java src/alice/test/topology/aquarium/fx/OtherNode.java src/alice/test/topology/aquarium/fx/Share.java src/alice/test/topology/aquarium/fx/TopNode.java src/example/CubeSample.java |
diffstat | 12 files changed, 126 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/build.xml Tue Jan 29 10:29:28 2013 +0900 +++ b/build.xml Tue Jan 29 15:00:40 2013 +0900 @@ -1,46 +1,24 @@ <?xml version="1.0" encoding="utf-8"?> -<project name="JavaFx" default="compile" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> +<project name="JavaFx" default="jar" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> <!-- ****プロパティ**** --> <property environment="env" /> <property name="javafx.tools.ant.jar" value="${java.home}\..\lib\ant-javafx.jar" /> <!-- ソースファイルがあるディレクトリ --> - <property name="src" location="src/example"/> + <property name="src" location="src"/> <!-- クラスファイルを出力するディレクトリ --> - <property name="dest" location="classes/example"/> + <property name="dest" location="classes"/> + <!-- jarファイル名 --> + <property name="jar" value="example.jar"/> <!-- 実行可能 Jar ファイルが作成されるフォルダ --> <property name="jardest" location="."/> <!-- javadocを出力するディレクトリ --> <property name="javadoc" value="docs"/> - <!-- アプリケーションの設定 --> - <property name="app.vendor" value="example.CubeSample" /> - - <!-- 実行可能 Jar ファイルの名前(の一部) --> - <property name="app.id" value="CubeSample"/> - <property name="app.name" value="CubeSample"/> - <property name="app.version" value="1.0" /> - <!-- メインクラス --> - <property name="app.main-class" value="example.CubeSample" /> + <!-- タスク定義 --> + <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" + uri="javafx:com.sun.javafx.tools.ant" + classpath="${javafx.tools.ant.jar}"/> -<!-- タスク定義 --> -<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" - uri="javafx:com.sun.javafx.tools.ant" - classpath="${javafx.tools.ant.jar}"/> - -<fx:application id="app-info" - name="${app.name}" - mainClass="${app.main-class}" /> - - <fx:jar destfile="${jardest}/${app.id}-${app.version}.jar"> - <fx:application refid="app-info"/> - <manifest> - <attribute name="Implementation-Vendor" value="${app.vendor}"/> - <attribute name="Implementation-Title" value="${app.name}"/> - <attribute name="Implementation-Version" value="${app.version}"/> - </manifest> - <fileset dir="${dest}"/> - </fx:jar> - <target name="clean"> <delete dir="${dest}"/> <delete dir="${javadoc}"/> @@ -49,6 +27,29 @@ <target name="compile" depends="clean"> <mkdir dir="${dest}" /> - <javac encoding="UTF-8" srcdir="${src}" destdir="${dest}" classpath="${java.home}\lib\jfxrt.jar" includeantruntime="false"/> + <javac encoding="UTF-8" srcdir="${src}" destdir="${dest}" classpath="${java.home}\lib\jfxrt.jar" includeantruntime="false"> + <classpath> + <pathelement path="lib/Alice.jar"/> + <pathelement path="lib/junit.jar"/> + <pathelement path="lib/javassist.jar" /> + <pathelement path="lib/log4j-1.2.16.jar" /> + <pathelement path="lib/slf4j-api-1.6.1.jar" /> + <pathelement path="lib/slf4j-log4j12-1.6.1.jar" /> + <pathelement path="lib/msgpack-0.6.6-SNAPSHOT.jar" /> + <pathelement path="lib/com.alexmerz.graphviz.jar" /> + </classpath> + <sourcepath> + <pathelement path="src"/> + </sourcepath> + </javac> + </target> + + <target name="jar" depends="compile"> + <jar jarfile="${jar}" basedir="${dest}"> + <zipgroupfileset dir="lib" includes="*.jar" /> + <fileset dir="src" includes="log4j.xml" /> + <fileset dir="image" includes="*.jpg" /> + <fileset dir="fxml" includes="*.fxml" /> + </jar> </target> </project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fxml/Hello.fxml Tue Jan 29 15:00:40 2013 +0900 @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Label?> +<?import javafx.scene.layout.AnchorPane?> + +<AnchorPane prefWidth="100" prefHeight="40" xmlns:fx="http://javafx.com/fxml"> + <children> + <Label text="Hello, World!" /> + </children> +</AnchorPane> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fxml/LoginDemo.fxml Tue Jan 29 15:00:40 2013 +0900 @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import java.lang.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.layout.*?> +<?import javafx.scene.text.*?> + +<AnchorPane minHeight="138.0" minWidth="100.0" prefHeight="138.0" prefWidth="320.0" xmlns:fx="http://javafx.com/fxml" fx:controller="example.LoginFormController"> + <children> + <VBox AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0"> + <children> + <AnchorPane prefHeight="40.0"> + <children> + <Label prefWidth="80.0" text="Account" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0"> + <font> + <Font name="System Bold" size="13.0" /> + </font> + </Label> + <TextField fx:id="accountField" prefWidth="160.0" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> + </children> + </AnchorPane> + <AnchorPane prefHeight="40.0"> + <children> + <Label prefWidth="80.0" text="Password" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" /> + <PasswordField fx:id="passwordField" prefWidth="160.0" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> + </children> + </AnchorPane> + <HBox alignment="TOP_RIGHT" fillHeight="true" prefHeight="30.0" snapToPixel="true" spacing="14.0"> + <children> + <Button text="Login" onAction="#handleLogin"/> + <Button text="Cancel" onAction="#handleCancel"/> + </children> + </HBox> + </children> + </VBox> + </children> +</AnchorPane>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fxml/aquarium.fxml Tue Jan 29 15:00:40 2013 +0900 @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?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" prefHeight="800.0" prefWidth="800.0" xmlns:fx="http://javafx.com/fxml" fx:controller="alice.test.topology.aquarium.fx.AquariumController"> + <children> + <TextField fx:id="text" layoutX="14.0" layoutY="564.0" minWidth="1.0" onKeyPressed="#PressedKey3" prefWidth="1.0" /> + <ImageView fx:id="image" fitHeight="75.0" fitWidth="75.0" layoutX="245.0" layoutY="42.0" pickOnBounds="true" preserveRatio="true" /> + </children> +</AnchorPane>
--- a/src/alice/test/topology/aquarium/fx/AddObject.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/AddObject.java Tue Jan 29 15:00:40 2013 +0900 @@ -14,23 +14,26 @@ public class AddObject extends CodeSegment{ - private Receiver data = ids.create(CommandType.PEEK); + private Receiver data1 = ids.create(CommandType.PEEK); + private Receiver data2 = ids.create(CommandType.PEEK); private ObservableList<Node> list; public AddObject(Aquarium aqua){ list = aqua.getList(); - data.setKey("objCnt"); + data1.setKey("objCnt"); + data2.setKey("mynum"); } @Override public void run() { Platform.runLater(new Runnable() { public void run() { - int num = data.asInteger(); + int objCnt = data1.asInteger(); + int mynum = data2.asInteger(); double size = 75; Random rnd = new Random(); Image img = new Image("fish.jpg"); - for (int i = 0;i < num; i++){ + for (int i = 0;i < objCnt; i++){ ImageView iv = ImageViewBuilder.create() .fitWidth(size).fitHeight(size) .translateX(rnd.nextInt(600)) @@ -41,10 +44,10 @@ iv.setImage(img); new SetTranslation(iv ,iv.getId()); list.add(iv); - new PositionController(iv.getId()); + if (mynum == 0) new PositionController(iv.getId()); new Share(iv.getId()); } - System.out.println("Create OBJ " + num); + System.out.println("Create OBJ " + objCnt); System.out.println(list); } });
--- a/src/alice/test/topology/aquarium/fx/Aquarium.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/Aquarium.java Tue Jan 29 15:00:40 2013 +0900 @@ -1,8 +1,6 @@ package alice.test.topology.aquarium.fx; import java.io.IOException; - - import javafx.application.Application; import javafx.collections.ObservableList; import javafx.event.EventHandler; @@ -22,12 +20,20 @@ @Override public void start(Stage primaryStage) throws IOException { - root = FXMLLoader.load(getClass().getResource("aquarium.fxml")); + if (getClass().getResource("aquarium.fxml") != null){ + root = FXMLLoader.load(getClass().getResource("aquarium.fxml")); + } else if (getClass().getClassLoader().getResource("aquarium.fxml") != null){ + root = FXMLLoader.load(getClass().getClassLoader().getResource("aquarium.fxml")); + } else { + System.out.println("error"); + System.exit(0); + } // AquariumController cont = (AquariumController) loader.getController(); get Controller instance ImageView iv = (ImageView) root.getChildren().get(1); Image img = new Image("fish.jpg"); iv.setImage(img); list = root.getChildren(); + new Share("image1"); new SetTranslation(iv, "image1"); Scene scene = new Scene(root);
--- a/src/alice/test/topology/aquarium/fx/CheckMyName.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/CheckMyName.java Tue Jan 29 15:00:40 2013 +0900 @@ -22,7 +22,7 @@ matcher.find(); int num = new Integer(matcher.group(2)); - + ods.put("local", "mynum", num); if (num==0) { new TopNode().execute(); } else {
--- a/src/alice/test/topology/aquarium/fx/OtherNode.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/OtherNode.java Tue Jan 29 15:00:40 2013 +0900 @@ -10,6 +10,9 @@ new RegistRoutingTable(); ods.put("parent", "member", "ADD_MEM"); + ods.put("local", "objCnt", 5); + Aquarium aqua = new Aquarium(); + aqua.run(); } }
--- a/src/alice/test/topology/aquarium/fx/Share.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/Share.java Tue Jan 29 15:00:40 2013 +0900 @@ -12,7 +12,7 @@ public Share(String key) { list.setKey("list"); - data.setKey(key); + data.setKey(key ,1); } public Share(String key, int index) {
--- a/src/alice/test/topology/aquarium/fx/TopNode.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/TopNode.java Tue Jan 29 15:00:40 2013 +0900 @@ -9,6 +9,9 @@ ods.put("local", "list", new RoutingTable()); new RegistRoutingTable(); + ods.put("local", "objCnt", 5); + Aquarium aqua = new Aquarium(); + aqua.run(); } }
--- a/src/example/CubeSample.java Tue Jan 29 10:29:28 2013 +0900 +++ b/src/example/CubeSample.java Tue Jan 29 15:00:40 2013 +0900 @@ -151,5 +151,8 @@ primaryStage.show(); play(); } - public static void main(String[] args) { launch(args); } + public static void main(String[] args) { + launch(args); + } + }