# HG changeset patch # User sugi # Date 1348072366 -32400 # Node ID b51d3bf971e7486fc2f4260b2045de5c22c46ad3 # Parent f995396f2af733a669762235aef1eaa34928695a add function (refresh) diff -r f995396f2af7 -r b51d3bf971e7 scripts/aquarium.sh --- a/scripts/aquarium.sh Tue Sep 18 16:19:50 2012 +0900 +++ b/scripts/aquarium.sh Thu Sep 20 01:32:46 2012 +0900 @@ -9,7 +9,7 @@ cnt=0 while [ $cnt -lt $max ] do - java -cp ../Alice.jar alice.test.topology.aquarium.FishMovementTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/modelbeta${cnt}.log -level debug > ./output/std_modelbeta${cnt}.log & + java -cp ../Alice.jar alice.test.topology.aquarium.FishMovementTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/aquarium${cnt}.log -level debug > ./output/std_aquarium${cnt}.log & cnt=`expr $cnt + 1` done wait diff -r f995396f2af7 -r b51d3bf971e7 src/alice/test/topology/aquarium/CheckMyName.java --- a/src/alice/test/topology/aquarium/CheckMyName.java Tue Sep 18 16:19:50 2012 +0900 +++ b/src/alice/test/topology/aquarium/CheckMyName.java Thu Sep 20 01:32:46 2012 +0900 @@ -54,14 +54,14 @@ } ods.update("local", key, new FishPoint(-0.1f,-0.1f)); - new SetLocation(new MakeObject(frame),key,0,num); + new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); for (int i = 0;i < 3 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); ods.update("local", key, new FishPoint(0.2f*i,0.2f*i)); - new SetLocation(new MakeObject(frame),key,0,num); + new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); } diff -r f995396f2af7 -r b51d3bf971e7 src/alice/test/topology/aquarium/KeyInputCodeSegment.java --- a/src/alice/test/topology/aquarium/KeyInputCodeSegment.java Tue Sep 18 16:19:50 2012 +0900 +++ b/src/alice/test/topology/aquarium/KeyInputCodeSegment.java Thu Sep 20 01:32:46 2012 +0900 @@ -5,8 +5,14 @@ public class KeyInputCodeSegment implements KeyListener{ + MakeFrame frame; + public KeyInputCodeSegment(MakeFrame frame) { + this.frame = frame; + } + @Override public void keyPressed(KeyEvent event) { + System.out.println(event.getKeyCode()); switch(event.getKeyCode()) { case 37: // left @@ -21,6 +27,9 @@ case 40: // down new SendLocation(0.0f,-0.1f); break; + case 82: // "r" + new RefreshWindow(frame); + break; } } diff -r f995396f2af7 -r b51d3bf971e7 src/alice/test/topology/aquarium/MakeFrame.java --- a/src/alice/test/topology/aquarium/MakeFrame.java Tue Sep 18 16:19:50 2012 +0900 +++ b/src/alice/test/topology/aquarium/MakeFrame.java Thu Sep 20 01:32:46 2012 +0900 @@ -24,13 +24,15 @@ public class MakeFrame { - int fSizeX = 800; - int fSizeY = 800; + private int fSizeX = 800; + private int fSizeY = 800; private Canvas3D canvas; private SimpleUniverse universe; + private JFrame frame; + private ObjectList list = new ObjectList(); public MakeFrame(String str){ - JFrame frame = new JFrame(str); + frame = new JFrame(str); frame.setSize(fSizeX,fSizeY); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -47,7 +49,7 @@ universe.addBranchGraph(createLight()); universe.addBranchGraph(setBackground()); - canvas.addKeyListener(new KeyInputCodeSegment()); + canvas.addKeyListener(new KeyInputCodeSegment(this)); frame.setVisible(true); ViewingPlatform camera = universe.getViewingPlatform(); @@ -85,8 +87,10 @@ } public void register(MakeObject obj){ + list.table.add(obj); BranchGroup group = obj.createBranch(); this.universe.addBranchGraph(group); + } public SimpleUniverse getUniverse(){ @@ -96,4 +100,13 @@ public Canvas3D getCanvas(){ return this.canvas; } + + public JFrame getJFrame(){ + return this.frame; + } + + public ObjectList getList(){ + return this.list; + } + } diff -r f995396f2af7 -r b51d3bf971e7 src/alice/test/topology/aquarium/ObjectList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/ObjectList.java Thu Sep 20 01:32:46 2012 +0900 @@ -0,0 +1,8 @@ +package alice.test.topology.aquarium; + +import java.util.ArrayList; +import java.util.List; + +public class ObjectList { + public List table = new ArrayList(); +} diff -r f995396f2af7 -r b51d3bf971e7 src/alice/test/topology/aquarium/RefreshWindow.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/RefreshWindow.java Thu Sep 20 01:32:46 2012 +0900 @@ -0,0 +1,27 @@ +package alice.test.topology.aquarium; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class RefreshWindow extends CodeSegment { + private Receiver host = ids.create(CommandType.PEEK); + private MakeFrame frame; + + public RefreshWindow(MakeFrame frame){ + this.host.setKey("local","host"); + this.frame = frame; + } + + @Override + public void run() { + + frame.getJFrame().dispose(); + ObjectList list = frame.getList(); + frame = new MakeFrame(this.host.asString()); + for (MakeObject obj : list.table) { + this.frame.register(obj); + } + } + +} + diff -r f995396f2af7 -r b51d3bf971e7 src/alice/test/topology/aquarium/SetLocation.java --- a/src/alice/test/topology/aquarium/SetLocation.java Tue Sep 18 16:19:50 2012 +0900 +++ b/src/alice/test/topology/aquarium/SetLocation.java Thu Sep 20 01:32:46 2012 +0900 @@ -30,7 +30,7 @@ if (startX <= fp.getX() && fp.getX() < endX) obj.setLocation(fp.getX() - 2*range, fp.getY()); - new SetLocation(this.obj,this.key,this.position.index,this.range); + new SetLocation(this.obj, this.key, this.position.index, this.range); }