comparison src/alice/test/topology/movement/CheckFishLocation.java @ 91:19f3bd33277d working

add KeyInput
author sugi
date Tue, 05 Jun 2012 00:35:58 +0900
parents
children 8e3c1217aad4
comparison
equal deleted inserted replaced
90:75aa139d46eb 91:19f3bd33277d
1 package alice.test.topology.movement;
2
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
5
6 import alice.codesegment.CodeSegment;
7 import alice.datasegment.CommandType;
8 import alice.datasegment.Receiver;
9
10
11 public class CheckFishLocation extends CodeSegment{
12
13 public Receiver nowX = ids.create(CommandType.PEEK);
14 public Receiver host = ids.create(CommandType.PEEK);
15 MakeFrame frame;
16 MakeObject obj;
17 Pattern pattern = Pattern.compile("^(cli)([0-9]+)$");
18 String myKey;
19
20 public CheckFishLocation(MakeObject MO ,String str){
21 this.obj = MO;
22 this.myKey = str;
23 }
24
25 @Override
26 public void run(){
27 String name = host.asString();
28 Matcher matcher = pattern.matcher(name);
29 matcher.find();
30 int num = new Integer(matcher.group(2));
31
32 float startX = 2*num - 3.0f;
33 float endX = 2*num -0.9f;
34 float x = (float)this.nowX.asInteger()/1000;
35 System.out.println(myKey+": " + x);
36 if (startX <= x && x < endX){
37 obj.setLocation(x - 2*(num-1), 0.1f*num);
38 ods.update("parent", myKey, this.nowX.asInteger()+1);
39 }
40
41 CheckFishLocation cs = new CheckFishLocation(this.obj,this.myKey);
42 cs.nowX.setKey("parent",myKey,this.nowX.index);
43 cs.host.setKey("local","host");
44
45 }
46
47
48 }