# HG changeset patch # User sugi # Date 1338874264 -32400 # Node ID 8e3c1217aad4a259b476af3eb24ac4e5d65f4333 # Parent 19f3bd33277d4f1c2f61a78a9858f49beb309f89 add KeyInput diff -r 19f3bd33277d -r 8e3c1217aad4 src/alice/test/topology/movement/CheckFishLocation.java --- a/src/alice/test/topology/movement/CheckFishLocation.java Tue Jun 05 00:35:58 2012 +0900 +++ b/src/alice/test/topology/movement/CheckFishLocation.java Tue Jun 05 14:31:04 2012 +0900 @@ -15,11 +15,10 @@ MakeFrame frame; MakeObject obj; Pattern pattern = Pattern.compile("^(cli)([0-9]+)$"); - String myKey; public CheckFishLocation(MakeObject MO ,String str){ this.obj = MO; - this.myKey = str; + this.nowX.key = str; } @Override @@ -29,17 +28,18 @@ matcher.find(); int num = new Integer(matcher.group(2)); + float startX = 2*num - 3.0f; float endX = 2*num -0.9f; float x = (float)this.nowX.asInteger()/1000; - System.out.println(myKey+": " + x); + System.out.println(this.nowX.key+" :" + x); if (startX <= x && x < endX){ obj.setLocation(x - 2*(num-1), 0.1f*num); - ods.update("parent", myKey, this.nowX.asInteger()+1); + ods.update("parent", this.nowX.key, this.nowX.asInteger()+1); } - CheckFishLocation cs = new CheckFishLocation(this.obj,this.myKey); - cs.nowX.setKey("parent",myKey,this.nowX.index); + CheckFishLocation cs = new CheckFishLocation(this.obj,this.nowX.key); + cs.nowX.setKey("parent",this.nowX.key,this.nowX.index); cs.host.setKey("local","host"); } diff -r 19f3bd33277d -r 8e3c1217aad4 src/alice/test/topology/movement/CheckMyName.java --- a/src/alice/test/topology/movement/CheckMyName.java Tue Jun 05 00:35:58 2012 +0900 +++ b/src/alice/test/topology/movement/CheckMyName.java Tue Jun 05 14:31:04 2012 +0900 @@ -36,6 +36,8 @@ cs2.host.setKey("local","host"); cs2.nowX.setKey("parent","fish2X"); + MakeObject obj3 = new MakeObject(frame); + frame.registerKObj(obj3); }else if(type.equals("node")){ System.out.println("node0"); diff -r 19f3bd33277d -r 8e3c1217aad4 src/alice/test/topology/movement/KeyInputCodeSegment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/movement/KeyInputCodeSegment.java Tue Jun 05 14:31:04 2012 +0900 @@ -0,0 +1,38 @@ +package alice.test.topology.movement; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class KeyInputCodeSegment implements KeyListener{ + int KeyCode = 0; + SendLocation cs; + @Override + public void keyPressed(KeyEvent event) { + // TODO Auto-generated method stub + KeyCode = event.getKeyCode(); + switch(KeyCode) + { + case 37: + cs = new SendLocation(-1); + cs.nowX.setKey("parent", "fish3X"); + break; + case 39: + cs = new SendLocation(1); + cs.nowX.setKey("parent", "fish3X"); + break; + } + } + + @Override + public void keyReleased(KeyEvent arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void keyTyped(KeyEvent arg0) { + // TODO Auto-generated method stub + + } + +} diff -r 19f3bd33277d -r 8e3c1217aad4 src/alice/test/topology/movement/MakeFrame.java --- a/src/alice/test/topology/movement/MakeFrame.java Tue Jun 05 00:35:58 2012 +0900 +++ b/src/alice/test/topology/movement/MakeFrame.java Tue Jun 05 14:31:04 2012 +0900 @@ -65,6 +65,11 @@ this.universe.addBranchGraph(group); } + public void registerKObj(MakeObject obj){ + BranchGroup group = obj.createKeyBranch(); + this.universe.addBranchGraph(group); + } + public Canvas3D getCanvas(){ return this.canvas; } diff -r 19f3bd33277d -r 8e3c1217aad4 src/alice/test/topology/movement/SendLocation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/movement/SendLocation.java Tue Jun 05 14:31:04 2012 +0900 @@ -0,0 +1,23 @@ +package alice.test.topology.movement; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + + +public class SendLocation extends CodeSegment { + + public Receiver nowX = ids.create(CommandType.PEEK); + int num; + + public SendLocation(int x){ + this.num = x; + } + + @Override + public void run() { + ods.update("parent", "fishX3", this.nowX.asInteger()+num); + + } + +}