Mercurial > hg > Members > sugi > javafx
changeset 40:8119d2bc3735 default tip
refactor
author | YU |
---|---|
date | Mon, 09 Jun 2014 19:17:00 +0900 |
parents | 4c52d0ecac46 |
children | |
files | fxml/aquarium.fxml src/alice/test/topology/aquarium/fx/AddObject.java src/alice/test/topology/aquarium/fx/Aquarium.java src/alice/test/topology/aquarium/fx/SetTranslate.java src/alice/test/topology/aquarium/fx/SetTranslation.java src/example/CubeSample.java |
diffstat | 6 files changed, 66 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/fxml/aquarium.fxml Thu May 22 00:06:32 2014 +0900 +++ b/fxml/aquarium.fxml Mon Jun 09 19:17:00 2014 +0900 @@ -8,7 +8,7 @@ <?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"> +<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.SceneController"> <children> <TextField fx:id="text" layoutX="-1" layoutY="-1" minWidth="1.0" onKeyPressed="#PressedKey3" prefWidth="1.0" /> <ImageView fx:id="background" fitHeight="800.0" fitWidth="800.0" layoutX="0.0" layoutY="0.0" pickOnBounds="true" preserveRatio="true" />
--- a/src/alice/test/topology/aquarium/fx/AddObject.java Thu May 22 00:06:32 2014 +0900 +++ b/src/alice/test/topology/aquarium/fx/AddObject.java Mon Jun 09 19:17:00 2014 +0900 @@ -10,6 +10,7 @@ import javafx.scene.image.ImageView; import javafx.scene.image.ImageViewBuilder; +@SuppressWarnings("deprecation") public class AddObject extends CodeSegment{ private Receiver data1 = ids.create(CommandType.PEEK); @@ -42,7 +43,7 @@ .id("FISH"+i) .build(); iv.setImage(img); - new SetTranslation(iv ,iv.getId()); + new SetTranslate(iv ,iv.getId()); list.add(iv); if (mynum == 0) new PositionController(iv.getId()); new Share(iv.getId() ,5);
--- a/src/alice/test/topology/aquarium/fx/Aquarium.java Thu May 22 00:06:32 2014 +0900 +++ b/src/alice/test/topology/aquarium/fx/Aquarium.java Mon Jun 09 19:17:00 2014 +0900 @@ -1,6 +1,7 @@ package alice.test.topology.aquarium.fx; import java.io.IOException; + import javafx.application.Application; import javafx.collections.ObservableList; import javafx.event.EventHandler; @@ -9,14 +10,16 @@ import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.image.ImageViewBuilder; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import javafx.stage.WindowEvent; +@SuppressWarnings("deprecation") public class Aquarium extends Application { private ObservableList<Node> list; - public AnchorPane root; + private AnchorPane root; @Override public void start(Stage primaryStage) throws IOException { @@ -37,7 +40,7 @@ Image img2 = new Image("fish.jpg"); fish.setImage(img2); new Share("FISH0"); - new SetTranslation(fish, "FISH0"); + new SetTranslate(fish, "FISH0"); list = root.getChildren(); Scene scene = new Scene(root); @@ -51,6 +54,18 @@ } }); + + + ImageView iv = ImageViewBuilder.create() + .fitWidth(90).fitHeight(90) + .translateX(700) + .translateY(700) + .translateZ(0) + .id("test") + .build(); + Image img = new Image("fish.jpg"); + iv.setImage(img); + root.getChildren().add(iv); new AddObject(this); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/SetTranslate.java Mon Jun 09 19:17:00 2014 +0900 @@ -0,0 +1,45 @@ +package alice.test.topology.aquarium.fx; + +import javafx.scene.image.ImageView; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class SetTranslate extends CodeSegment { + + private Receiver data1 = ids.create(CommandType.PEEK); + private Receiver data2 = ids.create(CommandType.PEEK); + private Receiver data3 = ids.create(CommandType.PEEK); + + private ImageView iv; + + public SetTranslate(ImageView iv, String key){ + ods.put("local", key, new FishData(iv.getTranslateX(),iv.getTranslateY(),iv.getTranslateZ())); + this.iv = iv; + data1.setKey(key); + data2.setKey("startX"); + data3.setKey("width"); + + } + + public SetTranslate(ImageView iv, String key, int index) { + this.iv = iv; + data1.setKey(key, index); + data2.setKey("startX"); + data3.setKey("width"); + } + + @Override + public void run() { + int startX = data2.asInteger(); + // int width = data3.asInteger(); + FishData fd = data1.asClass(FishData.class); + //if (startX<=fd.getX()&& fd.getX()<=startX+width){ + iv.setTranslateX(fd.getX() - startX); + iv.setTranslateY(fd.getY()); + iv.setTranslateZ(fd.getZ()); + //} + new SetTranslate(iv, data1.key, data1.index); + } + +}
--- a/src/alice/test/topology/aquarium/fx/SetTranslation.java Thu May 22 00:06:32 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -package alice.test.topology.aquarium.fx; - -import javafx.scene.image.ImageView; -import alice.codesegment.CodeSegment; -import alice.datasegment.CommandType; -import alice.datasegment.Receiver; - -public class SetTranslation extends CodeSegment { - - private Receiver data1 = ids.create(CommandType.PEEK); - private Receiver data2 = ids.create(CommandType.PEEK); - private Receiver data3 = ids.create(CommandType.PEEK); - - private ImageView iv; - - public SetTranslation(ImageView iv, String key){ - ods.put("local", key, new FishData(iv.getTranslateX(),iv.getTranslateY(),iv.getTranslateZ())); - this.iv = iv; - data1.setKey(key); - data2.setKey("startX"); - data3.setKey("width"); - - } - - public SetTranslation(ImageView iv, String key, int index) { - this.iv = iv; - data1.setKey(key, index); - data2.setKey("startX"); - data3.setKey("width"); - } - - @Override - public void run() { - int startX = data2.asInteger(); - // int width = data3.asInteger(); - FishData fd = data1.asClass(FishData.class); - //if (startX<=fd.getX()&& fd.getX()<=startX+width){ - iv.setTranslateX(fd.getX() - startX); - iv.setTranslateY(fd.getY()); - iv.setTranslateZ(fd.getZ()); - //} - new SetTranslation(iv, data1.key, data1.index); - } - -}
--- a/src/example/CubeSample.java Thu May 22 00:06:32 2014 +0900 +++ b/src/example/CubeSample.java Mon Jun 09 19:17:00 2014 +0900 @@ -30,6 +30,7 @@ * @see javafx.scene.paint.Color * @see javafx.scene.shape.RectangleBuilder */ +@SuppressWarnings("deprecation") public class CubeSample extends Application { private Timeline animation;