Mercurial > hg > Members > tatsuki > Alice
changeset 110:aa9fc077c286 working
remove host from checkFishLocation
author | sugi |
---|---|
date | Sun, 15 Jul 2012 21:32:48 +0900 |
parents | 96674c803853 |
children | ba64a9d76e70 |
files | src/alice/test/topology/fishmodel/alpha/CheckFishLocation.java src/alice/test/topology/fishmodel/alpha/CheckMyName.java src/alice/test/topology/fishmodel/alpha/MakeFrame.java src/alice/test/topology/fishmodel/alpha/MakeObject.java src/alice/test/topology/fishmodel/beta/CheckMyName.java src/alice/test/topology/fishmodel/beta/Update.java |
diffstat | 6 files changed, 30 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/topology/fishmodel/alpha/CheckFishLocation.java Sun Jul 15 20:48:01 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/CheckFishLocation.java Sun Jul 15 21:32:48 2012 +0900 @@ -1,8 +1,5 @@ package alice.test.topology.fishmodel.alpha; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; @@ -11,40 +8,30 @@ public class CheckFishLocation extends CodeSegment{ private Receiver position = ids.create(CommandType.PEEK); - private Receiver host = ids.create(CommandType.PEEK); MakeObject obj; String key; - Pattern pattern = Pattern.compile("^(cli)([0-9]+)$"); + int range; - public CheckFishLocation(MakeObject MO ,String key,int index){ + public CheckFishLocation(MakeObject MO ,String key,int index,int range){ this.obj = MO; this.key = key; - this.host.setKey("local","host"); + this.range = range; this.position.setKey("local",key,index); } @Override public void run(){ - String name = host.asString(); - Matcher matcher = pattern.matcher(name); - matcher.find(); - //int num = new Integer(matcher.group(2)); - //float startX = 2*num - 3.0f; - //float endX = 2*num -0.9f; FishPoint FP = this.position.asClass(FishPoint.class); obj.setLocation(FP.getX(), FP.getY()); /* - if (startX <= FP.getX() && FP.getX() < endX){ - obj.setLocation(FP.getX() - 2*(num-1), FP.getY()); - if(this.position.key!="fish3X") - ods.update("parent", this.position.key, this.position.asInteger()+1); - } - */ - new CheckFishLocation(this.obj,this.key,this.position.index); - - - + float startX = 2*range - 1; + float endX = 2*range + 1; + if (startX <= FP.getX() && FP.getX() < endX) + obj.setLocation(FP.getX() - 2*range, FP.getY()); + */ + new CheckFishLocation(this.obj,this.key,this.position.index,this.range); + }
--- a/src/alice/test/topology/fishmodel/alpha/CheckMyName.java Sun Jul 15 20:48:01 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/CheckMyName.java Sun Jul 15 21:32:48 2012 +0900 @@ -22,16 +22,16 @@ matcher.find(); String type = matcher.group(1); - int cliNum = new Integer(matcher.group(2)); + int num = new Integer(matcher.group(2)); if (type.equals("cli")){ - System.out.println("cli"+cliNum); + System.out.println("cli"+num); ods.update("local", key, new FishPoint(0.0f,0.0f)); - MakeFrame frame = new MakeFrame(); + MakeFrame frame = new MakeFrame(name); MakeObject obj3 = new MakeObject(frame); frame.register(obj3); - new CheckFishLocation(obj3,key,0); + new CheckFishLocation(obj3,key,0,num); new CheckLocalIndex(key,0); new CheckParentIndex(key,0); /* @@ -44,7 +44,7 @@ ods.update("local", key, new FishPoint(0.0f,0.0f)); //ods.update("local", "fish1X", new FishPoint(-1.0f,0.0f)); - if(cliNum == 0){ + if(num == 0){ new LookData(key,0); } else { new CheckLocalIndex(key,0);
--- a/src/alice/test/topology/fishmodel/alpha/MakeFrame.java Sun Jul 15 20:48:01 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/MakeFrame.java Sun Jul 15 21:32:48 2012 +0900 @@ -31,8 +31,8 @@ private KeyInput key; private KeyInputCodeSegment KIC; - public MakeFrame(){ - JFrame frame = new JFrame(); + public MakeFrame(String str){ + JFrame frame = new JFrame(str); frame.setSize(fSizeX,fSizeY); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
--- a/src/alice/test/topology/fishmodel/alpha/MakeObject.java Sun Jul 15 20:48:01 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/MakeObject.java Sun Jul 15 21:32:48 2012 +0900 @@ -75,7 +75,6 @@ } private Appearance createAppearance(){ - //System.out.println(new File(".").getAbsolutePath()); Appearance app = new Appearance(); Image image = null; Toolkit toolkit = Toolkit.getDefaultToolkit(); @@ -103,5 +102,12 @@ transform.setTranslation(vector); transform_group.setTransform(transform); } + + public void setLocation(float x,float y,float z){ + transform = new Transform3D(); + vector = new Vector3f(x,y,z); + transform.setTranslation(vector); + transform_group.setTransform(transform); + } }
--- a/src/alice/test/topology/fishmodel/beta/CheckMyName.java Sun Jul 15 20:48:01 2012 +0900 +++ b/src/alice/test/topology/fishmodel/beta/CheckMyName.java Sun Jul 15 21:32:48 2012 +0900 @@ -25,13 +25,13 @@ matcher.find(); String type = matcher.group(1); - int cliNum = new Integer(matcher.group(2)); + int num = new Integer(matcher.group(2)); RoutingTable routing = new RoutingTable(); ods.update("local", key, new FishPoint(0.0f,0.0f)); if (type.equals("cli")){ - System.out.println("cli"+cliNum); + System.out.println("cli"+num); routing.table.add(new Routing("parent")); ods.put("local", "list", routing); @@ -39,8 +39,8 @@ ods.put("parent", "member", name); }else if (type.equals("node")){ - System.out.println("node"+cliNum); - if (cliNum != 0){ + System.out.println("node"+num); + if (num != 0){ routing.table.add(new Routing("parent")); ods.put("parent", "member", name); @@ -51,11 +51,11 @@ } - MakeFrame frame = new MakeFrame(); + MakeFrame frame = new MakeFrame(name); MakeObject obj3 = new MakeObject(frame); frame.register(obj3); - new CheckFishLocation(obj3,key,0); + new CheckFishLocation(obj3,key,0,num); new CheckLocalIndex(key,1); }
--- a/src/alice/test/topology/fishmodel/beta/Update.java Sun Jul 15 20:48:01 2012 +0900 +++ b/src/alice/test/topology/fishmodel/beta/Update.java Sun Jul 15 21:32:48 2012 +0900 @@ -21,7 +21,6 @@ RoutingTable RT = this.list.asClass(RoutingTable.class); for (Routing r : RT.table) { if (!r.name.equals(this.data.from)){ - ods.update(r.name, this.key, this.data.val); }