comparison src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java @ 419:aefbe41fcf12 dispose

change tab to space
author sugi
date Tue, 15 Jul 2014 16:00:22 +0900
parents d28b1216d615
children 6e304a7a60e7
comparison
equal deleted inserted replaced
418:a269a019f5f8 419:aefbe41fcf12
7 import alice.codesegment.CodeSegment; 7 import alice.codesegment.CodeSegment;
8 import alice.datasegment.CommandType; 8 import alice.datasegment.CommandType;
9 import alice.datasegment.Receiver; 9 import alice.datasegment.Receiver;
10 10
11 public class CheckMyName extends CodeSegment { 11 public class CheckMyName extends CodeSegment {
12 private Receiver host = ids.create(CommandType.PEEK); 12 private Receiver host = ids.create(CommandType.PEEK);
13 private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$"); 13 private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$");
14 private int INNER_WIDTH = 10; 14 private int INNER_WIDTH = 10;
15
16 public CheckMyName(){
17 host.setKey("host");
18 }
19 15
20 @Override 16 public CheckMyName(){
21 public void run() { 17 host.setKey("host");
22 String name = host.asString(); 18 }
23 Matcher matcher = pattern.matcher(name);
24 matcher.find();
25 19
26 // use view scope 20 @Override
27 int num = new Integer(matcher.group(2)); 21 public void run() {
28 // scope: A_n = 5 + 10(n - 1); 22 String name = host.asString();
29 int median = INNER_WIDTH * num; 23 Matcher matcher = pattern.matcher(name);
30 ods.put("median", median); // node0 median : 0 24 matcher.find();
31 // node1 median : 10
32 // node2 median : 20
33
34 if (num == 0){
35 // only root node create fishInfoList registered all fishInfo
36 // fishInfoList send children for checking all Fish object in own scene
37 new RegisterList();
38 ods.put("registeredList", new ArrayList<FishInfo>());
39 }
40
41 new CheckAllFishInfoExist();
42 25
43 FishInfo fishInfo = new FishInfo(median,0,0); 26 // use view scope
44 fishInfo.setName(name); 27 int num = new Integer(matcher.group(2));
45 28 // scope: A_n = 5 + 10(n - 1);
46 ods.put("OwnFishP", fishInfo.clone()); 29 int median = INNER_WIDTH * num;
47 ods.put("fishData", fishInfo); 30 ods.put("median", median); // node0 median : 0
31 // node1 median : 10
32 // node2 median : 20
48 33
49 new CreateObject(); 34 if (num == 0){
50 new AddObject(); 35 // only root node create fishInfoList registered all fishInfo
51 36 // fishInfoList send children for checking all Fish object in own scene
52 String[] args = {name}; 37 new RegisterList();
53 Aquarium.main(args); 38 ods.put("registeredList", new ArrayList<FishInfo>());
54 } 39 }
40
41 new CheckAllFishInfoExist();
42
43 FishInfo fishInfo = new FishInfo(median,0,0);
44 fishInfo.setName(name);
45
46 ods.put("OwnFishP", fishInfo.clone());
47 ods.put("fishData", fishInfo);
48
49 new CreateObject();
50 new AddObject();
51
52 String[] args = {name};
53 Aquarium.main(args);
54 }
55 } 55 }