Mercurial > hg > Members > tatsuki > Alice
changeset 109:96674c803853 working
set background
author | sugi |
---|---|
date | Sun, 15 Jul 2012 20:48:01 +0900 |
parents | 5f0010c13631 |
children | aa9fc077c286 |
files | image/image1.jpg image/ocean.jpg scripts/fishBeta_run.sh src/alice/test/topology/fishmodel/alpha/MakeFrame.java src/alice/test/topology/fishmodel/alpha/MakeObject.java src/alice/test/topology/fishmodel/beta/AddRoutingTable.java src/alice/test/topology/fishmodel/beta/CheckLocalIndex.java src/alice/test/topology/fishmodel/beta/CheckMyName.java src/alice/test/topology/fishmodel/beta/Update.java |
diffstat | 9 files changed, 133 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/fishBeta_run.sh Sun Jul 15 20:46:42 2012 +0900 +++ b/scripts/fishBeta_run.sh Sun Jul 15 20:48:01 2012 +0900 @@ -2,8 +2,8 @@ max=$1 child_num=$2 ruby ./topology/treen.rb $1 $2 > ./topology/tree.dot -#dot -Tpng ./topology/tree.dot > ./topology/tree.png -#open ./topology/tree.png +dot -Tpng ./topology/tree.dot > ./topology/tree.png +open ./topology/tree.png java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot -log ./output/manager.log -level debug > ./output/std_manager.log & cnt=0
--- a/src/alice/test/topology/fishmodel/alpha/MakeFrame.java Sun Jul 15 20:46:42 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/MakeFrame.java Sun Jul 15 20:48:01 2012 +0900 @@ -1,15 +1,22 @@ package alice.test.topology.fishmodel.alpha; import java.awt.GraphicsConfiguration; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.media.j3d.Background; import javax.media.j3d.BoundingSphere; import javax.media.j3d.BranchGroup; import javax.media.j3d.Canvas3D; import javax.media.j3d.DirectionalLight; +import javax.media.j3d.ImageComponent2D; import javax.swing.JFrame; import javax.swing.JPanel; import javax.vecmath.Color3f; +import javax.vecmath.Point3d; import javax.vecmath.Vector3f; import com.sun.j3d.utils.universe.SimpleUniverse; @@ -40,6 +47,7 @@ universe = new SimpleUniverse(canvas); universe.addBranchGraph(createLight()); + universe.addBranchGraph(setBackground()); /* key = new KeyInput(); canvas.addKeyListener(key); @@ -52,6 +60,25 @@ camera.setNominalViewingTransform(); } + private BranchGroup setBackground(){ + BranchGroup scene = new BranchGroup(); + BufferedImage img = null; + try { + img = ImageIO.read(new File("../image/image1.jpg")); + } catch (IOException e) { + e.printStackTrace(); + } + ImageComponent2D image = + new ImageComponent2D(ImageComponent2D.FORMAT_RGBA8,img); + Background background = new Background(image); + background.setImageScaleMode(Background.SCALE_FIT_ALL); + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), Double.POSITIVE_INFINITY); + background.setApplicationBounds(bounds); + scene.addChild(background); + return scene; + + } + private BranchGroup createLight(){ BranchGroup scene = new BranchGroup(); Color3f light_color = new Color3f(1.7f,1.7f,1.7f);
--- a/src/alice/test/topology/fishmodel/alpha/MakeObject.java Sun Jul 15 20:46:42 2012 +0900 +++ b/src/alice/test/topology/fishmodel/alpha/MakeObject.java Sun Jul 15 20:48:01 2012 +0900 @@ -3,6 +3,7 @@ import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; +import java.io.FileNotFoundException; //import java.io.File; import javax.media.j3d.Appearance; @@ -13,6 +14,10 @@ import javax.media.j3d.TransformGroup; import javax.vecmath.Vector3f; +import com.sun.j3d.loaders.IncorrectFormatException; +import com.sun.j3d.loaders.ParsingErrorException; +import com.sun.j3d.loaders.Scene; +import com.sun.j3d.loaders.objectfile.ObjectFile; import com.sun.j3d.utils.geometry.Box; import com.sun.j3d.utils.image.TextureLoader; @@ -27,7 +32,7 @@ public MakeObject(MakeFrame MF){ this.canvas = MF.getCanvas(); - this.key = MF.getKey(); + //this.key = MF.getKey(); this.KIC = MF.getKeySegment(); } @@ -45,15 +50,28 @@ public BranchGroup createBranch(){ BranchGroup scene = new BranchGroup(); - Box box = new Box(0.1f,0.1f,0.0f, - Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance()); + /*Box box = new Box(0.1f,0.1f,0.0f, + Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance());*/ + ObjectFile obj = new ObjectFile(ObjectFile.RESIZE); + Scene S = null; + try{ + S = obj.load("../image/galleon.obj"); + } catch(FileNotFoundException e){ + System.err.println(e); + System.exit(1); + } catch(ParsingErrorException e){ + System.err.println(e); + System.exit(1); + } catch(IncorrectFormatException e){ + System.err.println(e); + System.exit(1); + } + transform_group = new TransformGroup(); transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); - transform_group.addChild(box); + transform_group.addChild(S.getSceneGroup()); scene.addChild(transform_group); - setLocation(-10,0);//default position - return scene; - + return scene; } private Appearance createAppearance(){
--- a/src/alice/test/topology/fishmodel/beta/AddRoutingTable.java Sun Jul 15 20:46:42 2012 +0900 +++ b/src/alice/test/topology/fishmodel/beta/AddRoutingTable.java Sun Jul 15 20:48:01 2012 +0900 @@ -17,15 +17,10 @@ @Override public void run() { - /* - for (Routing r : routing.table) { - System.out.println("name:"+r.name); - } - */ + System.out.println("add "+this.mail.from); routing.table.add(new Routing(this.mail.from)); - System.out.println("add "+this.mail.from); - + ods.update("local", "list", routing); new AddRoutingTable(this.routing,this.mail.index); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/fishmodel/beta/CheckLocalIndex.java Sun Jul 15 20:48:01 2012 +0900 @@ -0,0 +1,23 @@ +package alice.test.topology.fishmodel.beta; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class CheckLocalIndex extends CodeSegment { + + private Receiver data = ids.create(CommandType.PEEK); + String key; + + public CheckLocalIndex(String key, int index){ + this.key = key; + this.data.setKey("local", this.key, index); + } + + @Override + public void run() { + new Update(this.key, this.data); + + } + +}
--- a/src/alice/test/topology/fishmodel/beta/CheckMyName.java Sun Jul 15 20:46:42 2012 +0900 +++ b/src/alice/test/topology/fishmodel/beta/CheckMyName.java Sun Jul 15 20:48:01 2012 +0900 @@ -6,11 +6,16 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; +import alice.test.topology.fishmodel.alpha.CheckFishLocation; +import alice.test.topology.fishmodel.alpha.FishPoint; +import alice.test.topology.fishmodel.alpha.MakeFrame; +import alice.test.topology.fishmodel.alpha.MakeObject; public class CheckMyName extends CodeSegment { Receiver host = ids.create(CommandType.PEEK); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); + String key = "fish"; @Override public void run(){ @@ -23,6 +28,7 @@ int cliNum = 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); @@ -34,11 +40,23 @@ }else if (type.equals("node")){ System.out.println("node"+cliNum); - + if (cliNum != 0){ + routing.table.add(new Routing("parent")); + ods.put("parent", "member", name); + + + } ods.put("local", "list", routing); new AddRoutingTable(routing,0); - } + + MakeFrame frame = new MakeFrame(); + + MakeObject obj3 = new MakeObject(frame); + frame.register(obj3); + new CheckFishLocation(obj3,key,0); + + new CheckLocalIndex(key,1); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/fishmodel/beta/Update.java Sun Jul 15 20:48:01 2012 +0900 @@ -0,0 +1,34 @@ +package alice.test.topology.fishmodel.beta; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class Update extends CodeSegment { + + private Receiver list = ids.create(CommandType.PEEK); + private Receiver data; + String key; + + public Update(String key,Receiver data){ + this.key = key; + this.data = data; + this.list.setKey("local", "list"); + } + + @Override + public void run() { + 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); + } + + } + + new CheckLocalIndex(this.key,this.data.index); + + } + +}