Mercurial > hg > Members > sugi > javafx
changeset 15:3458bde834d3
remove NullPointerException
author | e095732 |
---|---|
date | Sat, 02 Feb 2013 02:24:05 +0900 |
parents | e027d228c455 |
children | 5e6d40908c60 |
files | src/alice/test/topology/aquarium/fx/AquariumController.java src/alice/test/topology/aquarium/fx/UpdateData.java |
diffstat | 2 files changed, 20 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/topology/aquarium/fx/AquariumController.java Wed Jan 30 18:20:48 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/AquariumController.java Sat Feb 02 02:24:05 2013 +0900 @@ -20,16 +20,16 @@ public void PressedKey3(KeyEvent ke){ switch (ke.getCode()){ case RIGHT: - new UpdateData("image1", new FishData(image.getTranslateX()+10,image.getTranslateY(),image.getTranslateZ())).execute(); + new UpdateData(new FishData(10,0,0)); break; case LEFT: - new UpdateData("image1", new FishData(image.getTranslateX()-10,image.getTranslateY(),image.getTranslateZ())).execute(); + new UpdateData(new FishData(-10,0,0)); break; case UP: - new UpdateData("image1", new FishData(image.getTranslateX(),image.getTranslateY()-10,image.getTranslateZ())).execute(); + new UpdateData(new FishData(0,-10,0)); break; case DOWN: - new UpdateData("image1", new FishData(image.getTranslateX(),image.getTranslateY()+10,image.getTranslateZ())).execute(); + new UpdateData(new FishData(0,10,0)); break; default: break;
--- a/src/alice/test/topology/aquarium/fx/UpdateData.java Wed Jan 30 18:20:48 2013 +0900 +++ b/src/alice/test/topology/aquarium/fx/UpdateData.java Sat Feb 02 02:24:05 2013 +0900 @@ -1,19 +1,29 @@ package alice.test.topology.aquarium.fx; import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; public class UpdateData extends CodeSegment { - private String key; - private FishData fd; + private Receiver data1 = ids.create(CommandType.PEEK); + private Receiver data2 = ids.create(CommandType.TAKE); - public UpdateData(String key, FishData fd){ - this.key = key; - this.fd = fd; + public UpdateData(FishData fd){ + ods.put("local", "diff", fd); + data1.setKey("image1"); + data2.setKey("diff"); } @Override public void run() { - ods.update("local", this.key, this.fd); + FishData fd1 = data1.asClass(FishData.class); + FishData fd2 = data2.asClass(FishData.class); + + fd1.SetXYZ(fd1.getX()+fd2.getX(), + fd1.getY()+fd2.getY(), + fd1.getZ()+fd2.getZ()); + ods.update("local", data1.key, fd1); + System.out.println("PUTDATA"); } }