[virtualcommons-svn] SF.net SVN: virtualcommons:[350] foraging/trunk
Status: Beta
Brought to you by:
alllee
From: <al...@us...> - 2009-10-30 22:18:49
|
Revision: 350 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=350&view=rev Author: alllee Date: 2009-10-30 22:18:42 +0000 (Fri, 30 Oct 2009) Log Message: ----------- updated pom and build.xml, minor hygiene / refactoring Modified Paths: -------------- foraging/trunk/build.xml foraging/trunk/ivy.xml foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/ClientMovementRequest.java foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java foraging/trunk/src/main/resources/web/client.jnlp Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreatorProcessor.java Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/build.xml 2009-10-30 22:18:42 UTC (rev 350) @@ -13,7 +13,7 @@ uri='antlib:org.apache.ivy.ant' classpathref='ivy.lib.path'/> --> - <property name="ivy.install.version" value="2.0.0" /> + <property name="ivy.install.version" value="2.1.0" /> <condition property="ivy.home" value="${env.IVY_HOME}"> <isset property="env.IVY_HOME" /> </condition> @@ -22,18 +22,10 @@ <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" /> <target name="download-ivy" unless="offline"> - <mkdir dir="${ivy.jar.dir}"/> <!-- download Ivy from web site so that it can be used even without any special installation --> - <get src="http://www.apache.org/dist/ant/ivy/${ivy.install.version}/apache-ivy-${ivy.install.version}-bin.zip" - dest="${ivy.jar.dir}/ivy-${ivy.install.version}-bin.zip" usetimestamp="true"/> - <!-- FIXME: this should be dependent on the download in the first place --> - <unzip src='${ivy.jar.dir}/ivy-${ivy.install.version}-bin.zip' dest='${ivy.jar.dir}' overwrite='false' /> - <move file='${ivy.jar.dir}/apache-ivy-${ivy.install.version}/ivy-${ivy.install.version}.jar' tofile='${ivy.jar.file}' overwrite='false' /> - <!-- - <get src="http://www.apache.org/dist/ant/ivy/${ivy.install.version}/ivy.jar" - dest="${ivy.jar.file}" usetimestamp="true"/> - --> + <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" + dest="${ivy.jar.file}" usetimestamp="true"/> </target> <target name="init-ivy" depends="download-ivy"> @@ -41,12 +33,10 @@ it into ant's lib dir (note that the latter copy will always take precedence). We will not fail as long as local lib dir exists (it may be empty) and ivy is in at least one of ant's lib dir or the local lib dir. --> - <path id="ivy.lib.path"> - <fileset dir="${ivy.jar.dir}" includes="*.jar"/> - - </path> - <taskdef resource="org/apache/ivy/ant/antlib.xml" - uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> + <path id="ivy.lib.path"> + <fileset dir="${ivy.jar.dir}" includes="*.jar"/> + </path> + <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> </target> <target name='resolve' depends='init-ivy' description='--> retrieve dependencies with ivy'> @@ -73,7 +63,7 @@ <property name='server.class' value='edu.asu.commons.foraging.server.ForagingServer'/> <property name='framework.jar' value='csidex.jar'/> - <property name='dist.dir' value='dist' /> + <property name='dist.dir' value='.' /> <property name='resources.dir' value='src/main/resources'/> <property name='conf.dir' value='${resources.dir}/configuration'/> @@ -117,6 +107,7 @@ test - Run all JUnit in the test source tree. build-all - builds the client, server, and facilitator jars. deploy - invokes build-all and then copies the client and facilitator jars to ${web.dir} + convert - invokes the ForagingSaveFileConverter to process the savefiles in the raw-data directory or as specified by -Dsavefile.dir=foo </echo> </target> @@ -229,10 +220,10 @@ <target name="clean"> <delete dir="${build.dir}"/> <delete dir="${test.build.dir}"/> - <delete dir='${dist.dir}'/> <delete dir='${lib.dir}'/> <delete file='server.jar'/> - + <delete file='client.jar'/> + <delete file='facilitator.jar'/> </target> <!-- Compile project source files --> @@ -344,11 +335,13 @@ </target> <property name='savefile.converter.class' value='edu.asu.commons.foraging.util.ForagingSaveFileConverter'/> - <target name='convert-savefiles' depends='compile'> + <!-- default savefile directory is the raw-data directory --> + <property name='savefile.dir' value='raw-data'/> + <target name='convert' depends='compile'> <java classname='${savefile.converter.class}' classpathref='project.classpath' fork='yes'> - <arg value='raw-data'/> + <arg value='${savefile.dir}'/> </java> - </target> + </target> <!-- Run Test on GUI --> <target name="guitest" depends="compile-tests"> Modified: foraging/trunk/ivy.xml =================================================================== --- foraging/trunk/ivy.xml 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/ivy.xml 2009-10-30 22:18:42 UTC (rev 350) @@ -6,7 +6,7 @@ <info organisation="edu.asu.commons" module="foraging"/> <dependencies> <dependency org="junit" name="junit" rev="latest.integration"/> - <dependency org="edu.asu.commons" name="csidex" rev="latest.integration"/> + <dependency org="edu.asu.commons" name="csidex" rev="0.2-SNAPSHOT"/> <dependency org="net.java.dev.jogl" name="jogl" rev="1.1.1-rc6"/> <dependency org="javax.media" name="jmf" rev="2.1.1e"/> </dependencies> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/pom.xml 2009-10-30 22:18:42 UTC (rev 350) @@ -52,7 +52,7 @@ <dependency> <groupId>edu.asu.commons</groupId> <artifactId>csidex</artifactId> - <version>0.2.1</version> + <version>0.2-SNAPSHOT</version> </dependency> <dependency> <groupId>net.java.dev.jogl</groupId> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java 2009-10-30 22:18:42 UTC (rev 350) @@ -10,8 +10,6 @@ import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -51,7 +49,6 @@ * @author alllee * @version $Revision$ */ - @SuppressWarnings("serial") public class ChatPanel extends JPanel { @@ -225,7 +222,7 @@ continue; } JButton button = new JButton(getChatHandle(targetId)); - button.setAlignmentX(Component.CENTER_ALIGNMENT); + button.setAlignmentX(JButton.CENTER_ALIGNMENT); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // change stuff in the messageEntryPanel Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-10-30 22:18:42 UTC (rev 350) @@ -321,6 +321,14 @@ return ! isPrivateProperty() && getBooleanProperty("chat-enabled"); } + public boolean isVotingEnabled() { + return getBooleanProperty("voting-enabled", false); + } + + public String getEnforcementMechanisms() { + return getProperty("enforcement-mechanisms", "single, rotation"); + } + public int getMaximumResourceAge() { return getIntProperty("maximum-resource-age", 10); } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/ClientMovementRequest.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/ClientMovementRequest.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/ClientMovementRequest.java 2009-10-30 22:18:42 UTC (rev 350) @@ -48,7 +48,4 @@ return "Client update: " + getId() + "\n\tDirection: " + direction; } - public void setId(Identifier id) { - this.id = id; - } } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/GroupView.java 2009-10-30 22:18:42 UTC (rev 350) @@ -13,7 +13,7 @@ /** * $Id$ * - * Provides an overview visualization of a particular groups and all participants in the group. + * Provides an overview visualization of a particular group and all participants in the group. * * * @author <a href='mailto:All...@as...'>Allen Lee</a> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-10-30 22:18:42 UTC (rev 350) @@ -287,7 +287,6 @@ } public void removeClient(Identifier id) { - // FIXME: add some sort of notification? clients.remove(id); } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java 2009-10-30 22:18:42 UTC (rev 350) @@ -48,16 +48,16 @@ public class ServerDataModel extends ForagingDataModel { private static final long serialVersionUID = 8166812955398387600L; - + private transient Logger logger = Logger.getLogger( getClass().getName() ); - + private transient Random random = new Random(); - + private transient FractalTerrain terrain; - + // Maps client Identifiers to the GroupDataModel that the client belongs to private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); - + public ServerDataModel() { super(EventTypeChannel.getInstance()); } @@ -66,40 +66,6 @@ super(channel); } - public void unapply(PersistableEvent persistableEvent) { - if (persistableEvent instanceof AddClientEvent) { -// AddClientEvent ace = (AddClientEvent) persistableEvent; -// ClientData clientData = ace.getClientData(); -// Group group = ace.getGroup(); -// removeClientFromGroup(clientData, group); - } - else if (persistableEvent instanceof MovementEvent) { - MovementEvent movementEvent = (MovementEvent) persistableEvent; -// if (movementEvent.didConsumeFood()) { -// Identifier clientId = movementEvent.getId(); -// Group group = getGroup(clientId); -// Point point = getClientPosition(clientId); -// addFood(group, point); -//// group.getClientData(clientId).subtractTokens(1); -// } - moveClient(movementEvent.getId(), movementEvent.getDirection().opposite()); - } - else if (persistableEvent instanceof ResourceAddedEvent) { - ResourceAddedEvent resourceAddedEvent = (ResourceAddedEvent) persistableEvent; - removeResource(resourceAddedEvent.getGroup(), resourceAddedEvent.getResource().getPosition()); - } - else if (persistableEvent instanceof RealTimeSanctionRequest) { -// // FIXME: need to add sanction undoability.. -// SanctionEvent sanctionEvent = (SanctionEvent) persistableEvent; -// getGroup(sanctionEvent.id()).reverseSanction(sanctionEvent); -// - } - else if (persistableEvent instanceof ResetTokenDistributionRequest) { - getGroup(persistableEvent.getId()).resetResourceDistribution(); - } - } - - /** * Invoked when we try to reconstruct a server game state given a time-ordered Set of * PersistableEvents that was previously saved. @@ -109,20 +75,14 @@ // iterate through all stored Persistable Actions, executing them onto // the ForagerServerGameState. if (event instanceof AddClientEvent) { - // usually we don't need to do anything here as we explicitly add all the clients - // in ReplayControlPanel. - AddClientEvent ace = (AddClientEvent) event; - ClientData clientData = ace.getClientData(); - GroupDataModel group = ace.getGroup(); + AddClientEvent addClientEvent = (AddClientEvent) event; + ClientData clientData = addClientEvent.getClientData(); + GroupDataModel group = addClientEvent.getGroup(); group.setServerDataModel(this); addClientToGroup(clientData, group); // XXX: this must occur after we add the client to the group because addClientToGroup() sets // the position according to the spacing algorithm. - System.err.println("setting client: " + clientData.getId() + " to position: " + ace.getPosition()); - clientData.setPosition(ace.getPosition()); - -// AddClientEvent ace = (AddClientEvent) persistableEvent; -// addClient(ace.getClientData()); + clientData.setPosition(addClientEvent.getPosition()); } else if (event instanceof ResourcesAddedEvent) { ResourcesAddedEvent resourcesAddedEvent = (ResourcesAddedEvent) event; @@ -137,34 +97,30 @@ addResource(resourceAddedEvent.getGroup(), resourceAddedEvent.getResource()); } else if (event instanceof RealTimeSanctionRequest) { -// getGroup(event.getId()).handle(event); + // currently unhandled. } else if (event instanceof ResetTokenDistributionRequest) { - getGroup(event.getId()).resetResourceDistribution(); } else if (event instanceof TokenCollectedEvent) { - TokenCollectedEvent tce = (TokenCollectedEvent) event; - getGroup(event.getId()).removeResource(tce.getLocation()); + TokenCollectedEvent tokenCollectedEvent = (TokenCollectedEvent) event; + getGroup(event.getId()).removeResource(tokenCollectedEvent.getLocation()); } else if (event instanceof ExplicitCollectionModeRequest) { ExplicitCollectionModeRequest request = (ExplicitCollectionModeRequest) event; - Identifier id = request.getId(); - ClientData client = getClientData(id); - client.setExplicitCollectionMode(request.isExplicitCollectionMode()); + getClientData(request.getId()).setExplicitCollectionMode(request.isExplicitCollectionMode()); } else { - // FIXME: this is pretty draconian, maybe relax this a little bit - // later. - logger.warning("could not apply event:" + event); + logger.warning("unapplied event:" + event); } } - - private void removeResource(GroupDataModel group, Point position) { - group.removeResource(position); + + public synchronized void removeClient(Identifier id) { + GroupDataModel groupDataModel = clientsToGroups.remove(id); + groupDataModel.removeClient(id); } - public void addClient(ClientData clientData) { + public synchronized void addClient(ClientData clientData) { // iterate through all existing groups and try to add to them. for (GroupDataModel group : getGroups()) { if (group.isFull()) { @@ -177,8 +133,8 @@ GroupDataModel group = new GroupDataModel(this); addClientToGroup(clientData, group); } - - public void addClientToGroup(ClientData clientData, GroupDataModel group) { + + public synchronized void addClientToGroup(ClientData clientData, GroupDataModel group) { group.addClient(clientData); clientsToGroups.put(clientData.getId(), group); channel.handle(new AddClientEvent(clientData, group, clientData.getPosition())); @@ -188,26 +144,26 @@ group.addResource(position); channel.handle(new ResourceAddedEvent(group, position)); } - + public void moveResources(GroupDataModel group, Collection<Point> removedPoints, Collection<Point> addedPoints) { // first remove all resources group.moveResources(removedPoints, addedPoints); channel.handle(new TokensMovedEvent(removedPoints, addedPoints)); } - + public void addResources(GroupDataModel group, Set<Resource> resources) { group.addResources(resources); channel.handle(new ResourcesAddedEvent(group, resources)); } - + public void moveResource(GroupDataModel group, Point oldLocation, Point newLocation) { group.addResource(newLocation); group.removeResource(oldLocation); channel.handle(new TokenMovedEvent(oldLocation, newLocation)); } - + public void moveResources(GroupDataModel group, List<Point> oldLocations, List<Point> newLocations) { - + } public void clearResourceDistribution() { @@ -215,7 +171,7 @@ group.clearResourceDistribution(); } } - + public Set<Point> getResourcePositions(Identifier id) { return clientsToGroups.get(id).getResourcePositions(); } @@ -225,7 +181,7 @@ int y = random.nextInt(getBoardHeight()); return new Point(x, y); } - + public FractalTerrain getTerrain() { return terrain; } @@ -233,7 +189,7 @@ public void setTerrain(FractalTerrain terrain) { this.terrain = terrain; } - + public void postProcessCleanup() { for (GroupDataModel group : clientsToGroups.values()) { group.clearDiffLists(); @@ -252,7 +208,7 @@ iter.remove(); } } - + public Map<Identifier, ClientData> getClientDataMap() { Map<Identifier, ClientData> clientDataMap = new HashMap<Identifier, ClientData>(); for (Map.Entry<Identifier, GroupDataModel> entry : clientsToGroups.entrySet()) { @@ -262,12 +218,12 @@ } return clientDataMap; } - + public void moveClient(Identifier id, Direction d) { getGroup(id).moveClient(id, d); channel.handle(new MovementEvent(id, d)); } - + public Point getClientPosition(Identifier id) { GroupDataModel group = clientsToGroups.get(id); return group.getClientPosition(id); @@ -276,7 +232,7 @@ public int getNumberOfClients() { return clientsToGroups.keySet().size(); } - + public Set<GroupDataModel> getGroups() { Set<GroupDataModel> groups = new LinkedHashSet<GroupDataModel>(); groups.addAll(clientsToGroups.values()); @@ -294,7 +250,7 @@ } return group; } - + /** * Returns a Map<Identifier, Point> representing the latest client * positions. @@ -310,15 +266,15 @@ public int getTokensConsumedBy(Identifier id) { return clientsToGroups.get(id).getCurrentTokens(id); } - + public boolean lockResource(LockResourceRequest event) { // lock resource System.err.println("Modifying lock status for resource: " + event.getResource() + " from station: " + event.getId()); return clientsToGroups.get(event.getId()).lockResource(event); } - + public void unlockResource(UnlockResourceRequest event) { clientsToGroups.get(event.getId()).unlockResource(event); } @@ -329,7 +285,7 @@ GroupDataModel group = clientsToGroups.get(id); group.harvestResource(id, event.getResource()); } - + public void harvestFruits(HarvestFruitRequest event) { Identifier id = event.getId(); GroupDataModel group = clientsToGroups.get(id); @@ -354,49 +310,49 @@ GroupDataModel group = clientsToGroups.get(clientId); return group.getClientDataMap(); } - + public void setGroups(Collection<GroupDataModel> groups) { for (GroupDataModel group: groups) { group.setServerDataModel(this); - + for (Identifier id: group.getClientIdentifiers()) { clientsToGroups.put(id, group); } } } - + /** * Resets this server data model by performing the following: * * 1. Sets event channel to a no-op event channel. */ public void setNullEventChannel() { - super.channel = new EventTypeChannel() { - public void handle(Event event) { } - }; + super.channel = new EventTypeChannel() { + public void handle(Event event) { } + }; } - + public void resetGroupResourceDistributions() { - for (GroupDataModel group: getGroups()) { - group.resetResourceDistribution(); - } + for (GroupDataModel group: getGroups()) { + group.resetResourceDistribution(); + } } - + public void reinitialize() { - setNullEventChannel(); - resetGroupResourceDistributions(); - // initialize all client positions - for (GroupDataModel group: getGroups()) { - for (ClientData clientData: group.getClientDataMap().values()) { - clientData.initializePosition(); - } - } + setNullEventChannel(); + resetGroupResourceDistributions(); + // initialize all client positions + for (GroupDataModel group: getGroups()) { + for (ClientData clientData: group.getClientDataMap().values()) { + clientData.initializePosition(); + } + } } - + public boolean isLastRound() { return getRoundConfiguration().isLastRound(); } - + private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); for (GroupDataModel group: getGroups()) { @@ -409,4 +365,8 @@ logger = Logger.getLogger( getClass().getName() ); random = new Random(); } + + public void unapply(PersistableEvent persistableEvent) { + logger.warning("unapply() not implemented yet: " + persistableEvent); + } } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2009-10-30 22:18:42 UTC (rev 350) @@ -234,6 +234,7 @@ } }); addEventProcessor(new EventTypeProcessor<DisconnectionRequest>(DisconnectionRequest.class) { + @Override public void handle(DisconnectionRequest event) { synchronized (clients) { logger.warning("Disconnecting client, removing from clients: " + event.getId()); @@ -404,6 +405,7 @@ }); addEventProcessor(new EventTypeProcessor<ShowInstructionsRequest>(ShowInstructionsRequest.class) { public void handle(ShowInstructionsRequest event) { + // FIXME: assign groups? if (event.getId().equals(facilitatorId)) { logger.info("Show Instructions request from facilitator - showing round instructions."); for (Identifier id: clients.keySet()) { @@ -435,11 +437,20 @@ } } }); +// addEventProcessor(new EventTypeProcessor<BeginVotingRequest>(BeginVotingRequest.class) { +// public void handle(BeginVotingRequest request) { +// if (getConfiguration().getCurrentParameters().isVotingEnabled()) { +// +// } +// } +// }); addEventProcessor(new EventTypeProcessor<BeginChatRoundRequest>(BeginChatRoundRequest.class) { public void handle(BeginChatRoundRequest request) { if (getConfiguration().getCurrentParameters().isChatEnabled()) { - // FIXME: need to handle properly corner case where chat is enabled before the first round - + // FIXME: need to handle properly corner case where chat is enabled before the first round // at that point the clients haven't been added to any groups yet. + // probably the best way to handle this is to have the clients added + // to groups when the show instructions request is handled. for (Map.Entry<Identifier, ClientData> entry: clients.entrySet()) { Identifier id = entry.getKey(); ClientData clientData = entry.getValue(); @@ -485,6 +496,7 @@ persister.store(request); } + // FIXME: remove Dispatcher reference if it's unused. public void execute(Dispatcher dispatcher) { switch (serverState) { case ROUND_IN_PROGRESS: Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-10-29 23:15:38 UTC (rev 349) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-10-30 22:18:42 UTC (rev 350) @@ -1,14 +1,9 @@ package edu.asu.commons.foraging.util; import java.awt.Dimension; -import java.awt.Graphics2D; import java.awt.Point; -import java.awt.image.BufferedImage; import java.io.File; -import java.io.IOException; -import java.io.OutputStream; import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -20,8 +15,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.PersistableEvent; @@ -29,7 +22,6 @@ import edu.asu.commons.experiment.SaveFileProcessor; import edu.asu.commons.experiment.SavedRoundData; import edu.asu.commons.foraging.conf.RoundConfiguration; -import edu.asu.commons.foraging.event.AddClientEvent; import edu.asu.commons.foraging.event.ClientPoseUpdate; import edu.asu.commons.foraging.event.HarvestFruitRequest; import edu.asu.commons.foraging.event.HarvestResourceRequest; @@ -37,7 +29,6 @@ import edu.asu.commons.foraging.event.ResourceAddedEvent; import edu.asu.commons.foraging.event.ResourcesAddedEvent; import edu.asu.commons.foraging.event.TokenCollectedEvent; -import edu.asu.commons.foraging.facilitator.GroupView; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; import edu.asu.commons.foraging.model.GroupDataModel; @@ -57,26 +48,25 @@ * @version $Rev$ */ public class ForagingSaveFileConverter { - - + public static boolean convert(String saveDataDirectory) { File allSaveFilesDirectory = new File(saveDataDirectory); if (allSaveFilesDirectory.exists() && allSaveFilesDirectory.isDirectory()) { List<SaveFileProcessor> processors = new ArrayList<SaveFileProcessor>(); processors.addAll(Arrays.asList( - new MovieCreatorProcessor() -// new AllDataProcessor(), -// new AggregateTimeIntervalProcessor(), -// new SummaryProcessor(), -// new CollectedTokenSpatialDistributionProcessor(), -// new MovementStatisticsProcessor() - )); + new AllDataProcessor(), + new AggregateTimeIntervalProcessor(), + new SummaryProcessor(), + new CollectedTokenSpatialDistributionProcessor(), + new MovementStatisticsProcessor(), + new MovieCreatorProcessor() + )); Persister.processSaveFiles(allSaveFilesDirectory, processors); return true; } return false; } - + public static void main(String[] args) { if (args.length == 0) { System.err.println("Usage: java " + ForagingSaveFileConverter.class + " <save-data-directory>"); @@ -84,136 +74,11 @@ } convert(args[0]); } - - private static class MovieCreatorProcessor extends SaveFileProcessor.Base { - - private VideoFormat videoFormat; - - public MovieCreatorProcessor() { - this(VideoFormat.PNG); - } - - public MovieCreatorProcessor(VideoFormat videoFormat) { - this.videoFormat = videoFormat; - } - - @Override - public void process(SavedRoundData savedRoundData, OutputStream stream) { - // hmm, there needs to be one output stream per group because we write 1 video per group. - // QuickTimeOutputStream quickTimeOutputStream = new QuickTimeOutputStream(stream, videoFormat); - ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); - RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); - final List<GroupView> groupViewList = new ArrayList<GroupView>(); - final Map<GroupView, QuickTimeOutputStream> groupViewMap = new HashMap<GroupView, QuickTimeOutputStream>(); - serverDataModel.reinitialize(); - List<JFrame> jframes = new ArrayList<JFrame>(); - Dimension dimension = new Dimension(800, 800); - File savedRoundDataFile = new File(savedRoundData.getSaveFilePath()); - String saveFilePath = savedRoundDataFile.getName(); - for (GroupDataModel groupDataModel: serverDataModel.getGroups()) { - GroupView groupView = new GroupView(dimension, groupDataModel); - groupView.setup(roundConfiguration); - groupViewList.add(groupView); - try { - File groupMovieFile = new File(savedRoundDataFile.getCanonicalPath() + "-group-" + groupViewList.size() + "-" + saveFilePath + ".mov"); - groupViewMap.put(groupView, new QuickTimeOutputStream(groupMovieFile, videoFormat)); - } - catch (IOException exception) { - exception.printStackTrace(); - } - JFrame jframe = new JFrame("Group: " + groupViewList.size()); - jframe.add(groupView); - jframe.pack(); - jframe.setVisible(true); - jframes.add(jframe); - } - int secondHasPassedCheck = -1; - // grab out all add client events to initialize the state of the game properly. - for (PersistableEvent event: savedRoundData.getActions()) { - if (event instanceof AddClientEvent) { - System.err.println("Adding client: " + event); - serverDataModel.apply(event); - } - } - for (PersistableEvent event: savedRoundData.getActions()) { - final int elapsedTimeInSeconds = savedRoundData.getElapsedTimeInSeconds(event); - System.err.println("elapsed time in seconds: " + elapsedTimeInSeconds + ":" + event); - serverDataModel.apply(event); - if (elapsedTimeInSeconds > secondHasPassedCheck) { - secondHasPassedCheck = elapsedTimeInSeconds; - // take a snapshot of each group... - for (final GroupView groupView: groupViewList) { - try { -// groupView.repaint(); - final Dimension groupViewSize = groupView.getSize(); - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - Graphics2D graphics = (Graphics2D) groupView.getGraphics(); - - BufferedImage bufferedImage = graphics.getDeviceConfiguration().createCompatibleImage(groupViewSize.width, groupViewSize.height); - Graphics2D bufferedImageGraphics = bufferedImage.createGraphics(); - groupView.paint(bufferedImageGraphics); - try { - // currently each frame is 1 second.. maybe we can divvy this up so it's .5 seconds instead. - groupViewMap.get(groupView).writeFrame(bufferedImage, 600); - } - catch (IOException exception) { - exception.printStackTrace(); - throw new RuntimeException(exception); - } - - // write buffered image out to sequentially named file..? -// try { -// ImageIO.write(bufferedImage, videoFormat.name(), new File(elapsedTimeInSeconds + "-group-" + groupViewList.indexOf(groupView) + "." + videoFormat.name())); -// } -// catch (IOException e) { -// e.printStackTrace(); -// throw new RuntimeException(e); -// } - } - }); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - for (QuickTimeOutputStream out : groupViewMap.values()) { - try { - out.close(); - } - catch (IOException exception) { - exception.printStackTrace(); - } - } - for (JFrame jframe : jframes) { - jframe.setVisible(false); - jframe.dispose(); - } - } - - - @Override - public void process(SavedRoundData savedRoundData, PrintWriter writer) { - throw new UnsupportedOperationException("This method is not suitable for this class (consider removing as requirement for super class)"); - } - - @Override - public String getOutputFileExtension() { - String videoFormatString = videoFormat.toString().toLowerCase(); - return String.format("-%s-movie.%s", videoFormatString, videoFormatString); - } - } - private static class MovementStatisticsProcessor extends SaveFileProcessor.Base { private Map<Identifier, ClientMovementStatistics> clientStatisticsMap = new LinkedHashMap<Identifier, ClientMovementStatistics>(); private Map<GroupDataModel, Integer> resourceCountMap = new HashMap<GroupDataModel, Integer>(); - + @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); @@ -235,7 +100,6 @@ } else { // stop counting for this group. -// System.err.println("Ignoring movement due to 0 resource count " + movementEvent + resourceCountMap); } } else if (event instanceof ResourcesAddedEvent) { @@ -253,7 +117,6 @@ resourceCountMap.put(groupDataModel, resources - 1); } } -// System.err.println("resource count map: " + resourceCountMap); // tally their very last movement counts // (since ClientMovementStatistics only adds to the movement distribution when they change direction) for (ClientMovementStatistics summary: clientStatisticsMap.values()) { @@ -267,7 +130,7 @@ // write out the header line. writer.println(Utils.join(',', "Identifier", Utils.join(',', Arrays.asList(movementHeader)))); - + // and then write out each Identifier's movement distribution. for (Map.Entry<Identifier, ClientMovementStatistics> entry : clientStatisticsMap.entrySet()) { writer.println(Utils.join(',', entry.getKey(), Utils.join(',', @@ -279,15 +142,15 @@ public String getOutputFileExtension() { return "-movement-summary-statistics.txt"; } - + @Override public void dispose() { clientStatisticsMap.clear(); resourceCountMap.clear(); } - + } - + /** * Helper class to keep track of client movements. */ @@ -298,11 +161,21 @@ private int[] movementDistribution; private int currentMoveCount = 0; private int allMoves; + public ClientMovementStatistics(Identifier id, RoundConfiguration configuration) { this.id = id; int maximumNumberOfMoves = Math.max(configuration.getBoardSize().height, configuration.getBoardSize().width); movementDistribution = new int[maximumNumberOfMoves]; } + + private void incrementMovementDistribution() { + int movementDistributionIndex = Math.min(currentMoveCount, movementDistribution.length-1); + if (movementDistributionIndex > 0) { + movementDistribution[movementDistributionIndex-1]++; + } + currentMoveCount = 1; + } + public synchronized void move(Direction direction) { if (direction != null) { allMoves++; @@ -319,21 +192,15 @@ incrementMovementDistribution(); } } - private void incrementMovementDistribution() { - int movementDistributionIndex = Math.min(currentMoveCount, movementDistribution.length-1); - if (movementDistributionIndex > 0) { - movementDistribution[movementDistributionIndex-1]++; - } - currentMoveCount = 1; - } + public Integer[] getMovementDistribution() { -// return Arrays.copyOf(movementDistribution, movementDistribution.length); Integer[] rv = new Integer[movementDistribution.length]; for (int i = 0; i < movementDistribution.length; i++) { rv[i] = Integer.valueOf(movementDistribution[i]); } return rv; } + public void validate() { int sum = 0; for (int i = 0; i < movementDistribution.length; i++) { @@ -344,7 +211,7 @@ } } } - + private static class CollectedTokenSpatialDistributionProcessor extends SaveFileProcessor.Base { @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { @@ -383,12 +250,12 @@ groupWeightedSpatialMetric /= totalTokens; writer.println(groupWeightedSpatialMetric); } -// for (Map.Entry<Identifier, ClientSpatialDistribution> entry: clientSpatialDistributionMap.entrySet()) { -// Identifier id = entry.getKey(); -// ClientSpatialDistribution spatialDistribution = entry.getValue(); -// spatialDistribution.calculateStandardDeviation(); -// writer.println(String.format("%s, %s", id, spatialDistribution.weightedSpatialMetric)); -// } + // for (Map.Entry<Identifier, ClientSpatialDistribution> entry: clientSpatialDistributionMap.entrySet()) { + // Identifier id = entry.getKey(); + // ClientSpatialDistribution spatialDistribution = entry.getValue(); + // spatialDistribution.calculateStandardDeviation(); + // writer.println(String.format("%s, %s", id, spatialDistribution.weightedSpatialMetric)); + // } } @Override @@ -396,7 +263,7 @@ return "-spatial-distribution.txt"; } } - + private static class ClientSpatialDistribution { private int[] rowCounts; private double standardizedRowDistribution; @@ -424,7 +291,7 @@ standardizedColumnDistribution = (columnStandardDeviation / averageTokens); weightedSpatialMetric = tokens * (rowStandardDeviation + columnStandardDeviation); } - + private double stdDev(int[] counts) { // calculate mean int totalTokensInRow = sum(counts); @@ -445,22 +312,11 @@ return total; } } - + private static class SummaryProcessor extends SaveFileProcessor.Base { @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); - /* - for (GroupDataModel group: new TreeSet<GroupDataModel>(serverDataModel.getGroups())) { - writer.println( - String.format("%s, %s, %s, %s", - group.toString(), - Utils.join(',', new TreeSet<Identifier>(group.getClientIdentifiers())), - group.getResourceDistributionSize(), - Utils.join(',', group.getResourceDistribution().keySet()) - )); - } - */ List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); for (GroupDataModel group: groups) { int totalConsumedGroupTokens = 0; @@ -471,12 +327,12 @@ } writer.println( String.format("%s, %s, %s, %s", - "Group #" + groups.indexOf(group), - Utils.join(',', clientTokens), - group.getResourceDistributionSize(), - totalConsumedGroupTokens, - Utils.join(',', group.getResourceDistribution().keySet()) - )); + "Group #" + groups.indexOf(group), + Utils.join(',', clientTokens), + group.getResourceDistributionSize(), + totalConsumedGroupTokens, + Utils.join(',', group.getResourceDistribution().keySet()) + )); } // FIXME: should update later once we fix rolling chat logs. Map<GroupDataModel, SortedSet<ChatRequest>> chatRequestMap = new HashMap<GroupDataModel, SortedSet<ChatRequest>>(); @@ -486,10 +342,10 @@ for (ChatRequest request: savedRoundData.getChatRequests()) { // FIXME: hack to deal with rolling chat logs, eventually should only have per-round chat requests // in savedRoundData. -// if (request.getCreationTime() < lastCreationTime) { -// continue; -// } - + // if (request.getCreationTime() < lastCreationTime) { + // continue; + // } + GroupDataModel group = serverDataModel.getGroup(request.getSource()); if (chatRequestMap.containsKey(group)) { chatRequestMap.get(group).add(request); @@ -503,9 +359,9 @@ // FIXME: hack to deal with rolling chat logs // set last creation time to the last chat request that occurred so in the next chat round // we'll know if we repeated a chat request. -// ChatRequest last = allChatRequests.last(); -// lastCreationTime = last.getCreationTime(); -// System.err.println("last creation time: " + lastCreationTime + " - " + last); + // ChatRequest last = allChatRequests.last(); + // lastCreationTime = last.getCreationTime(); + // System.err.println("last creation time: " + lastCreationTime + " - " + last); for (GroupDataModel group: groups) { SortedSet<ChatRequest> chatRequests = chatRequestMap.get(group); if (chatRequests != null) { @@ -524,7 +380,7 @@ return "-summary.txt"; } } - + private static class AllDataProcessor extends SaveFileProcessor.Base { @Override @@ -542,9 +398,9 @@ processData3d(savedRoundData, writer); } } - + private void processData2d(SavedRoundData savedRoundData, PrintWriter writer) { -// RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); + // RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); SortedSet<PersistableEvent> actions = savedRoundData.getActions(); ServerDataModel model = (ServerDataModel) savedRoundData.getDataModel(); Map<Identifier, ClientMovementTokenCount> clientMovementTokenCounts = createClientMovementTokenCounts(model); @@ -564,7 +420,7 @@ client.moves, movementEvent.getDirection(), "movement event" - ); + ); writer.println(line); } else if (event instanceof TokenCollectedEvent) { @@ -581,7 +437,7 @@ location.y, groups.indexOf(group), client.tokens, - "token collected event"); + "token collected event"); writer.println(line); } else if (event instanceof ResourcesAddedEvent) { @@ -642,7 +498,7 @@ resource.getAge(), roundConfiguration.getTokensPerFruits(), clientStats.tokens, - "harvest fruit"); + "harvest fruit"); writer.println(line); } else if (event instanceof HarvestResourceRequest) { @@ -659,15 +515,15 @@ resource.getAge(), roundConfiguration.calculateTokens(resource.getAge()), clientStats.tokens, - "harvest resource"); + "harvest resource"); System.err.println("harvest resource request: " + line); writer.println(line); } } } } - - + + public static class AggregateTimeIntervalProcessor extends SaveFileProcessor.Base { private static int secondsPerInterval = 5; public void process(SavedRoundData savedRoundData, PrintWriter writer) { @@ -681,32 +537,32 @@ RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); TreeSet<Identifier> orderedIdentifiers = new TreeSet<Identifier>(serverDataModel.getClientDataMap().keySet()); List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); - -// XXX: not really any better than the below, and actually more inefficient to boot. Damn. -// List<String> foo = Utils.map(orderedIdentifiers, new Utils.MapOp<Identifier, String>() { -// public String apply(Identifier id) { -// return id + " movement"; -// } -// }); - + // XXX: not really any better than the below, and actually more inefficient to boot. Damn. + // List<String> foo = Utils.map(orderedIdentifiers, new Utils.MapOp<Identifier, String>() { + // public String apply(Identifier id) { + // return id + " movement"; + // } + // }); + + List<String> movementHeader = new ArrayList<String>(); List<String> collectedTokensHeader = new ArrayList<String>(); for (Identifier id: orderedIdentifiers) { movementHeader.add(id + " moves"); collectedTokensHeader.add(id + " tokens collected"); } - + // headers for average probability of a token for each group -// List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); + // List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); // headers for tokens left in each group -// List<String> tokensLeftGroupNumberHeader = new ArrayList<String>(); + // List<String> tokensLeftGroupNumberHeader = new ArrayList<String>(); List<String> distanceHeader = new ArrayList<String>(); for (int groupIndex = 0; groupIndex < groups.size(); groupIndex++) { String groupNumber = "Group-" + groupIndex; -// tokenProbabilityGroupNumberHeader.add(groupNumber + " avg token P"); -// tokensLeftGroupNumberHeader.add(groupNumber + " tokens left"); + // tokenProbabilityGroupNumberHeader.add(groupNumber + " avg token P"); + // tokensLeftGroupNumberHeader.add(groupNumber + " tokens left"); List<Identifier> ids = new ArrayList<Identifier>(groups.get(groupIndex).getOrderedClientIdentifiers()); for (int i = 0; i < ids.size(); i++) { Identifier id = ids.get(i); @@ -716,28 +572,28 @@ } } } - + // write out the header String header = Utils.join(',', "Period", - // moves taken - Utils.join(',', movementHeader), - // tokens - Utils.join(',', collectedTokensHeader), - // group token probabilities -// Utils.join(',', tokenProbabilityGroupNumberHeader), - // group total tokens left -// Utils.join(',', tokensLeftGroupNumberHeader), - // distance between participants - Utils.join(',', distanceHeader) - ); + // moves taken + Utils.join(',', movementHeader), + // tokens + Utils.join(',', collectedTokensHeader), + // group token probabilities + // Utils.join(',', tokenProbabilityGroupNumberHeader), + // group total tokens left + // Utils.join(',', tokensLeftGroupNumberHeader), + // distance between participants + Utils.join(',', distanceHeader) + ); writer.println(header); - + int currentInterval = 0; for (PersistableEvent event: savedRoundData.getActions()) { int secondsElapsed = savedRoundData.getElapsedTimeInSeconds(event); int endOfInterval = (currentInterval + 1) * secondsPerInterval; -// System.err.println("seconds elapsed: " + secondsElapsed); -// System.err.println("end of interval: " + endOfInterval); + // System.err.println("seconds elapsed: " + secondsElapsed); + // System.err.println("end of interval: " + endOfInterval); // see if the current persistable event is past the threshold, // meaning we should take a snapshot of our currently @@ -757,13 +613,13 @@ stats.reset(); } String dataline = - Utils.join(',', endOfInterval, - Utils.join(',', movesTaken), - Utils.join(',', harvestedTokens), - Utils.join(',', expectedTokenProbabilities), - Utils.join(',', tokensLeft), - Utils.join(',', distances) - ); + Utils.join(',', endOfInterval, + Utils.join(',', movesTaken), + Utils.join(',', harvestedTokens), + Utils.join(',', expectedTokenProbabilities), + Utils.join(',', tokensLeft), + Utils.join(',', distances) + ); writer.println(dataline); currentInterval++; } @@ -821,7 +677,7 @@ } return distances; } - + private List<Double> getExpectedTokenProbabilities(ServerDataModel state) { List<Double> expectedTokens = new ArrayList<Double>(); Set<GroupDataModel> groups = state.getGroups(); @@ -840,7 +696,7 @@ } return expectedTokens; } - + private List<Integer> getTokensLeft(Collection<GroupDataModel> groups) { List<Integer> tokensLeft = new ArrayList<Integer>(); for (GroupDataModel group: groups) { @@ -848,15 +704,15 @@ } return tokensLeft; } - + @Override public String getOutputFileExtension() { return "-aggregated-time-interval-data.txt"; } - + } - + private static class ClientMovementTokenCount { private int moves = 0; private int tokens = 0; @@ -864,7 +720,7 @@ moves = 0; tokens = 0; } - + } public static Map<Identifier, ClientMovementTokenCount> createClientMovementTokenCounts(ServerDataModel model) { Map<Identifier, ClientMovementTokenCount> clientStats = new HashMap<Identifier, ClientMovementTokenCount>(); Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreatorProcessor.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreatorProcessor.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/MovieCreatorProcessor.java 2009-10-30 22:18:42 UTC (rev 350) @@ -0,0 +1,150 @@ +package edu.asu.commons.foraging.util; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +import edu.asu.commons.event.PersistableEvent; +import edu.asu.commons.experiment.SaveFileProcessor; +import edu.asu.commons.experiment.SavedRoundData; +import edu.asu.commons.foraging.conf.RoundConfiguration; +import edu.asu.commons.foraging.event.AddClientEvent; +import edu.asu.commons.foraging.facilitator.GroupView; +import edu.asu.commons.foraging.model.GroupDataModel; +import edu.asu.commons.foraging.model.ServerDataModel; + +/** + * $Id$ + * + * Foraging save file processor to create quicktime movies. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev$ + */ +class MovieCreatorProcessor extends SaveFileProcessor.Base { + + private VideoFormat videoFormat; + + public MovieCreatorProcessor() { + this(VideoFormat.PNG); + } + + public MovieCreatorProcessor(VideoFormat videoFormat) { + this.videoFormat = videoFormat; + } + + @Override + public void process(SavedRoundData savedRoundData, OutputStream stream) { + // hmm, there needs to be one output stream per group because we write 1 video per group. + // QuickTimeOutputStream quickTimeOutputStream = new QuickTimeOutputStream(stream, videoFormat); + ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); + RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); + final List<GroupView> groupViewList = new ArrayList<GroupView>(); + final Map<GroupView, QuickTimeOutputStream> groupViewMap = new HashMap<GroupView, QuickTimeOutputStream>(); + serverDataModel.reinitialize(); + List<JFrame> jframes = new ArrayList<JFrame>(); + Dimension dimension = new Dimension(800, 800); + File savedRoundDataFile = new File(savedRoundData.getSaveFilePath()); + String saveFilePath = savedRoundDataFile.getName(); + for (GroupDataModel groupDataModel: serverDataModel.getGroups()) { + GroupView groupView = new GroupView(dimension, groupDataModel); + groupView.setup(roundConfiguration); + groupViewList.add(groupView); + try { + File groupMovieFile = new File(savedRoundDataFile.getCanonicalPath() + "-group-" + groupViewList.size() + "-" + saveFilePath + ".mov"); + groupViewMap.put(groupView, new QuickTimeOutputStream(groupMovieFile, videoFormat)); + } + catch (IOException exception) { + exception.printStackTrace(); + } + JFrame jframe = new JFrame("Group: " + groupViewList.size()); + jframe.add(groupView); + jframe.pack(); + jframe.setVisible(true); + jframes.add(jframe); + } + int secondHasPassedCheck = -1; + // grab out all add client events to initialize the state of the game properly. + for (PersistableEvent event: savedRoundData.getActions()) { + if (event instanceof AddClientEvent) { + System.err.println("Adding client: " + event); + serverDataModel.apply(event); + } +... [truncated message content] |