virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 76)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <see...@us...> - 2009-04-02 23:53:36
|
Revision: 89 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=89&view=rev Author: seematalele Date: 2009-04-02 23:53:20 +0000 (Thu, 02 Apr 2009) Log Message: ----------- added flex configuration in web.xml and applicationContext.xml Modified Paths: -------------- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml Added Paths: ----------- mentalmodels/trunk/src/main/webapp/WEB-INF/testdrive-servlet.xml Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-04-02 21:50:46 UTC (rev 88) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-04-02 23:53:20 UTC (rev 89) @@ -9,12 +9,37 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" + xmlns:flex="http://www.springframework.org/schema/flex" + xmlns:security="http://www.springframework.org/schema/security" + xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd + http://www.springframework.org/schema/tx + http://www.springframework.org/schema/tx/spring-tx.xsd + http://www.springframework.org/schema/security/spring-security-2.0.4.xsd + http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd "> +<!-- Flex related information started --> +<flex:message-broker> + <flex:secured /> +</flex:message-broker> +<!-- Implementation of StudentImpl --> + +<bean id="studentservice" class="student.StudentDAO"> + <constructor-arg ref="mySessionFactory" /> +</bean> + +<!-- Expose the productDAO bean for BlazeDS remoting --> +<flex:remote-service ref="studentservice" /> + + +<!-- Flex related information ended--> + + + <bean id="mmeDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost/mme"/> @@ -22,6 +47,8 @@ <property name="password" value=""/> </bean> + + <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="/WEB-INF/hibernate.properties"/> <property name="beanName" value="mmeDataSource"/> Added: mentalmodels/trunk/src/main/webapp/WEB-INF/testdrive-servlet.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/testdrive-servlet.xml (rev 0) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/testdrive-servlet.xml 2009-04-02 23:53:20 UTC (rev 89) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> + +</beans> \ No newline at end of file Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml 2009-04-02 21:50:46 UTC (rev 88) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml 2009-04-02 23:53:20 UTC (rev 89) @@ -4,4 +4,40 @@ --> <web-app> <display-name>Mental Models Experiment</display-name> + <context-param> + <param-name>contextConfigLocation</param-name> + <param-value> + /WEB-INF/applicationContext.xml + </param-value> + </context-param> + + <filter> + <filter-name>springSecurityFilterChain</filter-name> + <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> + </filter> + + <filter-mapping> + <filter-name>springSecurityFilterChain</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <listener> + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> + </listener> + + <servlet> + <servlet-name>testdrive</servlet-name> + <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>testdrive</servlet-name> + <url-pattern>/messagebroker/*</url-pattern> + </servlet-mapping> + + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> + </web-app> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-04-02 21:50:52
|
Revision: 88 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=88&view=rev Author: alllee Date: 2009-04-02 21:50:46 +0000 (Thu, 02 Apr 2009) Log Message: ----------- adding skeletal spring/hibernate setup with maven jetty plugin. Still need to configure spring service definitions properly and also set up web.xml properly. Modified Paths: -------------- mentalmodels/trunk/pom.xml Added Paths: ----------- mentalmodels/trunk/src/main/webapp/ mentalmodels/trunk/src/main/webapp/WEB-INF/ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml mentalmodels/trunk/src/main/webapp/WEB-INF/classes/ mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml Modified: mentalmodels/trunk/pom.xml =================================================================== --- mentalmodels/trunk/pom.xml 2009-04-02 20:12:53 UTC (rev 87) +++ mentalmodels/trunk/pom.xml 2009-04-02 21:50:46 UTC (rev 88) @@ -77,6 +77,42 @@ <version>3.2.3.GA</version> </dependency> </dependencies> + <build> + <finalName>mme</finalName> + <testResources> + <testResource> + <directory>src/main/webapp</directory> + </testResource> + </testResources> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>tomcat-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <configuration> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>8080</port> + <maxIdleTime>60000</maxIdleTime> + </connector> + </connectors> + <scanIntervalSeconds>10</scanIntervalSeconds> + <stopKey>tdar</stopKey> + <stopPort>12919</stopPort> + </configuration> + </plugin> + </plugins> + </build> <profiles> <profile> <id>ant</id> Added: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml (rev 0) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-04-02 21:50:46 UTC (rev 88) @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<!-- + vim:sts=2:sw=2: +--> +<!-- + $Id: applicationContext.xml 617 2008-03-28 17:27:23Z alllee $ +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:aop="http://www.springframework.org/schema/aop" + xmlns:tx="http://www.springframework.org/schema/tx" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd + "> + + <bean id="mmeDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> + <property name="driverClassName" value="com.mysql.jdbc.Driver"/> + <property name="url" value="jdbc:mysql://localhost/mme"/> + <property name="username" value="mme"/> + <property name="password" value=""/> + </bean> + + <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="location" value="/WEB-INF/hibernate.properties"/> + <property name="beanName" value="mmeDataSource"/> + </bean> + + + <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> + <property name="configLocation" value="/WEB-INF/hibernate.cfg.xml"/> + <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/> + <property name="hibernateProperties"> + <props> + <prop key="hibernate.cglib.use_reflection_optimizer">false</prop> + <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop> + <prop key="hibernate.show_sql">false</prop> + </props> + </property> + <property name="dataSource" ref="mmeDataSource"/> + </bean> + + <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> + <property name="sessionFactory" ref="sessionFactory"/> + </bean> + <!-- XXX: don't need proxy-target-class if services are interfaces instead..? --> + <tx:annotation-driven proxy-target-class='true'/> + +</beans> Added: mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties (rev 0) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/classes/log4j.properties 2009-04-02 21:50:46 UTC (rev 88) @@ -0,0 +1,15 @@ +# Set root category priority to ERROR and its only appender to A1. +log4j.rootCategory=ERROR, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] (%F:%L) %-5p %c %x - %m%n + +# Add packages to log +log4j.logger.edu.asu.commons=DEBUG + +#log4j.logger.org.springframework=DEBUG +#log4j.logger.org.hibernate=DEBUG Added: mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml (rev 0) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/hibernate.cfg.xml 2009-04-02 21:50:46 UTC (rev 88) @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2: +--> +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> +<hibernate-configuration> + <session-factory> + <mapping class='edu.asu.commons.mme.entity.Student'/> + </session-factory> +</hibernate-configuration> + Added: mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml (rev 0) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/web.xml 2009-04-02 21:50:46 UTC (rev 88) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +vim:sts=2:sw=2 +--> +<web-app> + <display-name>Mental Models Experiment</display-name> +</web-app> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-04-02 20:13:04
|
Revision: 87 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=87&view=rev Author: alllee Date: 2009-04-02 20:12:53 +0000 (Thu, 02 Apr 2009) Log Message: ----------- adding hibernate tools ant build script for generating the schema Modified Paths: -------------- mentalmodels/trunk/pom.xml Added Paths: ----------- mentalmodels/trunk/init-db.ant.xml Added: mentalmodels/trunk/init-db.ant.xml =================================================================== --- mentalmodels/trunk/init-db.ant.xml (rev 0) +++ mentalmodels/trunk/init-db.ant.xml 2009-04-02 20:12:53 UTC (rev 87) @@ -0,0 +1,82 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2 +$Id: init-db.ant.xml 239 2009-03-20 17:49:19Z alllee $ +$Revision: 239 $ +Master build file for TDAR deployment. +--> +<project name="tdar" default="help"> + <!-- get environment vars --> + <property file="hibernate.properties"/> + <!-- + define some sane default values for db connection if undefined in + build.properties + --> + <property name='db.name' value='mme'/> + <property name='hibernate.connection.url' value='jdbc:postgresql://localhost/${db.name}'/> + <property name='hibernate.connection.username' value='mme'/> + <property name='hibernate.connection.password' value=''/> + <property name='hibernate.connection.driver_class' value='com.mysql.jdbc.Driver'/> + <property name='hibernate.dialect' value='org.hibernate.dialect.MySQLInnoDBDialect'/> + <property name='createdb.url' value='jdbc:postgresql://localhost/template1'/> + + <!-- where the applicationContext.xml and hibernate.cfg.xml are currently located, this may change --> + <property name='web.inf.dir' value='src/main/webapp/WEB-INF'/> + <property name='db.dir' value='src/main/db'/> + <property name='db.generated.dir' value='${db.dir}/generated'/> + <!-- + this should always be available, connect to this if we need to create + the tdardev database + --> + + <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpath="${compile.classpath}"/> + <target name="init-db" depends="create-db-schema, create-indexes"/> + <target name='create-db-schema'> + <mkdir dir='${db.generated.dir}'/> + <echo message="You must have valid database connection information within hibernate.properties for this task to succeed."/> + <hibernatetool destdir='${db.generated.dir}'> + <!-- annotated class/packages are specified in the hibernate.cfg.xml --> + <annotationconfiguration propertyFile="hibernate.properties" configurationfile="${web.inf.dir}/hibernate.cfg.xml"/> + <hbm2ddl export="true" drop="true" outputfilename="tdar.sql"/> + </hibernatetool> + </target> + <target name='create-indexes'> + <sql onerror='continue' autocommit='true' driver="${hibernate.connection.driver_class}" url="${hibernate.connection.url}" userid="${hibernate.connection.username}" password="${hibernate.connection.password}" classpath="${compile.classpath}"> + <transaction src="${db.dir}/create-indexes.sql"/> + </sql> + </target> + <target name="initialize-data" depends="init-db"> + <sql driver="${hibernate.connection.driver_class}" + url="${hibernate.connection.url}" + userid="${hibernate.connection.username}" + password="${hibernate.connection.password}" + classpath="${compile.classpath}" + src="${db.dir}/init-tdar.sql"/> + </target> + + <target name='create-db'> + <sql driver='${hibernate.connection.driver_class}' + url='${createdb.url}' + userid='${hibernate.connection.username}' + password='${hibernate.connection.password}' + onerror='continue' + classpath='${compile.classpath}' autocommit='true'> + DROP DATABASE ${db.name}; + CREATE DATABASE ${db.name} WITH ENCODING 'UTF8'; + </sql> + </target> + + <!-- not needed here. + <target name='load-data' depends='create-db'> + <bunzip2 src='${db.dir}/tdar-data.sql.bz2' dest='${db.dir}/tdar-data.sql'/> + <sql driver='${hibernate.connection.driver_class}' + url='${hibernate.connection.url}' + userid='${hibernate.connection.username}' + password='${hibernate.connection.password}' + classpath='${compile.classpath}'> + <transaction src='${db.dir}/tdar-data.sql'/> + <transaction src='${db.dir}/upgrade-db-tdar.struts.sql'/> + </sql> + </target> + --> +</project> Modified: mentalmodels/trunk/pom.xml =================================================================== --- mentalmodels/trunk/pom.xml 2009-04-01 16:40:43 UTC (rev 86) +++ mentalmodels/trunk/pom.xml 2009-04-02 20:12:53 UTC (rev 87) @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <organization> - <name>The Digital Archaeological Record</name> - <url>http://tdar.org</url> + <name>The Virtual Commons</name> + <url>http://dev.commons.asu.edu</url> </organization> <modelVersion>4.0.0</modelVersion> <groupId>edu.asu.commons</groupId> <artifactId>mme</artifactId> <version>0.1-SNAPSHOT</version> - <name>Mental Models Spring Application</name> + <name>Mental Models Application</name> <packaging>war</packaging> <repositories> <repository> <id>dev.commons.asu.edu</id> - <url>http://dev.commons.asu.edu/archiva/internal/repository/</url> + <url>http://dev.commons.asu.edu/archiva/repository/internal/</url> <releases> <enabled>true</enabled> </releases> @@ -37,6 +37,11 @@ </dependency> <dependency> <groupId>org.springframework</groupId> + <artifactId>spring-flex</artifactId> + <version>1.0.0.M2</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> <artifactId>spring-hibernate3</artifactId> <version>2.0-m4</version> </dependency> @@ -71,7 +76,45 @@ <artifactId>hibernate-tools</artifactId> <version>3.2.3.GA</version> </dependency> - </dependencies> + <profiles> + <profile> + <id>ant</id> + <build> + <defaultGoal>antrun:run</defaultGoal> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <goals> + <goal>load</goal> + </goals> + <configuration> + <tasks> + <!-- + can be invoked via + mvn -P ant -D target=initialize-data + --> + <property name="compile.classpath" refid="maven.compile.classpath" /> + <property name="runtime.classpath" refid="maven.runtime.classpath" /> + <property name="test.classpath" refid="maven.test.classpath" /> + <property name="plugin.classpath" refid="maven.plugin.classpath" /> + <ant antfile="${basedir}/init-db.ant.xml" inheritRefs="true" inheritAll="true"> + <target name="${target}" /> + </ant> + </tasks> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>ant-contrib</groupId> + <artifactId>ant-contrib</artifactId> + <version>1.0b2</version> + </dependency> + </dependencies> + </profile> + </profiles> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-04-01 16:40:49
|
Revision: 86 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=86&view=rev Author: alllee Date: 2009-04-01 16:40:43 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Currently going with a minimalist/simplistic pom + maven project setup. Refine this later as we figure out what works best with FlexBuilder + BlazeDS + Spring integration. Added Paths: ----------- mentalmodels/trunk/pom.xml mentalmodels/trunk/src/ mentalmodels/trunk/src/main/ mentalmodels/trunk/src/main/java/ mentalmodels/trunk/src/main/resources/ Added: mentalmodels/trunk/pom.xml =================================================================== --- mentalmodels/trunk/pom.xml (rev 0) +++ mentalmodels/trunk/pom.xml 2009-04-01 16:40:43 UTC (rev 86) @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <organization> + <name>The Digital Archaeological Record</name> + <url>http://tdar.org</url> + </organization> + <modelVersion>4.0.0</modelVersion> + <groupId>edu.asu.commons</groupId> + <artifactId>mme</artifactId> + <version>0.1-SNAPSHOT</version> + <name>Mental Models Spring Application</name> + <packaging>war</packaging> + <repositories> + <repository> + <id>dev.commons.asu.edu</id> + <url>http://dev.commons.asu.edu/archiva/internal/repository/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <dependencies> + <!-- mysql jdbc --> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.6</version> + </dependency> + <!-- spring dependencies --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring</artifactId> + <version>2.5.6</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-hibernate3</artifactId> + <version>2.0-m4</version> + </dependency> + <!-- hibernate and JPA persistence --> + <dependency> + <groupId>javax.persistence</groupId> + <artifactId>persistence-api</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>3.3.1.GA</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>3.3.2.GA</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-annotations</artifactId> + <version>3.4.0.GA</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-ehcache</artifactId> + <version>3.3.1.GA</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-tools</artifactId> + <version>3.2.3.GA</version> + </dependency> + + </dependencies> + +</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. <All...@as...> - 2009-03-31 18:04:49
|
Oops, disregard this message. They haven't updated their meeting site yet, that was for earlier this month. Reading comprehension! On Tue, Mar 31, 2009 at 10:39 AM, Allen Lee <All...@as...> wrote: > The keynote is on Flex + Spring integration. Might be useful to > attend given our current interests. > > http://www.phxjug.org/meetings.html#next > > -- > Allen Lee > Center for the Study of Institutional Diversity [http://csid.asu.edu] > School of Human Evolution and Social Change [http://shesc.asu.edu] > The Virtual Commons [http://commons.asu.edu] > The Digital Archaeological Record [http://www.tdar.org] > The OpenABM Consortium [http://www.openabm.org] > Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 > Office: 480.727.0401 | Fax: 480.965.7671 > -- Allen Lee Center for the Study of Institutional Diversity [http://csid.asu.edu] School of Human Evolution and Social Change [http://shesc.asu.edu] The Virtual Commons [http://commons.asu.edu] The Digital Archaeological Record [http://www.tdar.org] The OpenABM Consortium [http://www.openabm.org] Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 Office: 480.727.0401 | Fax: 480.965.7671 |
From: Allen L. <All...@as...> - 2009-03-31 17:59:36
|
The keynote is on Flex + Spring integration. Might be useful to attend given our current interests. http://www.phxjug.org/meetings.html#next -- Allen Lee Center for the Study of Institutional Diversity [http://csid.asu.edu] School of Human Evolution and Social Change [http://shesc.asu.edu] The Virtual Commons [http://commons.asu.edu] The Digital Archaeological Record [http://www.tdar.org] The OpenABM Consortium [http://www.openabm.org] Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 Office: 480.727.0401 | Fax: 480.965.7671 |
From: <kj...@us...> - 2009-03-28 00:49:41
|
Revision: 85 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=85&view=rev Author: kjonas Date: 2009-03-28 00:49:27 +0000 (Sat, 28 Mar 2009) Log Message: ----------- DataGridHandler actionscript class completed Forecast1, Forecast2 utilize DataGridHandler Forecast2 can be filled from older Forecast1 Modified Paths: -------------- mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml Modified: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-03-28 00:49:27 UTC (rev 85) @@ -2,12 +2,13 @@ <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="absolute"> <mx:VBox> - <mx:HBox> + <mx:HBox id="cast"> <comp:Forecast id="legacy" numColumns="10"/> <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> - <comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/> + <!--<comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/>--> </mx:HBox> <mx:Label initialize="init()"/> + <mx:Button id="next" label="Next" click="testNext()"/> </mx:VBox> <mx:Script> @@ -24,6 +25,16 @@ forecastPeople.setItem(2,2,X); } + public function testNext(evt:Event=null):void + { + if(!forecastPeople.isFinished()) return; + var f2:Forecast2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + f2.oldForecast1 = forecastPeople; + cast.addChild(f2); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-03-28 00:49:27 UTC (rev 85) @@ -2,81 +2,106 @@ package actionscript { import mx.collections.ArrayCollection; + import mx.controls.Alert; import mx.controls.DataGrid; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.utils.StringUtil; + [Bindable] public class DataGridHandler { - private var myDataGrid:DataGrid; - private var myProvider:ArrayCollection; + private var _myDataGrid:DataGrid; + private var _myProvider:ArrayCollection; - private var errorMessage:String = ""; + private var _errorMessage:String = ""; +public var debug:String = new String(); + private var finished:Boolean = false; - private var numFields:Number; - private var numCols:Number; - private var minValue:Number; - private var maxValue:Number; - private var sumOfEachColumn:Number; + private var _numFields:Number; + private var _numColumns:Number; + private var _minValue:Number; + private var _maxValue:Number; + private var _sumOfEachColumn:Number; public function get grid():DataGrid - { return myDataGrid; } + { return _myDataGrid; } public function set grid(newValue:DataGrid):void - { myDataGrid = newValue; } + { _myDataGrid = newValue; } public function get dataProvider():ArrayCollection - { return myProvider; } + { return _myProvider; } public function set dataProvider(newValue:ArrayCollection):void - { myProvider = newValue; } + { _myProvider = newValue; } public function get errorMessage():String - { return errorMessage; } + { return _errorMessage; } public function set errorMessage(newValue:String):void - { errorMessage = newValue; } + { _errorMessage = newValue; } + public function isFinished():Boolean + { + return finished; + } public function get numFields():Number - { return numFields; } + { return _numFields; } public function set numFields(newValue:Number):void - { numFields = newValue; } - public function get numCols():Number - { return numCols; } - public function set numCols(newValue:Number):void - { numCols = newValue; } + { _numFields = newValue; } + public function get numColumns():Number + { return _numColumns; } + public function set numColumns(newValue:Number):void + { _numColumns = newValue; } public function get minValue():Number - { return minValue; } + { return _minValue; } public function set minValue(newValue:Number):void - { minValue = newValue; } + { _minValue = newValue; } public function get maxValue():Number - { return maxValue; } + { return _maxValue; } public function set maxValue(newValue:Number):void - { maxValue = newValue; } + { _maxValue = newValue; } public function get sumOfEachColumn():Number - { return sumOfEachColumn; } + { return _sumOfEachColumn; } public function set sumOfEachColumn(newValue:Number):void - { sumOfEachColumn = newValue; } + { _sumOfEachColumn = newValue; } - public function DataGridHandler(fields:Number, cols:Number, min:Number = 0, max:Number = 9999, colSum:Number = -1) + public function DataGridHandler(fields:Number, cols:Number, min:Number=0, max:Number=9999, colSum:Number=-1) { - numFields = fields; - numCols = cols; - minValue = min; - maxValue = max; - sumOfEachColumn = colSum; - - createGrid(); + try{ + numFields = fields; + numColumns = cols; + minValue = min; + maxValue = max; + sumOfEachColumn = colSum; + + errorMessage = ""; + + createGrid(); + + grid.addEventListener("change", changed); +// dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, changed, false); +// dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, changed, true); + }catch(e:Error){ + Alert.show(e.message); + } } public function getItem(field:Number, col:Number):Object { - return myProvider.getItemAt(field)["day"+(col+1)]; + return dataProvider.getItemAt(field)["day"+(col+1)]; } public function setItem(field:Number, col:Number, value:Object):void { - myProvider.getItemAt(field)["day"+(col+1)] = value; + dataProvider.getItemAt(field)["day"+(col+1)] = value; } - private function createGrid() + private function createGrid():void { - var tempArray:Array = myDataGrid.columns; + grid = new DataGrid(); + + dataProvider = new ArrayCollection(); + + //_myDataGrid.columns = new Array(); + var tempArray:Array = grid.columns; var i:Number; var temp:DataGridColumn; @@ -95,16 +120,19 @@ tempArray[i] = temp; } - myDataGrid.columns = tempArray; + grid.columns = tempArray; // add day1, day2, etc to each field for(var j:Number=0; j<numFields; j++) { var field:Object = new Object(); - myProvider.addItem(field); + dataProvider.addItem(field); } - myDataGrid.height = (23)*(numFields+1)+2; + grid.dataProvider = dataProvider; + grid.height = (23)*(_numFields+1)+2; + grid.editable = true; +debug += ""; } public function clone():DataGrid @@ -135,7 +163,7 @@ dgClone.columns = tempArray; // fill data - for(var j:Number=0; j<numFields; j++) + for(var j:Number=0; j<_numFields; j++) { var field:Object = new Object(); myProviderClone.addItem(field); @@ -145,15 +173,15 @@ } } - dgClone.height = (23)*(numFields+1)+2; + dgClone.height = (23)*(_numFields+1)+2; return dgClone; } - public function changed():void + public function changed(evt:Event=null):void { markNoError(); - errorMessage = "Complete." + errorMessage = ""; var error:Boolean = false; var value:Object; @@ -164,7 +192,7 @@ { var colStr:String = "day"+(col+1); var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) + for(var field:Number=0; field < _numFields && !error; field++) { value = getItem(field, col); if(invalidNum(value)) @@ -187,21 +215,27 @@ // if no other errors yet, and there is a required sum for columns, // then check actual sum against expected - if( ! (error || sumOfEachColumn == -1 || colSum == sumOfEachColumn) ) + if( !error && sumOfEachColumn != -1 && colSum != sumOfEachColumn ) { errorMessage = "Sum of all columns must be exactly "+sumOfEachColumn+"."; error = true; markError(-1,col); - } + debug += "{"+colSum+"}"; + } + else + { + debug += "["+colSum+"]"; + } } + + finished = !error; } private function invalidNum(n:Object):Boolean { if(n == null) return true; - //the entire string must be consecutive digits - var pattern:RegExp = /^\d+$/; + var pattern:RegExp = /^\d+$/; //the entire string must be consecutive digits var s:String = StringUtil.trim(String(n)); - return !pattern.test(s); + return !pattern.test(s) && !(n is Number); } private function outOfBoundsNum(n:Object):Boolean { @@ -210,16 +244,16 @@ private function markError(field:Number, col:Number):void { - DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#3333FF"); - myDataGrid.selectedIndex = field; + DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#ee82ee"); + grid.selectedIndex = field; } private function markNoError():void { for(var col:Number=0; col < numColumns; col++) { - DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); } - myDataGrid.selectedIndex = -1; + grid.selectedIndex = -1; } } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-28 00:49:27 UTC (rev 85) @@ -1,25 +1,30 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> <mx:ArrayCollection id="sched"/> - <mx:HBox> + <mx:HBox id="gridContainer"> <mx:VBox id="labels"> </mx:VBox> - <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" click="changed()"/> + <!--<mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()"/>--> </mx:HBox> - <mx:Label id="lbl"/> - <mx:Label id="debug"/> + <mx:Label id="lbl" text="{dgh.errorMessage}"/> + <!--<mx:Label id="debug" text="{dgh.debug}"/>--> <mx:Script> <![CDATA[ + import mx.controls.DataGrid; + import actionscript.DataGridHandler; import mx.utils.StringUtil; import mx.controls.dataGridClasses.DataGridColumn; [Bindable] + public var dgh:DataGridHandler; + + [Bindable] public var numColumns:Number = 15; [Bindable] public var numFields:Number = 4; @@ -27,19 +32,44 @@ public var minValue:Number = 0; [Bindable] public var maxValue:Number = 10; + [Bindable] + public var colSum:Number = 30; private var errorMessage:String = null; //not used private var colIndex:Number=0; - private var finished:Boolean = false; public function init():void { - createColumns(); + dgh = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); + gridContainer.addChildAt(dgh.grid, 1); +// createColumns(); } - private function createColumns():void + public function changed():void { + dgh.changed(); + } + public function isFinished():Boolean + { + return dgh.isFinished(); + } + public function getItem(field:Number, col:Number):Object + { + return dgh.getItem(field, col); + } + public function setItem(field:Number, col:Number, value:Object):void + { + dgh.setItem(field, col, value); + } + public function clone():DataGrid + { + return dgh.clone(); + } + + + /* private function createColumns():void + { var tempArray:Array = dgMain.columns; var i:Number; var temp:DataGridColumn; @@ -143,7 +173,7 @@ private function markError(field:Number, col:Number):void { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); dgMain.selectedIndex = field; } private function markNoError():void @@ -196,7 +226,7 @@ dgClone.height = (23)*(numFields+1)+2; return dgClone; - } + } */ ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-28 00:49:27 UTC (rev 85) @@ -112,7 +112,7 @@ if(oldForecast1 == null) { setItem(0,1,1); - dgRow2.addChild(newForecast1.dgMain); + dgRow2.addChild(newForecast1.dgh.grid); setItem(1,1,2); } else @@ -193,7 +193,7 @@ private function markError(field:Number, col:Number):void { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); dgMain.selectedIndex = field; } private function markNoError():void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-03-18 20:19:46
|
Revision: 84 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=84&view=rev Author: kjonas Date: 2009-03-18 20:19:28 +0000 (Wed, 18 Mar 2009) Log Message: ----------- DataGridHandler actionscript class added Added Paths: ----------- mentalmodels/trunk/flex/src/FisheryExperiment.mxml mentalmodels/trunk/flex/src/Forecasting.mxml mentalmodels/trunk/flex/src/MME.mxml mentalmodels/trunk/flex/src/Mental.mxml mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml mentalmodels/trunk/flex/src/Socio_demographic.mxml mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/TestApp.mxml mentalmodels/trunk/flex/src/actionscript/ mentalmodels/trunk/flex/src/actionscript/ASResults.as mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/actionscript/RoundConfig.as mentalmodels/trunk/flex/src/customComponents/ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml mentalmodels/trunk/flex/src/customComponents/LongScale.mxml mentalmodels/trunk/flex/src/customComponents/Planner.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml mentalmodels/trunk/flex/src/display.mxml Added: mentalmodels/trunk/flex/src/FisheryExperiment.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperiment.mxml (rev 0) +++ mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,162 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" + backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" + width="760" height="510" clipContent="false" layout="absolute" + currentState="instructions" initialize="init()"> + + <mx:states> + <mx:State name="instructions"> + <mx:AddChild relativeTo="{content}"> + <comp:InstructionPage id="instructions"/> + </mx:AddChild> + </mx:State> + + <mx:State name="socioDemographic"> + <mx:AddChild relativeTo="{content}"> + <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + </mx:AddChild> + </mx:State> + + <mx:State name="planner"> + <mx:AddChild relativeTo="{content}"> + <comp:PlannerPage id="planner"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"/> + </mx:states> + + <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> + <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> + + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + + <mx:Script> + <![CDATA[ + import mx.controls.Label; + import customComponents.*; + + private var shared:SharedObject; + private var flushMessage:String; + + public function init():void + { + var sharedObjTest:Boolean = false; + if(sharedObjTest) + { + var got:Boolean = getLocal(); + if(got) + { + getData().saved1 = "Hello, World!"; + getData().thisIsATest = 283; + + var testLabel:Label = new Label(); + testLabel.text = "This is a test"; + testLabel.x = getData().thisIsATest; + testLabel.y = getData().thisIsATest; + + testLabel.text += ", " +flushMessage+"x"+shared.toString()+"x"; + getData().testLabel = testLabel; + + if(getData().exists) testLabel.text += "SharedObject existed before initialization"; + else getData().exists = true; + + this.addChild(getData().testLabel); + } + } + } + public function getData():Object + { + return shared.data; + } + public function getLocal():Boolean + { + try{ + shared = SharedObject.getLocal("thisIsForWork"); + }catch(err:Error){ + return false; + } + return true; + } + public function flush():Boolean + { + try{ + flushMessage = shared.flush(10000); + }catch(err:Error){ + return false; + } + return true; + } + + public function back():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + (InstructionPage)(obj).back(); + } + return false; + } + + public function forward():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + (InstructionPage)(obj).forward(); + } + return false; + } + + public function accept():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + if( (InstructionPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "socioDemographic"; + return true; + } + } + if(obj is SocioDemographicPage) + { + if( (SocioDemographicPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "planner"; + return true; + } + } + if(obj is PlannerPage) + { + if( (PlannerPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "none"; + return true; + } + } + + return false; + } + + ]]> + </mx:Script> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/FisheryExperiment.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Forecasting.mxml =================================================================== --- mentalmodels/trunk/flex/src/Forecasting.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Forecasting.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:local="*" xmlns:comp="customComponents.*"> + <mx:Grid top="10" bottom="10" right="10" left="10"> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:VDividedBox width="100%" height="100%" id="vdboxOuter" liveDragging="false"> + <mx:VBox width="100%" height="50%" id="vboxLeftInnerDown" verticalGap="20"> + <mx:VBox width="100%" height="50%" id="vboxLeftInnerUpper" verticalGap="20"> + <mx:Image id="imgIsland" source="../libs/island.png"/> + <mx:ComboBox width="50%" id="cmbUpper"></mx:ComboBox> + </mx:VBox> + <mx:TextArea width="50%" height="70%"/> + <mx:ComboBox width="50%"></mx:ComboBox> + </mx:VBox> + </mx:VDividedBox> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:VBox width="100%" height="100%" id="vboxRightSideMainContainer" verticalGap="10"> + <mx:VBox width="100%" height="20%" id="vboxRightInnerUpper" verticalGap="20"> + <mx:Form width="100%" height="8%" id="frmGeneralInfoOfPlayer_Time"> + <mx:FormItem label="Clock" horizontalAlign="right" fontSize="14" fontWeight="bold"> + <!-- <mx:Text id="txtclock" text="10:50"/> --> + <comp:TimeLabel/> + </mx:FormItem> + <mx:FormItem label="Round Number:" horizontalAlign="right" fontSize="14" fontWeight="bold"> + <mx:Text id="txtroundno" text="1"/> + </mx:FormItem> + <mx:FormItem label="You Are Player Number:" fontSize="14" fontWeight="bold"> + <mx:Text id="txtplayerno" text="2"/> + </mx:FormItem> + <mx:FormItem label="You Are in Group Number:" fontSize="14" fontWeight="bold"> + <mx:Text id="txtgroupno" text="3"/> + </mx:FormItem> + + </mx:Form> + <mx:ProgressBar id="progressbarRoundInfo" label="Round" width="100%" height="10%" minimum="0" maximum="100" indeterminate="false" enabled="true"/> + </mx:VBox> + <mx:VBox width="100%" height="70%" id="vboxRightInnerDown" verticalGap="20"> + <mx:Form width="100%" height="90%" id="frmSurvey"> + <mx:FormHeading label="Survey Questions"/> + <mx:TextArea id="txtaSurvey" width="100%" height="100%" wordWrap="true"/> + </mx:Form> + <mx:HBox width="100%" height="10%" id="hboxButtons" horizontalAlign="center" horizontalGap="20" verticalAlign="middle"> + <mx:Button label="Previous" fontSize="14" id="btnPrevious"/> + <mx:Button label="Next" fontSize="14" id="btnNext"/> + </mx:HBox> + </mx:VBox> + </mx:VBox> + </mx:GridItem> + </mx:GridRow> + </mx:Grid> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/Forecasting.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/MME.mxml =================================================================== --- mentalmodels/trunk/flex/src/MME.mxml (rev 0) +++ mentalmodels/trunk/flex/src/MME.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" + backgroundGradientAlphas="[1.0, 1.0]" + backgroundGradientColors="[#9DDBED, #BFED9D]" + xmlns:ns1="*" + pageTitle="Fishery Experiment"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import actionscript.RoundConfig; + + // request config data from server + private var rndConfig:RoundConfig = getConfig(); + + public function getConfig():RoundConfig + { + // temporary fix: + return new RoundConfig( 1, + new ArrayCollection([0.5, 0.15, 0.05]), + new ArrayCollection([10, 20, 30]), + new ArrayCollection([5, 10, 15])); + } + + ]]> + </mx:Script> + + <mx:states> + <mx:State name="forecasting"> + <mx:RemoveChild target="{socio_demographic_information1}"/> + <mx:RemoveChild target="{hbox1}"/> + <mx:AddChild relativeTo="{containerContent}" position="lastChild"> + <ns1:Forecasting top="10" bottom="10" right="10" left="10" id="forecasting1"> + </ns1:Forecasting> + </mx:AddChild> + </mx:State> + </mx:states> + <mx:Canvas left="10" right="10" bottom="10" top="10" id="containerMain" label="OutsideContainer"> + <mx:VBox right="10" top="10" bottom="10" left="10"> + <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle" id="hboxheading"> + <mx:Label text="Fishery Experiment" id="lblHeading" enabled="true" fontSize="36" textAlign="center" fontWeight="bold" color="#4D992C"/> + </mx:HBox> + <mx:Canvas width="100%" height="90%" id="containerContent"> + <ns1:Socio_Demographic_Information top="10" left="10" right="0" bottom="10" id="socio_demographic_information1"> + </ns1:Socio_Demographic_Information> + + <mx:HBox x="42" width="100%" height="10%" verticalAlign="bottom" horizontalAlign="center" bottom="5" id="hbox1"> + <mx:Button label="Submit" id="btnSubmit_Socio_Demographic_Info" click="currentState='forecasting'" fontSize="12"/> + </mx:HBox> + </mx:Canvas> + <mx:HBox width="100%" id="hboxfooter" horizontalAlign="center" verticalAlign="bottom"> + <mx:Text text="School of Human Evolution & Social Change + Tempe, AZ 85287-2402 + T: 480-965-6213 / Fax: 480-965-7671" + id="txtFooter"/> + </mx:HBox> + </mx:VBox> + </mx:Canvas> +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/MME.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Mental.mxml =================================================================== --- mentalmodels/trunk/flex/src/Mental.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Mental.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#ACD1EE, #D989E5]"> + <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> + + + <mx:VBox height="100%" id="vboxGatherInfo"> + <mx:HBox width="100%" id="hboxSubHeading"> + <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> + </mx:HBox> + <mx:RadioButtonGroup id="radiogroupGender"/> + <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle"> + <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButtonGroup id="radiogroup1Gender"/> + <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> + </mx:HBox> + <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="left" verticalAlign="middle"> + <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbBirthYear" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for the range: make combo box as text box 4 digit --> + <mx:Array> + <mx:String>1980</mx:String> + <mx:String>1981</mx:String> + <mx:String>1982</mx:String> + <mx:String>1983</mx:String> + <mx:String>1984</mx:String> + <mx:String>1985</mx:String> + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle"> + <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> + <mx:TextInput id="txtMajor" editable="true" enabled="true"/> + + + </mx:HBox> + + <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle"> + <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbEthnicity" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for this one also --> + <mx:Array> + <mx:String>Freshman</mx:String> + <mx:String>Sophomore</mx:String> + <mx:String>Junior</mx:String> + <mx:String>Senior</mx:String> + + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> + <mx:Button label="Submit" id="butSubmit"/> + </mx:HBox> + + </mx:VBox> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/Mental.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="698" height="407" textAlign="center"> + <mx:VBox id="vboxouterBox" horizontalAlign="center" verticalAlign="middle" width="100%" height="50%" horizontalCenter="0" top="10" verticalGap="0"> + + + <mx:Form top="5" bottom="5" id="frmSocioDemographic" right="5" left="5" width="50%" height="50%" textAlign="center"> + <mx:FormHeading label="Socio DemographicInformation " id="frmheadingSocioDemographicInfo" fontSize="24" textAlign="left" themeColor="#1200FF" color="#186BE8" width="5%" height="10%"/> + <mx:FormItem id="frmitemStudy" horizontalAlign="left" fontSize="14" required="true"> + <mx:Label text="What year are you in your study?"/> + <mx:RadioButton id="freshman" groupName="study"> + <mx:label>Freshman</mx:label> + </mx:RadioButton> + <mx:RadioButton id="sophomore" groupName="study"> + <mx:label>Sophomore</mx:label> + </mx:RadioButton> + <mx:RadioButton id="junior" groupName="study"> + <mx:label>Junior</mx:label> + </mx:RadioButton> + <mx:RadioButton id="senior" groupName="study"> + <mx:label>Senior</mx:label> + </mx:RadioButton> + + </mx:FormItem> + <mx:FormItem label="What is your major?" id="frmitemMajor" horizontalAlign="left" fontSize="14" required="true"> + <mx:TextInput id="txtipMajor"/> + </mx:FormItem> + <mx:FormItem label="Year of Birth" id="frmitemYOB" horizontalAlign="left" fontSize="14" required="true"> + <mx:TextInput id="txtipYOB" maxChars="4"/> + </mx:FormItem> + <mx:FormItem label="Gender" id="frmitemGender" horizontalAlign="left" fontSize="14" required="true"> + <mx:RadioButton id="male" groupName="gender"> + <mx:label>Male</mx:label> + </mx:RadioButton> + <mx:RadioButton id="female" groupName="gender"> + <mx:label>Female</mx:label> + </mx:RadioButton> + + </mx:FormItem> + + </mx:Form> + + + </mx:VBox> +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Socio_demographic.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_demographic.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Socio_demographic.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="80%"> + + + + + <mx:VBox height="100%" id="vboxGatherInfo" width="100%"> + <mx:HBox horizontalAlign="center" verticalAlign="middle" id="hboxSocio_demographic_info"> + <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> + </mx:HBox> + <mx:HBox width="100%" id="hboxSubHeading"> + <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> + </mx:HBox> + <mx:RadioButtonGroup id="radiogroupGender"/> + <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle" horizontalAlign="center"> + <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButtonGroup id="radiogroup1Gender"/> + <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> + </mx:HBox> + <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="center" verticalAlign="middle"> + <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbBirthYear" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for the range: make combo box as text box 4 digit --> + <mx:Array> + <mx:String>1980</mx:String> + <mx:String>1981</mx:String> + <mx:String>1982</mx:String> + <mx:String>1983</mx:String> + <mx:String>1984</mx:String> + <mx:String>1985</mx:String> + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle" horizontalAlign="center"> + <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> + <mx:TextInput id="txtMajor" editable="true" enabled="true"/> + + + </mx:HBox> + + <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle" horizontalAlign="center"> + <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbEthnicity" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for this one also --> + <mx:Array> + <mx:String>Freshman</mx:String> + <mx:String>Sophomore</mx:String> + <mx:String>Junior</mx:String> + <mx:String>Senior</mx:String> + + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> + <mx:Button label="Submit" id="butSubmit"/> + </mx:HBox> + + </mx:VBox> + + + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="absolute"> + + <mx:VBox> + <mx:HBox> + <comp:Forecast id="legacy" numColumns="10"/> + <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> + <comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/> + </mx:HBox> + <mx:Label initialize="init()"/> + </mx:VBox> + + <mx:Script> + <![CDATA[ + import mx.messaging.channels.StreamingAMFChannel; + import customComponents.*; + import mx.collections.ArrayCollection; + + public function init():void + { + var X:String="X"; + forecastPeople.setItem(0,0,X); + forecastPeople.setItem(1,1,X); + forecastPeople.setItem(2,2,X); + } + + ]]> + </mx:Script> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/TableTest.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/TestApp.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestApp.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TestApp.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*" + width="700" height="500"> + + <comp:LongHScale id="slider1" label="blah"/> + <mx:Label id="slideinfo1" text="{slider1.slider.value}"/> + + <comp:ShortHScale id="slider2"/> + <mx:Label id="slideinfo2" text="{slider2.slider.value}"/> + + <mx:Label/> + <mx:Label/> + <mx:Label/> + + <mx:ArrayCollection id="slider3Labels"> + <mx:String>label1</mx:String> + <mx:String>label2</mx:String> + <mx:String>label3</mx:String> + </mx:ArrayCollection> + + <mx:ArrayCollection id="slider4Labels"> + <mx:String>label1</mx:String> + <mx:String>label2</mx:String> + </mx:ArrayCollection> + + <comp:PsychometricQuestion id="slider3" labels="{slider3Labels}"/> + <mx:Label id="slideinfo3" text="{slider3.slider.getVal}"/> + + <comp:PsychometricQuestion id="slider4" labels="{slider4Labels}"/> + <mx:Label id="slideinfo4" text="{slider4.slider.getVal}"/> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/TestApp.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/actionscript/ASResults.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASResults.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASResults.as 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,18 @@ +package actionscript +{ + import mx.messaging.channels.StreamingHTTPChannel; + + public class ASResults + { + public function ASResults() + { + } + public function calculateString():String + { + var greeting:String; + greeting="Welcome Kalin!!"; + return String(greeting); + } + + } +} \ No newline at end of file Property changes on: mentalmodels/trunk/flex/src/actionscript/ASResults.as ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,225 @@ +// ActionScript file +package actionscript +{ + import mx.collections.ArrayCollection; + import mx.controls.DataGrid; + + [Bindable] + public class DataGridHandler + { + private var myDataGrid:DataGrid; + private var myProvider:ArrayCollection; + + private var errorMessage:String = ""; + + private var numFields:Number; + private var numCols:Number; + private var minValue:Number; + private var maxValue:Number; + private var sumOfEachColumn:Number; + + + public function get grid():DataGrid + { return myDataGrid; } + public function set grid(newValue:DataGrid):void + { myDataGrid = newValue; } + public function get dataProvider():ArrayCollection + { return myProvider; } + public function set dataProvider(newValue:ArrayCollection):void + { myProvider = newValue; } + + public function get errorMessage():String + { return errorMessage; } + public function set errorMessage(newValue:String):void + { errorMessage = newValue; } + + public function get numFields():Number + { return numFields; } + public function set numFields(newValue:Number):void + { numFields = newValue; } + public function get numCols():Number + { return numCols; } + public function set numCols(newValue:Number):void + { numCols = newValue; } + public function get minValue():Number + { return minValue; } + public function set minValue(newValue:Number):void + { minValue = newValue; } + public function get maxValue():Number + { return maxValue; } + public function set maxValue(newValue:Number):void + { maxValue = newValue; } + public function get sumOfEachColumn():Number + { return sumOfEachColumn; } + public function set sumOfEachColumn(newValue:Number):void + { sumOfEachColumn = newValue; } + + public function DataGridHandler(fields:Number, cols:Number, min:Number = 0, max:Number = 9999, colSum:Number = -1) + { + numFields = fields; + numCols = cols; + minValue = min; + maxValue = max; + sumOfEachColumn = colSum; + + createGrid(); + } + + public function getItem(field:Number, col:Number):Object + { + return myProvider.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + myProvider.getItemAt(field)["day"+(col+1)] = value; + } + + private function createGrid() + { + var tempArray:Array = myDataGrid.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + myDataGrid.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + myProvider.addItem(field); + } + + myDataGrid.height = (23)*(numFields+1)+2; + } + + public function clone():DataGrid + { + var dgClone:DataGrid = new DataGrid(); + var myProviderClone:ArrayCollection = new ArrayCollection(); + dgClone.dataProvider = myProviderClone; + + var tempArray:Array = dgClone.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dgClone.columns = tempArray; + + // fill data + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + myProviderClone.addItem(field); + for(var k:Number=0; k<numColumns; k++) + { + myProviderClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); + } + } + + dgClone.height = (23)*(numFields+1)+2; + + return dgClone; + } + + public function changed():void + { + markNoError(); + errorMessage = "Complete." + + var error:Boolean = false; + var value:Object; + + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + value = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + + // if no other errors yet, and there is a required sum for columns, + // then check actual sum against expected + if( ! (error || sumOfEachColumn == -1 || colSum == sumOfEachColumn) ) + { + errorMessage = "Sum of all columns must be exactly "+sumOfEachColumn+"."; + error = true; + markError(-1,col); + } + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + //the entire string must be consecutive digits + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#3333FF"); + myDataGrid.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + myDataGrid.selectedIndex = -1; + } + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/RoundConfig.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,34 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + public class RoundConfig + { + private var number:Number; // what round is it? + + // bay information + private var bayRegen:ArrayCollection; + private var bayMax:ArrayCollection; + private var bayStart:ArrayCollection; + + public function RoundConfig(number:Number, bayRegen:ArrayCollection, bayMax:ArrayCollection, bayStart:ArrayCollection) + { + this.number = number; + this.bayRegen = bayRegen; + this.bayMax = bayMax; + this.bayStart = bayStart; + } + + public function getRegen():ArrayCollection + { return this.bayRegen; } + + public function getMax():ArrayCollection + { return this.bayMax; } + + public function getStart():ArrayCollection + { return this.bayStart; } + + public function getNumber():Number + { return this.number; } + } +} \ No newline at end of file Property changes on: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" + horizontalScrollPolicy="on" + verticalScrollPolicy="off"/> + <mx:Button label="{dgMain.columns.length}" click="clicked()"/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + private var colIndex:Number=0; + [Bindable] + public var numColumns:Number = 3; + [Bindable] + public var numFields:Number = 6; + [Bindable] + public var finished:Boolean = false; + + public function init():void + { + createColumns(); + + /* dgMain.selectedIndex = 0; dgMain.selectedItem.day1 = 5; + dgMain.selectedIndex = 1; dgMain.selectedItem.day1 = 10; + dgMain.selectedIndex = 2; dgMain.selectedItem.day1 = 15; + dgMain.selectedIndex = -1; */ + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dgMain.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = false; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + if(0 == i) + { + temp.editable = true; + } + + tempArray[i] = temp; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + if(0 == i) + { + var field:Object = new Object(); + sched.addItem(field); + } + } + } + dgMain.columns = tempArray; + + dgMain.height = 23*(numFields+1)+17 + dgMain.width = 30*Math.min(numColumns, 6)+1 + } + + public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dgMain.selectedIndex = i; +// dgMain.selectedItem.day2 = Number(dgMain.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dgMain.columns[colIndex]; + if(num == null || !(num is Number)) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dgMain.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dgMain.selectedIndex = -1; + } + } + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + private function changeColumn():void + { + DataGridColumn(dgMain.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dgMain.columns[colIndex]).editable = true; + } + + public function changed():void + { + // check the values of the current column + // and point out any errors (TextBox) + } + + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + //return Number(n) < minValue || Number(n) > maxValue; + return false; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()"/> + </mx:HBox> + + <mx:Label id="lbl"/> + <mx:Label id="debug"/> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 15; + [Bindable] + public var numFields:Number = 4; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 10; + + private var errorMessage:String = null; + + //not used + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + } + private function createColumns():void + { + var tempArray:Array = dgMain.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dgMain.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + sched.addItem(field); + } + + dgMain.height = (23)*(numFields+1)+2; + } + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + var value:Object; + + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + value = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + } + + if(error) + { + lbl.text = errorMessage; + } + else + { + lbl.text = "Complete."; + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + dgMain.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dgMain.selectedIndex = -1; + } + + public function clone():DataGrid + { + var dgClone:DataGrid = new DataGrid(); + var schedClone:ArrayCollection = new ArrayCollection(); + dgClone.dataProvider = schedClone; + + var tempArray:Array = dgClone.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dgClone.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + schedClone.addItem(field); + for(var k:Number=0; k<numColumns; k++) + { + schedClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); + } + } + + dgClone.height = (23)*(numFields+1)+2; + + return dgClone; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,211 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" creationComplete="init()"> + + <mx:ArrayCollection id="sched"/> + <mx:ArrayCollection id="schedPeople"/> + <mx:ArrayCollection id="calculated"/> + + <comp:Forecast1 id="newForecast1" visible="false" includeInLayout="false"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:VBox id="dgRows" verticalGap="0"> + <mx:HBox id="dgRow1" horizontalGap="0"> + <mx:DataGrid id="dgMain" + editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/> + </mx:HBox> + + <mx:HBox id="dgRow2"> + <!--<mx:DataGrid id="dgPeople" + editable="false" textAlign="right" dataProvider="{schedPeople}" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/>--> + </mx:HBox> + + <mx:HBox id="dgRow3"> + <mx:DataGrid id="dgCalculated" headerHeight="1" + editable="false" textAlign="right" dataProvider="{calculated}" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/> + </mx:HBox> + </mx:VBox> + </mx:HBox> + + <mx:Label id="lbl"/> + + + <mx:Script> + <![CDATA[ + import mx.controls.Button; + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 5; + [Bindable] + public var numFields:Number = 3; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 50; + [Bindable] + public var oldForecast1:Forecast1 = null; + + private var errorMessage:String = null; + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + getPeople(); + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dgMain.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = false; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + if(0 != i) + { + temp.editable = true; + } + + tempArray[i] = temp; + } + + dgMain.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + sched.addItem(field); + } + + dgMain.height = (23)*(numFields+1)+2; + } + + public function getPeople():void + { + if(oldForecast1 == null) + { + setItem(0,1,1); + dgRow2.addChild(newForecast1.dgMain); + setItem(1,1,2); + } + else + { + setItem(0,2,3); + dgRow2.addChild(oldForecast1.clone()); + setItem(1,2,4); + } + } + + public function getItem(field:Number, col:Number):Object + { + return this.sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + this.sched.getItemAt(field)["day"+(col+1)] = value; + } + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + var value:Object = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + } + + if(error) + { + lbl.text = errorMessage; + } + else + { + lbl.text = "Complete."; + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + dgMain.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dgMain.selectedIndex = -1; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + [Bindable] + public var numPages:Number; //temporary hard-coded value *fix this* + + // Contains ArrayCollections filled with DisplayObjects + // *see: getDisp(pageNum, index) + private var allPageList:ArrayCollection; + + // Variables with default settings + [Bindable] + public var currPageNumber:Number = 0; + public var pagesRead:Number = 1; + + public function init():void + { + numPages = loadAllPages(); + showPage(); + } + + public function loadAllPages():Number + { + allPageList = new ArrayCollection(); + // load allPageList from file - return length + var done:Boolean = false; + do + { + var tempPage:ArrayCollection = new ArrayCollection(); + + var doneItems:Boolean = false; + do + { + var tempItem:DisplayObject = new PsychometricQuestion(); + ((PsychometricQuestion)(tempItem)).labels = new ArrayCollection(["Big", "Small"]); + + tempPage.addItem(tempItem); + doneItems = true; + }while(!doneItems) + + allPageList.addItem(tempPage); + done = true; + }while(!done) + + return allPageList.length; + } + + private function getPage(pageNum:Number):ArrayCollection + { + if(pageNum < 0 || allPageList == null || pageNum >= allPageList.length) + { return null; } + + return (ArrayCollection)(allPageList.getItemAt(pageNum)); + } + + private function getDisp(pageNum:Number, index:Number):DisplayObject + { + var tempList:ArrayCollection = getPage(pageNum); + + if(tempList == null || index < 0 || index >= tempList.length) + { return null; } + + return (DisplayObject)(tempList.getItemAt(index)); + } + public function showPage():Boolean + { + try + { + var list:ArrayCollection = getPage(currPageNumber); + for(var index:Number = 0; index < list.length; index++) + { + content.addChild(getDisp(currPageNumber, index)); + } + + if(currPageNumber >= pagesRead) + { + pagesRead = currPageNumber+1; + } + return true; + } + catch(error:Error) + {} + return false; + } + + private function fixNum():Boolean + { + if(currPageNumber < 0) + { + currPageNumber = 0; + return false; + } + if(currPageNumber >= numPages) + { + currPageNumber = numPages - 1; + return false; + } + return showPage(); + } + + public function back():Boolean + { + currPageNumber--; + return fixNum(); + } + + public function forward():Boolean + { + currPageNumber++; + return fixNum(); + } + + public function accept():Boolean + { + return pagesRead >= numPages; + } + + ]]> + </mx:Script> + + <mx:Label text="{currPageNumber+1} / {numPages}"/> + + <mx:VBox id="content"/> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30"> + + <mx:Image source="../libs/LongScale.jpg" y="0"/> + + <mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml" id="slider" + width="495" height="20" y="0" + minimum="-15" maximum="15" snapInterval="1" value="0" + allowTrackClick="true" + fillAlphas="[1.0, 1.0]" fillColors="[#20B4D4, #20B4D4]" alpha="1.0"/> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/LongScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongScale.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30" layout="absolute"> + + <mx:Image x="10" y="0" source="../libs/LongSlider.jpg" /> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/customComponents/LongScale.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Planner.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()" + width="350" height="200" + borderStyle="solid" verticalScrollPolicy="off" horizontalScrollPolicy="off"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + + public var valueRequired:Boolean = false; + + private function init():void + { + if(valueRequired) + { + addRow(); + } + } + + public function childRemoved():void + { + numbers.removeChildAt(numbers.numChildren-1); + } + + public function addRow():void + { + var newRow:PlannerRow = new PlannerRow(); + newRow.valueRequired = this.valueRequired; + var newNumber:Label = new Label(); + newNumber.text = "" + (numbers.numChildren+1); + newNumber.height = 22; + + grid.addChildAt(newRow, grid.numChildren); + numbers.addChild(newNumber); + } + + public function getPlannerRow(index:Number):PlannerRow + { + if(index < grid.numChildren && index >= 0) + { + return (PlannerRow)(grid.getChildAt(index)); + } + return null; + } + public function getPlannerList(index:Number):ArrayCollection + { + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + return null; + } + var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); + return list; + } + public function toArrayCollection():ArrayCollection + { + var array:ArrayCollection = new ArrayCollection(); + + for(var index:Number = 0; index < grid.numChildren; index++) + { + var temp:ArrayCollection = getPlannerList(index); + array.addItem(temp); + } + + return array; + } + + ]]> + </mx:Script> + + <mx:HBox id="newButtonBox"> + <mx:Label text="" width="12"/> + <mx:Button id="newButton" label="New" click="addRow()" width="60"/> + <!--<mx:Label text="-" width="80" textAlign="center"/> + <mx:Label text="-" width="50" textAlign="center"/> + <mx:Label text="-" width="80" textAlign="center"/>--> + </mx:HBox> + + <mx:HBox id="headerBox"> + <mx:Label text="#" fontWeight="bold" paddingBottom="-3" width="12"/> + <mx:Label text="Remove" fontWeight="bold" paddingBottom="-3" width="60" textAlign="center"/> + <mx:Label text="Location" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + <mx:Label text="Days" fontWeight="bold" paddingBottom="-3" width="50" textAlign="center"/> + <mx:Label text="Threshold" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + </mx:HBox> + + <mx:HBox horizontalScrollPolicy="off" height="147" width="100%"> + <mx:VBox id="numbers" width="12"/> + <mx:VBox id="grid" childRemove="childRemoved()"/> + </mx:HBox> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Planner.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:Label text="Planning Stage" fontSize="24"/> + <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, and repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." + width="600"/> + <mx:Label/> + + <mx:HBox> + <mx:VBox> + <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> + <comp:Planner id="notRepeated"/> + </mx:VBox> + <mx:VBox> + <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> + <comp:Planner id="repeated" valueRequired="true"/> + </mx:VBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Suspend repetition:" fontWeight="bold" width="130"/> + <mx:Label text="If during one repetition"/> + <mx:NumericStepper id="suspendWeight" value="5" minimum="0.1" maximum="100" stepSize="0.1" height="20" width="50"/> + <mx:Label text="lbs could not be fished,"/> + </mx:HBox> + <mx:HBox> + <mx:Label width="113"/> + <mx:Label text="then stay in the harbor for"/> + <mx:NumericStepper id="suspendDays" value="1" minimum="0" maximum="30" stepSize="1" height="20" width="50"/> + <mx:Label text="days before starting the next repetition."/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public function getNotRepeated():ArrayCollection + { return notRepeated.toArrayCollection(); } + + public function getRepeated():ArrayCollection + { return repeated.toArrayCollection(); } + + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public var valueReq... [truncated message content] |
From: <kj...@us...> - 2009-03-18 20:14:44
|
Revision: 83 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=83&view=rev Author: kjonas Date: 2009-03-18 20:14:38 +0000 (Wed, 18 Mar 2009) Log Message: ----------- Deleting old customComponents Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (V. Commons-JIRA) <all...@as...> - 2009-03-16 22:59:45
|
Use UTO's ETS virtual server for dev.commons.asu.edu ---------------------------------------------------- Key: VC-5 URL: https://dev.commons.asu.edu/jira/browse/VC-5 Project: Virtual Commons Issue Type: Improvement Reporter: Allen Lee Assignee: Allen Lee Switch to sod19.asu.edu and set up dev infrastructure there (JIRA, Confluence, etc.) for dev.commons.asu.edu -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://dev.commons.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Allen L. <All...@as...> - 2009-03-06 23:10:55
|
This is a test message to see if Kalin is signed up properly, disregard. -- Allen Lee Center for the Study of Institutional Diversity [http://csid.asu.edu] School of Human Evolution and Social Change [http://shesc.asu.edu] The Virtual Commons [http://commons.asu.edu] The Digital Archaeological Record [http://www.tdar.org] The OpenABM Consortium [http://www.openabm.org] Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 Office: 480.727.0401 | Fax: 480.965.7671 |
From: <kj...@us...> - 2009-03-06 22:31:16
|
Revision: 82 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=82&view=rev Author: kjonas Date: 2009-03-06 22:31:03 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Initial revision of Custom Components for Fishery Experiment Added Paths: ----------- mentalmodels/trunk/flex/src/ mentalmodels/trunk/flex/src/customComponents/ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml mentalmodels/trunk/flex/src/customComponents/LongScale.mxml mentalmodels/trunk/flex/src/customComponents/Planner.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml Added: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dg1" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" + horizontalScrollPolicy="on" + verticalScrollPolicy="off"/> + <mx:Button label="{dg1.columns.length}" click="clicked()"/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + private var colIndex:Number=0; + [Bindable] + public var numColumns:Number = 3; + [Bindable] + public var numFields:Number = 6; + [Bindable] + public var finished:Boolean = false; + + public function init():void + { + createColumns(); + + /* dg1.selectedIndex = 0; dg1.selectedItem.day1 = 5; + dg1.selectedIndex = 1; dg1.selectedItem.day1 = 10; + dg1.selectedIndex = 2; dg1.selectedItem.day1 = 15; + dg1.selectedIndex = -1; */ + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dg1.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = false; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + if(0 == i) + { + temp.editable = true; + } + + tempArray[i] = temp; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + if(0 == i) + { + var field:Object = new Object(); + sched.addItem(field); + } + } + } + dg1.columns = tempArray; + + dg1.height = 23*(numFields+1)+17 + dg1.width = 30*Math.min(numColumns, 6)+1 + } + + public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dg1.selectedIndex = i; +// dg1.selectedItem.day2 = Number(dg1.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dg1.columns[colIndex]; + if(num == null || !(num is Number)) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dg1.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dg1.selectedIndex = -1; + } + } + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + private function changeColumn():void + { + DataGridColumn(dg1.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dg1.columns[colIndex]).editable = true; + } + + public function changed():void + { + // check the values of the current column + // and point out any errors (TextBox) + } + + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d\d*$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + //return Number(n) < minValue || Number(n) > maxValue; + return false; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dg1" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()"/> + </mx:HBox> + + <mx:Label id="lbl"/> + <mx:Label id="debug"/> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 15; + [Bindable] + public var numFields:Number = 4; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 10; + + private var errorMessage:String = null; + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + } + private function createColumns():void + { + var tempArray:Array = dg1.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dg1.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + sched.addItem(field); + } + + dg1.height = 22*numFields+24 + } + + /* public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dg1.selectedIndex = i; +// dg1.selectedItem.day2 = Number(dg1.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dg1.columns[colIndex]; + if(num == null || num == "" || Number(num)*0 != 0) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dg1.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dg1.selectedIndex = -1; + } + } */ + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + /* private function changeColumn():void + { + DataGridColumn(dg1.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dg1.columns[colIndex]).editable = true; + } */ + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + var value:Object; + + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + value = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + } + + if(error) + { + lbl.text = errorMessage; + } + else + { + lbl.text = "Complete."; + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d\d*$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(dg1.columns[col]).setStyle("backgroundColor", "#3333FF"); + dg1.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dg1.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dg1.selectedIndex = -1; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dg1" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/> + </mx:HBox> + + <mx:Label id="lbl"/> + + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 6; + [Bindable] + public var numFields:Number = 3; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 50; + + private var errorMessage:String = null; + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dg1.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = false; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + if(0 != i) + { + temp.editable = true; + } + + tempArray[i] = temp; + } + + dg1.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + sched.addItem(field); + } + + dg1.height = 22*numFields+24 + } + + /* public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dg1.selectedIndex = i; +// dg1.selectedItem.day2 = Number(dg1.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dg1.columns[colIndex]; + if(num == null || num == "" || Number(num)*0 != 0) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dg1.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dg1.selectedIndex = -1; + } + } + private function changeColumn():void + { + DataGridColumn(dg1.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dg1.columns[colIndex]).editable = true; + } */ + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + var value:Object = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + } + + if(error) + { + lbl.text = errorMessage; + } + else + { + lbl.text = "Complete."; + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d\d*$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(dg1.columns[col]).setStyle("backgroundColor", "#3333FF"); + dg1.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dg1.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dg1.selectedIndex = -1; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + [Bindable] + public var numPages:Number; //temporary hard-coded value *fix this* + + // Contains ArrayCollections filled with DisplayObjects + // *see: getDisp(pageNum, index) + private var allPageList:ArrayCollection; + + // Variables with default settings + [Bindable] + public var currPageNumber:Number = 0; + public var pagesRead:Number = 1; + + public function init():void + { + numPages = loadAllPages(); + showPage(); + } + + public function loadAllPages():Number + { + allPageList = new ArrayCollection(); + // load allPageList from file - return length + var done:Boolean = false; + do + { + var tempPage:ArrayCollection = new ArrayCollection(); + + var doneItems:Boolean = false; + do + { + var tempItem:DisplayObject = new PsychometricQuestion(); + ((PsychometricQuestion)(tempItem)).labels = new ArrayCollection(["Big", "Small"]); + + tempPage.addItem(tempItem); + doneItems = true; + }while(!doneItems) + + allPageList.addItem(tempPage); + done = true; + }while(!done) + + return allPageList.length; + } + + private function getPage(pageNum:Number):ArrayCollection + { + if(pageNum < 0 || allPageList == null || pageNum >= allPageList.length) + { return null; } + + return (ArrayCollection)(allPageList.getItemAt(pageNum)); + } + + private function getDisp(pageNum:Number, index:Number):DisplayObject + { + var tempList:ArrayCollection = getPage(pageNum); + + if(tempList == null || index < 0 || index >= tempList.length) + { return null; } + + return (DisplayObject)(tempList.getItemAt(index)); + } + public function showPage():Boolean + { + try + { + var list:ArrayCollection = getPage(currPageNumber); + for(var index:Number = 0; index < list.length; index++) + { + content.addChild(getDisp(currPageNumber, index)); + } + + if(currPageNumber >= pagesRead) + { + pagesRead = currPageNumber+1; + } + return true; + } + catch(error:Error) + {} + return false; + } + + private function fixNum():Boolean + { + if(currPageNumber < 0) + { + currPageNumber = 0; + return false; + } + if(currPageNumber >= numPages) + { + currPageNumber = numPages - 1; + return false; + } + return showPage(); + } + + public function back():Boolean + { + currPageNumber--; + return fixNum(); + } + + public function forward():Boolean + { + currPageNumber++; + return fixNum(); + } + + public function accept():Boolean + { + return pagesRead >= numPages; + } + + ]]> + </mx:Script> + + <mx:Label text="{currPageNumber+1} / {numPages}"/> + + <mx:VBox id="content"/> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30"> + + <mx:Image source="../libs/LongScale.jpg" y="0"/> + + <mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml" id="slider" + width="495" height="20" y="0" + minimum="-15" maximum="15" snapInterval="1" value="0" + allowTrackClick="true" + fillAlphas="[1.0, 1.0]" fillColors="[#20B4D4, #20B4D4]" alpha="1.0"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/LongScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongScale.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30" layout="absolute"> + + <mx:Image x="10" y="0" source="../libs/LongSlider.jpg" /> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Planner.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()" + width="350" height="200" + borderStyle="solid" verticalScrollPolicy="off" horizontalScrollPolicy="off"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + + public var valueRequired:Boolean = false; + + private function init():void + { + if(valueRequired) + { + addRow(); + } + } + + public function childRemoved():void + { + numbers.removeChildAt(numbers.numChildren-1); + } + + public function addRow():void + { + var newRow:PlannerRow = new PlannerRow(); + newRow.valueRequired = this.valueRequired; + var newNumber:Label = new Label(); + newNumber.text = "" + (numbers.numChildren+1); + newNumber.height = 22; + + grid.addChildAt(newRow, grid.numChildren); + numbers.addChild(newNumber); + } + + public function getPlannerRow(index:Number):PlannerRow + { + if(index < grid.numChildren && index >= 0) + { + return (PlannerRow)(grid.getChildAt(index)); + } + return null; + } + public function getPlannerList(index:Number):ArrayCollection + { + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + return null; + } + var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); + return list; + } + public function toArrayCollection():ArrayCollection + { + var array:ArrayCollection = new ArrayCollection(); + + for(var index:Number = 0; index < grid.numChildren; index++) + { + var temp:ArrayCollection = getPlannerList(index); + array.addItem(temp); + } + + return array; + } + + ]]> + </mx:Script> + + <mx:HBox id="newButtonBox"> + <mx:Label text="" width="12"/> + <mx:Button id="newButton" label="New" click="addRow()" width="60"/> + <!--<mx:Label text="-" width="80" textAlign="center"/> + <mx:Label text="-" width="50" textAlign="center"/> + <mx:Label text="-" width="80" textAlign="center"/>--> + </mx:HBox> + + <mx:HBox id="headerBox"> + <mx:Label text="#" fontWeight="bold" paddingBottom="-3" width="12"/> + <mx:Label text="Remove" fontWeight="bold" paddingBottom="-3" width="60" textAlign="center"/> + <mx:Label text="Location" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + <mx:Label text="Days" fontWeight="bold" paddingBottom="-3" width="50" textAlign="center"/> + <mx:Label text="Threshold" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + </mx:HBox> + + <mx:HBox horizontalScrollPolicy="off" height="147" width="100%"> + <mx:VBox id="numbers" width="12"/> + <mx:VBox id="grid" childRemove="childRemoved()"/> + </mx:HBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:Label text="Planning Stage" fontSize="24"/> + <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, and repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." + width="600"/> + <mx:Label/> + + <mx:HBox> + <mx:VBox> + <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> + <comp:Planner id="notRepeated"/> + </mx:VBox> + <mx:VBox> + <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> + <comp:Planner id="repeated" valueRequired="true"/> + </mx:VBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Suspend repetition:" fontWeight="bold" width="130"/> + <mx:Label text="If during one repetition"/> + <mx:NumericStepper id="suspendWeight" value="5" minimum="0.1" maximum="100" stepSize="0.1" height="20" width="50"/> + <mx:Label text="lbs could not be fished,"/> + </mx:HBox> + <mx:HBox> + <mx:Label width="113"/> + <mx:Label text="then stay in the harbor for"/> + <mx:NumericStepper id="suspendDays" value="1" minimum="0" maximum="30" stepSize="1" height="20" width="50"/> + <mx:Label text="days before starting the next repetition."/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public function getNotRepeated():ArrayCollection + { return notRepeated.toArrayCollection(); } + + public function getRepeated():ArrayCollection + { return repeated.toArrayCollection(); } + + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public var valueRequired:Boolean = false; + + public function deleteMe():void + { + if(!valueRequired || parent.numChildren > 1) + { + parent.removeChild(this); + } + } + + public function changedLocation():void + { + threshold.visible = (location.selectedIndex != 0); + threshold.enabled = threshold.visible; + } + + public function getLocation():String + { + if(location.selectedIndex == 0) + { + return "Harbor"; + } + return "Bay " + location.selectedIndex; + } + public function getDays():Number + { + return days.value; + } + public function getThreshold():Number + { + if(location.selectedIndex == 0) + { + return -1; + } + return threshold.value; + } + + ]]> + </mx:Script> + + <mx:ArrayCollection id="locs"> + <mx:Object label="Harbor" data="Harbor"/> + <mx:Object label="Bay 1" data="Bay 1"/> + <mx:Object label="Bay 2" data="Bay 2"/> + <mx:Object label="Bay 3" data="Bay 3"/> + </mx:ArrayCollection> + + + <mx:Button id="deleteRow" label="Del" click="deleteMe()" width="60"/> + <mx:ComboBox id="location" dataProvider="{locs}" change="changedLocation()" width="80"/> + <mx:NumericStepper id="days" value="1" minimum="1" maximum="30" stepSize="1" width="50"/> + <mx:NumericStepper id="threshold" value="0.5" stepSize="0.1" minimum="0" maximum="100" enabled="false" visible="false" width="80"/> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:comp="customComponents.*"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public var labels:ArrayCollection; + + private function init():void + { + if(labels != null) + { + if(labels.length == 2) + { + this.removeChild(topleft); + this.removeChild(topmid); + this.removeChild(topright); + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + slider.isBipolar = false; + slider.x = 100; + slider.y = 0; + } + else + { + this.removeChild(farleft); + this.removeChild(farright); + topleft.text = (String)(labels.getItemAt(0)); + topmid.text = (String)(labels.getItemAt(1)); + topright.text = (String)(labels.getItemAt(2)); + slider.isBipolar = true; + slider.x = 0; + slider.y = 36; + } + } + slider.init(); + } + + ]]> + </mx:Script> + + <!-- Used for bipolar psychometric scales --> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right"/> + + <!-- Used for unipolar psychometric scales --> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center"/> + + <comp:Slider id="slider" initialize="false"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="260" height="30"> + + <mx:Image source="../libs/ShortScale.jpg"/> + + <mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml" id="slider" + width="255" height="20" top="10" + minimum="0" maximum="15" snapInterval="1" value="15" + allowTrackClick="true" + fillAlphas="[1.0, 1.0]" fillColors="[#20B4D4, #20B4D4]" alpha="1.0"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:Script> + <![CDATA[ + import mx.controls.Label; + + // Psychometric Variables - (Left = Positive, Right = Negative) + public var maxValue:Number = 10; // Leftmost value + public static var abstainValue:Number = -999; // Refusal to answer + private static var unipolarWidth:Number = 200; + private static var bipolarWidth:Number = 400; + private static var imageWidth:Number = 4; + + private var minValue:Number; // Rightmost value + private var value:Number; // value selected + + [Bindable] + public var getVal:Number; // (for binding: same value as last getValue() method call) + public var isBipolar:Boolean; // double slider = true, single slider = false + + // prepare Slider in default (abstain) position + public function init():void + { + this.addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); + this.addEventListener(MouseEvent.MOUSE_UP, mouseMove); + + if(isBipolar) + { + sliderBar.width = bipolarWidth + imageWidth; + minValue = -maxValue; + } + else + { + sliderBar.width = unipolarWidth + imageWidth; + minValue = 0; + } + + addTicks(); + reset(); + } + + private function addTicks():void + { + var numTicks:Number = maxValue - minValue + 1; + var separation:Number = (sliderBar.width - imageWidth) / (numTicks-1) + + var ticks:Array = new Array(numTicks); + + for(var i:Number = 0; i < numTicks; i++) + { + var tick:Label = new Label(); + tick.text = "."; + tick.x = i*separation - imageWidth/2; + tick.y = -10; + this.addChild(tick); + } + } + + private function mouseMove(event:MouseEvent):void + { + sliderButton.visible = true; + updateValue(); + } + + public function getValue():Number + { + if(sliderButton.visible) + { + getVal = value; + return value; + } + else + { + getVal = abstainValue; + return abstainValue; + } + } + + private function updateValue():void + { + var separation:Number = (sliderBar.width - imageWidth) / (maxValue - minValue) + var index:Number = Math.round((mouseX-imageWidth/2) / separation); // snap to nearest valid position + + value = maxValue - index; // flips scale so positive numbers on left + getValue(); // updates the bindable "getVal" variable + + var xPos:Number = index * separation; + sliderButton.move(xPos, 0); + } + + public function reset():void + { + sliderButton.visible = false; + updateValue(); + sliderButton.move(0,0); + } + + ]]> + </mx:Script> + + <!-- change X value to 1/2 the width of the sliderButton image --> + <mx:HBox id="sliderBar" + height="3" x="0" y="15" + borderStyle="solid" borderColor="#F0F0F0" borderThickness="2" + /> + + <mx:Image id="sliderButton" + x="0" y="0" + source="../libs/SliderImage.png" + /> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public function getGender():String + { + if(radioMale.selected) { return "M"; } + if(radioFemale.selected) { return "F"; } + return "Err"; + } + public function getYear():String + { + return txtYear.text; + } + public function getMajor():String + { + return txtMajor.text; + } + public function getSemester():String + { + return txtSemester.text; + } + + public function accept():Boolean + { + // if any field is of improper length, this section is not completed + // flag/unflag an area with red if incomplete/complete + var ready:Boolean=true; + + if(getGender().length != 1) + { + boxGender.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + boxGender.setStyle("backgroundColor", ""); + } + + if(getYear().length != 4) + { + txtYear.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + txtYear.setStyle("backgroundColor", "#FFFFFF"); + } + + if(getMajor().length == 0) + { + txtMajor.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + txtMajor.setStyle("backgroundColor", "#FFFFFF"); + } + + if(getSemester().length == 0) + { + txtSemester.setStyle("backgroundColor", "#FF0000"); + ready=false; + }else{ + txtSemester.setStyle("backgroundColor", "#FFFFFF"); + } + + boxGender.enabled = !ready; + txtYear.enabled = !ready; + txtMajor.enabled = !ready; + txtSemester.enabled = !ready; + // all datamembers are the desired length + return ready; + } + + ]]> + </mx:Script> + + <mx:VBox width="220" horizontalAlign="center"> + <mx:Label text="Personal Data" fontSize="18"/> + <mx:Label text="Please fill out the following fields:"/> + </mx:VBox> + + <mx:HBox> + <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> + <mx:HBox id="boxGender"> + <mx:RadioButton groupName="gender" label="M" id="radioMale"/> + <mx:RadioButton groupName="gender" label="F" id="radioFemale"/> + </mx:HBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtYear" width="75" maxChars="4"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtMajor" width="120" maxChars="100"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + </mx:HBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml 2009-03-06 22:31:03 UTC (rev 82) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + creationComplete="init()"> + + <mx:Script> + <![CDATA[ + [Bindable] private var showTime:String; + + private function init():void{ + // Update every second + var tmr:Timer = new Timer(1000); + tmr.addEventListener(TimerEvent.TIMER, changeTime); + tmr.start(); + } + + private function changeTime(event:TimerEvent):void{ + // Get Server Time + var serv:Date = new Date(); // *fix this* + + // Display Server Time + showTime = serv.toLocaleTimeString(); + } + ]]> + </mx:Script> + + <mx:Label text="{showTime}"/> + +</mx:Canvas> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-03-06 22:17:02
|
Revision: 81 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=81&view=rev Author: alllee Date: 2009-03-06 22:16:44 +0000 (Fri, 06 Mar 2009) Log Message: ----------- adding mentalmodels stub directories Added Paths: ----------- mentalmodels/ mentalmodels/branches/ mentalmodels/tags/ mentalmodels/trunk/ mentalmodels/trunk/flex/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-03-03 21:13:49
|
Revision: 80 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=80&view=rev Author: alllee Date: 2009-03-03 21:13:48 +0000 (Tue, 03 Mar 2009) Log Message: ----------- fully implementing field of vision Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-03-03 20:56:00 UTC (rev 79) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-03-03 21:13:48 UTC (rev 80) @@ -70,8 +70,7 @@ int width = (int) dw; int height = (int) dh; int offset = 1; - // paint residual tokens that you've consumed. - + // paint shrinking tokens that this client has consumed. synchronized (collectedTokens) { for (Iterator<Map.Entry<Point, Duration>> iter = collectedTokens.entrySet().iterator(); iter.hasNext();) { Map.Entry<Point, Duration> entry = iter.next(); @@ -116,22 +115,25 @@ for (Map.Entry<Identifier, ClientData> entry : positions.entrySet()) { Identifier id = entry.getKey(); Point subjectLocation = entry.getValue().getPosition(); - if (fieldOfVision != null && ! fieldOfVision.contains(subjectLocation)) { - // the other participant is outside of this subject's field of vision. - continue; + // optimized conditional + if (fieldOfVision == null || id.equals(dataModel.getId()) || fieldOfVision.contains(subjectLocation)) { + // only draw if: + // 1. field of vision is not enabled for subjects + // 2. subject being drawn is this participant (i.e., id == dataModel.id) + // 3. field of vision contains subject location + int scaledX = scaleX(subjectLocation.x); + int scaledY = scaleY(subjectLocation.y); + drawParticipant( graphics2D, id, scaledX, scaledY ); + // graphics2D.drawImage( getImage(id), scaledX, scaledY, null); + graphics2D.setColor( getSubjectNumberColor(id) ); + // Paint the subject's number + String subjectNumber = String.valueOf( dataModel.getAssignedNumber(id) ); + //Calculate x and y so that the text is center aligned + int characterWidth = fontMetrics.stringWidth(subjectNumber); + int x = (int) (scaledX + ( (dw - characterWidth) / 2)); + int y = (int) (scaledY + characterHeight - verticalCharacterSpacing); + graphics2D.drawString(subjectNumber, x, y); } - int scaledX = scaleX(subjectLocation.x); - int scaledY = scaleY(subjectLocation.y); - drawParticipant( graphics2D, id, scaledX, scaledY ); -// graphics2D.drawImage( getImage(id), scaledX, scaledY, null); - graphics2D.setColor( getSubjectNumberColor(id) ); -// Paint the subject's number - String subjectNumber = String.valueOf( dataModel.getAssignedNumber(id) ); - //Calculate x and y so that the text is center aligned - int characterWidth = fontMetrics.stringWidth(subjectNumber); - int x = (int) (scaledX + ( (dw - characterWidth) / 2)); - int y = (int) (scaledY + characterHeight - verticalCharacterSpacing); - graphics2D.drawString(subjectNumber, x, y); } } 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-03-03 20:56:00 UTC (rev 79) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-03-03 21:13:48 UTC (rev 80) @@ -8,7 +8,6 @@ import edu.asu.commons.conf.ExperimentRoundParameters; import edu.asu.commons.foraging.graphics.Point3D; -import edu.asu.commons.foraging.model.ResourceDispenser; public class RoundConfiguration extends ExperimentRoundParameters.Base<ServerConfiguration> { @@ -111,14 +110,14 @@ public double getViewSubjectsRadius() { if (isSubjectFieldOfVisionEnabled()) { - return getDoubleProperty("view-subjects-radius", 20); + return getDoubleProperty("view-subjects-radius", 10.0d); } throw new UnsupportedOperationException("subject field of vision is not enabled."); } public double getViewTokensRadius() { if (isTokensFieldOfVisionEnabled()) { - return getDoubleProperty("view-tokens-radius", 20); + return getDoubleProperty("view-tokens-radius", 10.0d); } throw new UnsupportedOperationException("view tokens field of vision is not enabled."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-03-03 20:56:06
|
Revision: 79 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=79&view=rev Author: alllee Date: 2009-03-03 20:56:00 +0000 (Tue, 03 Mar 2009) Log Message: ----------- removing default configuration, copy from the appropriate experiment directory Removed Paths: ------------- foraging/trunk/src/main/resources/configuration/round0.xml foraging/trunk/src/main/resources/configuration/round1.xml foraging/trunk/src/main/resources/configuration/round2.xml foraging/trunk/src/main/resources/configuration/round3.xml foraging/trunk/src/main/resources/configuration/round4.xml foraging/trunk/src/main/resources/configuration/round5.xml foraging/trunk/src/main/resources/configuration/round6.xml foraging/trunk/src/main/resources/configuration/server.xml Deleted: foraging/trunk/src/main/resources/configuration/round0.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round0.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round0.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="resource-width">13</entry> -<entry key="resource-depth">13</entry> -<entry key="practice-round">true</entry> -<entry key="private-property">true</entry> -<entry key="duration">240</entry> - -<entry key='regrowth-rate'>.01</entry> -<entry key='initial-distribution'>.25</entry> -<entry key='always-explicit'>true</entry> - -<entry key="quiz">true</entry> -<entry key="q1">C</entry> -<entry key="q2">B</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>General Instructions</h3> -<p> -You appear on the screen as a yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif">, -and your other group members appear as blue dots <img src="@CODEBASE_URL@/images/gem-other.gif">. -You move by pressing the four arrow keys to the right of your keyboard. You -can move either up, down, left, or right. You have to press a key for every -move of your yellow dot. In this experiment you can collect green diamond -shaped tokens -<img src="@CODEBASE_URL@/images/gem-token.gif"> and you will -earn two cents for each collected token. To collect a token, simply move your -yellow dot over a green token and press the <b>space bar</b>. If you move -over a token without pressing the <b>space bar</> you will NOT collect that -token. -</p> - -<p> -The tokens that you collect have the potential to regenerate. After you have -collected a green token, a new token can once again appear on that empty cell. -However, the rate at which new tokens will appear depends on the number of -adjacent cells that still have tokens. The more tokens in the 8 cells around -an empty cel, the faster a new token will appear on that empty cell. Tokens -generate new tokens. Thus the middle cell in Image 1 denoted with X will be -regenerated at a faster rate than the middle cell in Image 2. When all -neighboring cells are empty, there is no renewal. - -<table width="100%"> -<tr> -<td align="center"><b>Image 1</b></td> -<td align="center"><b>Image 2</b></td> -</tr> -<tr> -<td align="center"> -<img src="@CODEBASE_URL@/images/8neighbors.jpg" alt="image 1"> -</td> -<td align="center"> -<img src="@CODEBASE_URL@/images/5neighbors.jpg" alt="image 2"> -</td> -</tr> -</table> -<hr> -<h3>Practice Round Instructions</h3> -<hr> -<p> -You will now have four minutes to practice with the experimental environment. -The decisions you make in this round will NOT influence your earnings. At the -At the beginning of the practice round half of the cells are occupied -with green tokens. The environment is a 13 x 13 grid of cells. -</p> -<p> -When you push the <b>R</b> key you will reset the distribution of -the tokens to randomly occupying half of the cells with green tokens. -</p> - -<p><center><b>Please do not communicate with any other participant.</b></center></p> -<p>If you have any questions please raise your hand. <b>Do you have any -questions so far?</b></p> -]]> -</entry> - -<entry key="quiz-instructions"> -<![CDATA[ -<p> -Before we begin the practice round you need to answer the following questions -correctly. You can only continue when you have answered all questions -correctly. If an error is made you will need to answer the questions again. -</p> -<br> -<form> -Which of the statements is incorrect? <br> -<input type="radio" name="q1" value="A">Your decisions of where to collect tokens affect the regeneration of tokens.<br> -<input type="radio" name="q1" value="B">When you have collected all tokens on -the screen, no new tokens will appear.<br> -<input type="radio" name="q1" value="C">Tokens grow from the middle of the -screen.<br> -<input type="radio" name="q1" value="D">In order to collect a token you need -to press the space bar while your avatar is on a cell with a token.<br> -<br><br> - -Which sequence of situations is not possible? <br> -<img src="@CODEBASE_URL@/images/question2.jpg"><br> -<input type="radio" name="q2" value="A">A<br> -<input type="radio" name="q2" value="B">B<br> -<input type="radio" name="q2" value="C">C<br> -<br> -<input type="submit" name="submit" value="Submit"> -</form> -]]> -</entry> -<entry key="welcome-instructions"> -<![CDATA[ -<h3>Welcome</h3> -<p> -Welcome. You have already earned 5 dollars for showing up at this experiment. -You can earn more, up to a maximum of 40 dollars, by participating in this -experiment, which will take about an hour. The amount of money you earn -depends on your decisions as well as the decisions of your group members -during the four rounds of the experiment. -</p> -]]> -</entry> - -</properties> Deleted: foraging/trunk/src/main/resources/configuration/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round1.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round1.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,80 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> -<entry key="duration">240</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> - -<entry key='always-explicit'>true</entry> -<entry key='max-cell-occupancy'>1</entry> - -<entry key="initial-distribution">.25</entry> -<entry key="regrowth-rate">0.01</entry> - -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> -<entry key="chat-duration">240</entry> - -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and clicking the "send" button with your mouse or -pressing the "enter" key on your keyboard. </p> -]]> -</entry> - - -<entry key="instructions"> -<![CDATA[ -<h3>Round 1 Instructions</h3> -<hr> -<p> -This is the first round of the experiment. The length of the round is 4 -minutes. As in the practice round you can collect green tokens but there are -two important differences. You will earn <b>two cents</b> for each token -collected and you <b>cannot reset</b> the distribution of green tokens. -</p> -<p> -In this round the renewable resource will become five times bigger. You -will share this larger environment with four other players in this room. -Each of you has been randomly assigned to one of several equal-sized -groups. Each of the groups is collecting tokens from an identical, but -separate resource. -</p> -<p> -Each of you has been assigned a number from 1 to 5. The other four players -will appear on the screen as blue dots -<img src="@CODEBASE_URL@/images/gem-other.gif"> with a white -number embedded in the dot. On the top right corner of the screen you can see -how many tokens each player has collected. -</p> -<p> -Before the next round starts you can anonymously communicate via text messages -for four minutes with the other participants in your group. You can use this -opportunity to discuss the experiment and coordinate your actions to improve -your earnings. You may not promise them side-payments after the experiment is -completed or make any threats. You are also not allowed to reveal your real -identity. We will be monitoring the chat traffic while you chat. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> -</entry> -</properties> Deleted: foraging/trunk/src/main/resources/configuration/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round2.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round2.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> -<entry key="duration">240</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> - -<entry key='always-explicit'>true</entry> -<entry key='max-cell-occupancy'>1</entry> - -<entry key="initial-distribution">.25</entry> -<entry key="regrowth-rate">0.01</entry> -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> -<entry key="chat-duration">240</entry> - -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and clicking the "send" button with your mouse or -pressing the "enter" key on your keyboard. </p> -]]> -</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 2 Instructions</h3> -<hr> -<p> -Round 2 is the same as round 1. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> -</entry> -</properties> Deleted: foraging/trunk/src/main/resources/configuration/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round3.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round3.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> -<entry key="duration">240</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> - -<entry key='always-explicit'>true</entry> -<entry key='max-cell-occupancy'>1</entry> - -<!-- resource regrowth parameters --> -<entry key="initial-distribution">.25</entry> -<entry key="regrowth-rate">0.01</entry> - -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> -<entry key="chat-duration">240</entry> - -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and clicking the "send" button with your mouse or -pressing the "enter" key on your keyboard. </p> -]]> -</entry> - -<!-- -<entry key="patchy">true</entry> -<entry key="top-initial-distribution">0.50</entry> -<entry key="top-rate">0.02</entry> -<entry key="bottom-initial-distribution">0.25</entry> -<entry key="bottom-rate">0.01</entry> ---> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 3 Instructions</h3> -<hr> -<p> -Round 3 is the same as round 2. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> -</entry> -</properties> Deleted: foraging/trunk/src/main/resources/configuration/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round4.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round4.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> -<entry key="duration">240</entry> - -<entry key='always-explicit'>true</entry> -<entry key='max-cell-occupancy'>1</entry> - -<entry key="initial-distribution">.25</entry> -<entry key="regrowth-rate">0.01</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 4 Instructions</h3> -<hr> -<p> -Round 4 is the same as the previous rounds with one exception - you will not -be able to anonymously communicate with the other participants in your group. -</p> -<p> -The length of this round is four minutes. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> -</entry> - -</properties> Deleted: foraging/trunk/src/main/resources/configuration/round5.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round5.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round5.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> -<entry key="duration">240</entry> - -<entry key="initial-distribution">.25</entry> -<entry key="regrowth-rate">0.01</entry> - -<entry key='always-explicit'>true</entry> -<entry key='max-cell-occupancy'>1</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 5 Instructions</h3> -<hr> -<p> -Round 5 is the same as round 4.</p> -<p> -The length of this round is again four minutes. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> -</entry> - -</properties> Deleted: foraging/trunk/src/main/resources/configuration/round6.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round6.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/round6.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML-ized experiment round configuration</comment> -<entry key="display-group-tokens">true</entry> -<entry key="clients-per-group">5</entry> -<entry key="resource-depth">29</entry> -<entry key="resource-width">29</entry> -<entry key="duration">240</entry> - -<entry key="initial-distribution">.25</entry> -<entry key="regrowth-rate">0.01</entry> - -<entry key='always-explicit'>true</entry> -<entry key='max-cell-occupancy'>1</entry> - -<entry key="instructions"> -<![CDATA[ -<h3>Round 6 Instructions</h3> -<hr> -<p> -Round 6 is the same as round 5.</p> -<p> -The length of this round is again four minutes. -</p> -<p> -If you have any questions please raise your hand. <b>Do you have any -questions so far?</b> -</p> -]]> -</entry> - -<entry key="last-round-debriefing"> -<![CDATA[ -<p> -This was the last round, but not the end of the experiment. We will now -determine your payments. While we are doing this, we request that you -carefully fill out a brief survey. -</p> -<p> -When we are ready we will call you one by one to the room next door. We will -pay you there in private. Please wait until your computer number is called, -and then proceed to the room next door to turn in your computer number and -your survey. -</p> -<p> -Please answer the survey carefully and thank you for participating. -</p> -]]> -</entry> - -</properties> Deleted: foraging/trunk/src/main/resources/configuration/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/server.xml 2009-03-03 03:36:25 UTC (rev 78) +++ foraging/trunk/src/main/resources/configuration/server.xml 2009-03-03 20:56:00 UTC (rev 79) @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> -<properties> -<comment>Foraging XML experiment round configuration</comment> -<entry key="hostname">@SERVER_ADDRESS@</entry> -<entry key="port">@PORT_NUMBER@</entry> -<entry key="round0">round0.xml</entry> -<entry key="round1">round1.xml</entry> -<entry key="round2">round2.xml</entry> -<entry key="round3">round3.xml</entry> -<entry key="round4">round4.xml</entry> -<entry key="round5">round5.xml</entry> -<entry key="round6">round6.xml</entry> -<entry key="wait-for-participants">true</entry> -<entry key="number-of-rounds">7</entry> -<entry key="facilitator-instructions"> -<![CDATA[ -<h3>Facilitator Instructions</h3> -<p> -Welcome to the facilitator interface. This interface allows you to control -the experiment. You may only modify configuration parameters <b>before</b> -you start the experiment by selecting the Configuration menu. When all the -participants are ready to begin the experiment, you can start the experiment -by selecting Experiment -> Start. After a round has been completed you -will be able to view the statistics for all of the participants. You can -begin the next round by selecting Round -> Start. -</p> -]]> -</entry> -</properties> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-03-03 03:36:28
|
Revision: 78 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=78&view=rev Author: alllee Date: 2009-03-03 03:36:25 +0000 (Tue, 03 Mar 2009) Log Message: ----------- refactoring ResourceGenerator and ResourceDispenser some more, moving initialize() and generateInitialDistribution() into interface. Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenCollectedEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokensMovedEvent.java 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-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-03-03 03:36:25 UTC (rev 78) @@ -8,6 +8,7 @@ import edu.asu.commons.conf.ExperimentRoundParameters; import edu.asu.commons.foraging.graphics.Point3D; +import edu.asu.commons.foraging.model.ResourceDispenser; public class RoundConfiguration extends ExperimentRoundParameters.Base<ServerConfiguration> { @@ -22,8 +23,9 @@ private static final double DEFAULT_DOLLARS_PER_TOKEN = .02d; private static final double DEFAULT_TOKEN_MOVEMENT_PROBABILITY = 0.02d; + + private static final double DEFAULT_TOKEN_BIRTH_PROBABILITY = 0.02d; - private final static Map<String, SanctionType> sanctionTypeMap = new HashMap<String, SanctionType>(3); public enum SanctionType { REAL_TIME("real-time"), POST_ROUND("post-round"), NONE("none"); @@ -44,6 +46,8 @@ private final static Map<String, ExperimentType> experimentTypeMap = new HashMap<String, ExperimentType>(3); + + public enum ExperimentType { TWO_DIMENSIONAL("2d"), ABSTRACT("abstract"), FORESTRY("forestry"); private final String name; @@ -63,10 +67,10 @@ } } - enum SanctionAction { + public enum SanctionAction { FINE, FREEZE; } - + public RoundConfiguration() { super(); } @@ -89,14 +93,14 @@ return getIntProperty("sanction-flash-duration", DEFAULT_SANCTION_FLASH_DURATION); } + public double getTokenBirthProbability() { + return getDoubleProperty("token-birth-probability", DEFAULT_TOKEN_BIRTH_PROBABILITY); + } + public double getTokenMovementProbability() { return getDoubleProperty("token-movement-probability", DEFAULT_TOKEN_MOVEMENT_PROBABILITY); } - public boolean isMobileResource() { - return getBooleanProperty("mobile-resource", false); - } - public boolean isTokensFieldOfVisionEnabled() { return getBooleanProperty("tokens-field-of-vision", false); } @@ -107,14 +111,14 @@ public double getViewSubjectsRadius() { if (isSubjectFieldOfVisionEnabled()) { - return getDoubleProperty("view-subjects-radius"); + return getDoubleProperty("view-subjects-radius", 20); } throw new UnsupportedOperationException("subject field of vision is not enabled."); } public double getViewTokensRadius() { if (isTokensFieldOfVisionEnabled()) { - return getDoubleProperty("view-tokens-radius"); + return getDoubleProperty("view-tokens-radius", 20); } throw new UnsupportedOperationException("view tokens field of vision is not enabled."); } @@ -297,8 +301,8 @@ return getDoubleProperty("bottom-initial-distribution", 0.25); } - public boolean isPatchy() { - return getBooleanProperty("patchy", false); + public String getResourceGeneratorType() { + return getProperty("resource-generator", "density-dependent"); } public int getWorldWidth() { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java 2009-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java 2009-03-03 03:36:25 UTC (rev 78) @@ -5,14 +5,27 @@ import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; +/** + * $Id$ + * + * Signifies that a resource at location source gave "birth" at location offspring. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ public class TokenBirthEvent extends AbstractPersistableEvent { private static final long serialVersionUID = -5583615580820624952L; private final Point parent; private final Point offspring; - - public TokenBirthEvent(Identifier id, Point source, Point offspring) { - super(id); + + /** + * No Identifier is necessary since this is a system generated event. + * @param source + * @param offspring + */ + public TokenBirthEvent(Point source, Point offspring) { + super(Identifier.NULL); this.parent = source; this.offspring = offspring; } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenCollectedEvent.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenCollectedEvent.java 2009-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenCollectedEvent.java 2009-03-03 03:36:25 UTC (rev 78) @@ -5,8 +5,18 @@ import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; +/** + * $Id$ + * + * Persistable event signifying that a token was collected at some Point getLocation() by + * the participant with Identifier getId(). + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ public class TokenCollectedEvent extends AbstractPersistableEvent { + // FIXME: crappy but keep it for backwards compatibility. private static final long serialVersionUID = 1L; private final Point location; Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java 2009-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java 2009-03-03 03:36:25 UTC (rev 78) @@ -4,15 +4,22 @@ import edu.asu.commons.event.AbstractPersistableEvent; import edu.asu.commons.net.Identifier; - +/** + * $Id$ + * + * Signifies that a token moved from source to destination. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ public class TokenMovedEvent extends AbstractPersistableEvent { private static final long serialVersionUID = -8130009188192973062L; private final Point source; private final Point destination; - public TokenMovedEvent(Identifier id, Point source, Point destination) { - super(id); + public TokenMovedEvent(Point source, Point destination) { + super(Identifier.NULL); this.source = source; this.destination = destination; } Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokensMovedEvent.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokensMovedEvent.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokensMovedEvent.java 2009-03-03 03:36:25 UTC (rev 78) @@ -0,0 +1,38 @@ +package edu.asu.commons.foraging.event; + +import java.awt.Point; +import java.util.Collection; + +import edu.asu.commons.event.AbstractPersistableEvent; +import edu.asu.commons.net.Identifier; +/** + * $Id$ + * + * Bulk token movement event containing old locations that should be removed and + * the new locations that should be added. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public class TokensMovedEvent extends AbstractPersistableEvent { + + private static final long serialVersionUID = -8130009188192973062L; + private final Collection<Point> originalLocations; + private final Collection<Point> newLocations; + + public TokensMovedEvent(Collection<Point> originalLocations, Collection<Point> newLocations) { + super(Identifier.NULL); + this.originalLocations = originalLocations; + this.newLocations = newLocations; + } + + public Collection<Point> getOriginalLocations() { + return originalLocations; + } + + public Collection<Point> getNewLocations() { + return newLocations; + } + + +} Property changes on: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokensMovedEvent.java ___________________________________________________________________ Added: svn:keywords + Date Revision Id 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-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-03-03 03:36:25 UTC (rev 78) @@ -2,6 +2,7 @@ import java.awt.Point; import java.io.Serializable; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -116,24 +117,54 @@ public void addResource(Resource resource) { Point position = resource.getPosition(); - resourceDistribution.put(position, resource); + synchronized (resourceDistribution) { + resourceDistribution.put(position, resource); + } getAddedResources().add(resource); } + void addResources(Collection<Point> locations) { + synchronized (resourceDistribution) { + for (Point point : locations) { + Resource resource = new Resource(point); + resourceDistribution.put(point, resource); + getAddedResources().add(resource); + } + } + } + public void addResources(Set<Resource> resources) { - for (Resource resource: resources) { - Point position = resource.getPosition(); - resourceDistribution.put(position, resource); - getAddedResources().add(resource); + synchronized (resourceDistribution) { + for (Resource resource: resources) { + Point position = resource.getPosition(); + resourceDistribution.put(position, resource); + getAddedResources().add(resource); + } } } + void moveResources(Collection<Point> removedResources, Collection<Point> addedResources) { + synchronized (resourceDistribution) { + for (Point oldLocation: removedResources) { + Resource oldResource = resourceDistribution.remove(oldLocation); + getRemovedResources().add(oldResource); + } + for (Point newLocation : addedResources) { + Resource newResource = new Resource(newLocation); + resourceDistribution.put(newLocation, newResource); + getAddedResources().add(newResource); + } + } + } + /** - * Only invoked when replaying a round and stepping backwards + * Currently only invoked when replaying a round and stepping backwards. * @param position */ public void removeResource(Point position) { - resourceDistribution.remove(position); + synchronized (resourceDistribution) { + resourceDistribution.remove(position); + } } public Set<Identifier> getClientIdentifiers() { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java 2009-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java 2009-03-03 03:36:25 UTC (rev 78) @@ -1,9 +1,15 @@ package edu.asu.commons.foraging.model; import java.awt.Point; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.logging.Logger; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; @@ -21,18 +27,39 @@ */ public class ResourceDispenser { + + private final static Logger logger = Logger.getLogger( ResourceDispenser.class.getName() ); + private final static Map<String, Type> resourceGeneratorTypeMap = new HashMap<String, Type>(3); + public enum Type { + DENSITY_DEPENDENT("density-dependent"), TOP_BOTTOM_PATCHY("top-bottom-patchy"), MOBILE("mobile"); + private Type(String name) { + resourceGeneratorTypeMap.put(name, this); + } + + public static Type find(final String name) { + Type type = resourceGeneratorTypeMap.get(name); + if (type == null) { + type = valueOf(name); + if (type == null) { + // FIXME: default value is density-dependent + logger.warning("Couldn't find resource generator by name, returning default: " + name); + type = DENSITY_DEPENDENT; + } + } + return type; + } + } + private final ServerDataModel serverDataModel; - // value between 0 and 1 - private double rate = 0.0d; private final Random random = new Random(); - // FIXME: turn these into factory driven based on configuration parameter. + private ResourceGenerator currentResourceGenerator; - private final StochasticGenerator stochasticGrowthGenerator = new DensityDependentResourceGenerator(); - private final InitialResourceGenerator initialResourceGenerator = new InitialResourceGenerator(); - private final TopBottomPatchGenerator patchyGrowthGenerator = new TopBottomPatchGenerator(); + private final StochasticGenerator densityDependentGenerator = new DensityDependentResourceGenerator(); + private final TopBottomPatchGenerator topBottomPatchGenerator = new TopBottomPatchGenerator(); + private final MobileResourceGenerator mobileResourceGenerator = new MobileResourceGenerator(); // FIXME: refactor this so that there's a single generator/strategy that gets used per round? // private Generator resourceGenerator; @@ -46,27 +73,34 @@ GroupDataModel group = serverDataModel.getGroup(event.getId()); group.resetResourceDistribution(); // FIXME: won't work if practice round is patchy - initialResourceGenerator.generate(group); + Set<Resource> resources = currentResourceGenerator.generateInitialDistribution(group); + serverDataModel.addResources(group, resources); } } public void initialize() { - RoundConfiguration configuration = serverDataModel.getRoundConfiguration(); - // FIXME: this is hacky, clean it up. - if (configuration.isPatchy()) { - patchyGrowthGenerator.initialize(configuration); + initialize(serverDataModel.getRoundConfiguration()); + } + + public void initialize(RoundConfiguration roundConfiguration) { + Type resourceGeneratorType = Type.find( roundConfiguration.getResourceGeneratorType() ); + currentResourceGenerator = getResourceGenerator( resourceGeneratorType ); + currentResourceGenerator.initialize(roundConfiguration); + } + + protected ResourceGenerator getResourceGenerator(Type resourceGeneratorType) { + switch (resourceGeneratorType) { + case DENSITY_DEPENDENT: + return densityDependentGenerator; + case TOP_BOTTOM_PATCHY: + return topBottomPatchGenerator; + case MOBILE: + return mobileResourceGenerator; + default: + return densityDependentGenerator; } - else { - setRate(configuration.getRegrowthRate()); - generateResources(initialResourceGenerator.setInitialDistribution(configuration.getInitialDistribution())); - Resource.setConfiguration(configuration); - } } - public void setRate(double rate) { - this.rate = rate; - } - public void updateResourceAge(GroupDataModel group) { for (Resource resource: group.getResourceDistribution().values()) { resource.increaseAge(); @@ -74,11 +108,16 @@ } public void generateResources() { - generateResources( getStochasticGenerator() ); + generateResources( getCurrentResourceGenerator() ); } + /** + * Special-case optimization for 3D visualization only. + * + * @param group + */ public void generateResources(GroupDataModel group) { - stochasticGrowthGenerator.generate(group); + densityDependentGenerator.generate(group); } public void generateResources(ResourceGenerator generator) { @@ -88,14 +127,108 @@ } } - public StochasticGenerator getStochasticGenerator() { - if (serverDataModel.getRoundConfiguration().isPatchy()) { - return patchyGrowthGenerator; + public ResourceGenerator getCurrentResourceGenerator() { + return currentResourceGenerator; + } + + public class MobileResourceGenerator extends ResourceGenerator.Base { + private double tokenMovementProbability; + private double tokenBirthProbability; + public void initialize(RoundConfiguration roundConfiguration) { + this.tokenMovementProbability = roundConfiguration.getTokenMovementProbability(); + this.tokenBirthProbability = roundConfiguration.getTokenBirthProbability(); + for (GroupDataModel group: serverDataModel.getGroups()) { + Set<Resource> resources = generateInitialDistribution(group); + serverDataModel.addResources(group, resources); + } } - else { - return stochasticGrowthGenerator; + /** + * Moves all resources one-at-a-time. Moved resources need to be aware of the updated + * resource positions, otherwise resources could "disappear". + * XXX: could optimize by generating a list of all removed resources and then a list of all added resources + * and then first removing all resources and then adding new resources. + * @param group + */ + public void generate(GroupDataModel group) { + // getResourcePositions() returns a new HashSet + // this Set will contain the most up-to-date resource positions as a working copy. + final Set<Point> currentResourcePositions = group.getResourcePositions(); + final Set<Point> addedResources = new HashSet<Point>(); + final Set<Point> removedResources = new HashSet<Point>(); + // iterate over a copy so we can update currentResourcePositions. + // we need to update them one-at-a-time, otherwise a resource might move to a location that + // has already been moved to... + final List<Point> shuffledCopy = new ArrayList<Point>(currentResourcePositions); + Collections.shuffle(shuffledCopy); + // iterate through a new randomized copy of the points + for (Point currentResourcePosition: shuffledCopy) { + if (random.nextDouble() < tokenMovementProbability) { + // this token is ready to move. + final List<Point> validNeighbors = getValidMooreNeighborhood(currentResourcePosition, currentResourcePositions); + if (validNeighbors.isEmpty()) { + // this point can't move anywhere. + continue; + } + final Point newPosition = validNeighbors.get(random.nextInt(validNeighbors.size())); + // either execute one move at a time or execute a bulk move. + addedResources.add(newPosition); + removedResources.add(currentResourcePosition); +// serverDataModel.moveResource(group, currentResourcePosition, newPosition); + currentResourcePositions.remove(currentResourcePosition); + currentResourcePositions.add(newPosition); +// newResources.add(new Resource(newPosition)); +// removedResources.add(currentResourcePosition); + } + } + serverDataModel.moveResources(group, removedResources, addedResources); + shuffledCopy.clear(); + shuffledCopy.addAll(currentResourcePositions); + Collections.shuffle(shuffledCopy); + Set<Resource> addedOffspring = new HashSet<Resource>(); + // next, generate offspring. + // use current resource positions. + for (Point currentResourcePosition: currentResourcePositions) { + if (random.nextDouble() < tokenBirthProbability) { + final List<Point> validNeighbors = getValidMooreNeighborhood(currentResourcePosition, currentResourcePositions); + if (validNeighbors.isEmpty()) { + // cannot generate offspring anywhere, is resource-locked. + continue; + } + final Point offspringPosition = validNeighbors.get(random.nextInt(validNeighbors.size())); + addedOffspring.add(new Resource(offspringPosition)); + } + } + serverDataModel.addResources(group, addedOffspring); } - + + private List<Point> getValidMooreNeighborhood(Point referencePoint, Set<Point> existingPositions) { + List<Point> neighborhoodPoints = new ArrayList<Point>(); + int currentX = referencePoint.x; + int currentY = referencePoint.y; + for (int x = currentX - 1; x < currentX + 2; x++) { + for (int y = currentY - 1; y < currentY + 2; y++) { + Point point = new Point(x, y); + // only add a point to the neighborhood set if it doesn't already have a resource. + if (! existingPositions.contains(point)) { + neighborhoodPoints.add(point); + } + + } + } + return neighborhoodPoints; + } + + private Set<Point> getMooreNeighborhood(Point point) { + Set<Point> neighborhoodPoints = new HashSet<Point>(); + int currentX = point.x; + int currentY = point.y; + for (int x = currentX - 1; x < currentX + 2; x++) { + for (int y = currentY - 1; y < currentY + 2; y++) { + neighborhoodPoints.add(new Point(x, y)); + } + } + return neighborhoodPoints; + } } public class TopBottomPatchGenerator extends DensityDependentResourceGenerator { @@ -127,28 +260,34 @@ setTopDistribution(configuration.getTopInitialResourceDistribution()); setTopRate(configuration.getTopRegrowthScalingFactor()); for (GroupDataModel group: serverDataModel.getGroups()) { - generateInitialDistribution(group); + Set<Resource> resources = generateInitialDistribution(group); + serverDataModel.addResources(group, resources); } } - public void generateInitialDistribution(GroupDataModel group) { + + /** + * Generates an initial distribution for top/bottom patches based on the top/bottom initial distribution + * configuration parameters. + */ + @Override + public Set<Resource> generateInitialDistribution(GroupDataModel group) { int width = serverDataModel.getBoardWidth(); int height = serverDataModel.getBoardHeight() / 2; - int tokensNeeded = (int) (width * height * topDistribution); - System.err.println("number of tokens needed on top: " + tokensNeeded); + int topTokensNeeded = (int) (width * height * topDistribution); + logger.info("number of tokens needed on top: " + topTokensNeeded); Set<Resource> newResources = new HashSet<Resource>(); - while (newResources.size() < tokensNeeded) { + while (newResources.size() < topTokensNeeded) { Point point = new Point(random.nextInt(width), random.nextInt(height)); newResources.add(new Resource(point)); } - serverDataModel.addResources(group, newResources); - newResources.clear(); - tokensNeeded = (int) (width * height * bottomDistribution); - System.err.println("number of tokens needed on bottom:" + tokensNeeded); + int bottomTokensNeeded = (int) (width * height * bottomDistribution); + logger.info("number of tokens needed on bottom:" + bottomTokensNeeded); + int tokensNeeded = topTokensNeeded + bottomTokensNeeded; while (newResources.size() < tokensNeeded) { Point point = new Point(random.nextInt(width), random.nextInt(height) + height); newResources.add(new Resource(point)); } - serverDataModel.addResources(group, newResources); + return newResources; } @Override @@ -161,7 +300,7 @@ for (int x = 0; x < serverDataModel.getBoardWidth(); x++) { Point currentPoint = new Point(x, y); if (!group.isResourceAt(currentPoint)) { - if (Math.random() < getProbabilityForCell(group, x, y, topRate)) { + if (random.nextDouble() < getProbabilityForCell(group, x, y, topRate)) { newResources.add(new Resource(currentPoint)); } } @@ -172,7 +311,7 @@ for (int x = 0; x < serverDataModel.getBoardWidth(); x++) { Point currentPoint = new Point(x, y); if (!group.isResourceAt(currentPoint)) { - if (Math.random() < getProbabilityForCell(group, x, y, bottomRate)) { + if (random.nextDouble() < getProbabilityForCell(group, x, y, bottomRate)) { newResources.add(new Resource(currentPoint)); } } @@ -189,17 +328,33 @@ } } + + + /** * Using the Strategy pattern to factor out algorithm from food dispensing. * - * New food dispenser algorithm: 1. iterate through entire grid.. 2. for + * New resource dispenser algorithm: 1. iterate through entire grid.. 2. for * each cell in the grid, calculate ratio of food-occupied neighboring cells * to max number of cells 3. multiply ratio by food probability - * configuration parameter and 8?. 4. if result > Math.random(), add food to + * configuration parameter and 8?. 4. if result > random.nextDouble(), add food to * that grid cell. */ - public class DensityDependentResourceGenerator implements StochasticGenerator { + public class DensityDependentResourceGenerator extends ResourceGenerator.Base + implements StochasticGenerator { + private double rate; + + public void initialize(RoundConfiguration roundConfiguration) { + this.rate = roundConfiguration.getRegrowthRate(); + for (GroupDataModel group: serverDataModel.getGroups()) { + Set<Resource> resources = generateInitialDistribution(group); + serverDataModel.addResources(group, resources); + } + // FIXME: is this necessary? + Resource.setConfiguration(roundConfiguration); + } + public double getProbabilityForCell(GroupDataModel group, int currentX, int currentY) { return getProbabilityForCell(group, currentX, currentY, rate); } @@ -209,14 +364,14 @@ } protected double getNeighborsTokenRatio(GroupDataModel group, int currentX, int currentY) { - Point neighbor; double neighborsWithTokens = 0; // start off at -1 to offset the off-by-one we get from adding the // current cell. double maxNeighbors = -1; + // use the Moore neighborhood (all 8 cells surrounding the empty cell). for (int x = currentX - 1; x < currentX + 2; x++) { for (int y = currentY - 1; y < currentY + 2; y++) { - neighbor = new Point(x, y); + Point neighbor = new Point(x, y); // FIXME: if we ever decide to have Group-specific boundaries/territorial // sizes, then we will need to change this. if (serverDataModel.isValidPosition(neighbor)) { @@ -241,8 +396,8 @@ for (int y = 0; y < serverDataModel.getBoardHeight(); y++) { for (int x = 0; x < serverDataModel.getBoardWidth(); x++) { Point currentPoint = new Point(x, y); - if (!group.isResourceAt(currentPoint)) { - if (Math.random() < getProbabilityForCell(group, x, y)) { + if ( ! group.isResourceAt(currentPoint) ) { + if (random.nextDouble() < getProbabilityForCell(group, x, y)) { // FIXME: should initial age be parameterizable? newResources.add(new Resource(currentPoint, 1)); } @@ -253,40 +408,18 @@ } } - public class InitialResourceGenerator implements ResourceGenerator { - private double initialDistribution = 0.5d; - public ResourceGenerator setInitialDistribution(double initialDistribution) { - this.initialDistribution = initialDistribution; - return this; - } - public void generate(GroupDataModel group) { - int width = serverDataModel.getBoardWidth(); - int height = serverDataModel.getBoardHeight(); - System.err.println("initial distribution factor:" + initialDistribution); - int tokensNeeded = (int) (width * height * initialDistribution); - System.err.println("number of tokens needed: " + tokensNeeded); - RoundConfiguration configuration = serverDataModel.getRoundConfiguration(); - boolean ageMatters = ! serverDataModel.is2dExperiment(); - int maximumResourceAge = configuration.getMaximumResourceAge(); - boolean shouldVaryAge = maximumResourceAge > 0; - Set<Resource> newResources = new HashSet<Resource>(); - while (newResources.size() < tokensNeeded) { - Point point = new Point(random.nextInt(width), random.nextInt(height)); - Resource resource = new Resource(point); - if (! newResources.contains(resource)) { - if (ageMatters && shouldVaryAge) { - resource.setAge(random.nextInt(maximumResourceAge) + 1); - } - newResources.add(resource); - } + public StochasticGenerator getDensityDependentGenerator() { + return densityDependentGenerator; + } - } - serverDataModel.addResources(group, newResources); - System.err.println("number of tokens generated: " + group.getResourceDistributionSize()); - } + public TopBottomPatchGenerator getTopBottomPatchGenerator() { + return topBottomPatchGenerator; } - + public MobileResourceGenerator getMobileResourceGenerator() { + return mobileResourceGenerator; + } + } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java 2009-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java 2009-03-03 03:36:25 UTC (rev 78) @@ -1,5 +1,12 @@ package edu.asu.commons.foraging.model; +import java.awt.Point; +import java.util.HashSet; +import java.util.Random; +import java.util.Set; + +import edu.asu.commons.foraging.conf.RoundConfiguration; + /** * $Id$ * @@ -9,5 +16,34 @@ * @version $Revision$ */ public interface ResourceGenerator { + public void initialize(RoundConfiguration roundConfiguration); + public Set<Resource> generateInitialDistribution(GroupDataModel group); public void generate(GroupDataModel group); + + public static abstract class Base implements ResourceGenerator { + private final Random random = new Random(); + public Set<Resource> generateInitialDistribution(GroupDataModel group) { + RoundConfiguration configuration = group.getRoundConfiguration(); + int width = configuration.getResourceWidth(); + int height = configuration.getResourceDepth(); + double initialDistribution = configuration.getInitialDistribution(); + int tokensNeeded = (int) (width * height * initialDistribution); + boolean ageMatters = ! configuration.is2dExperiment(); + int maximumResourceAge = configuration.getMaximumResourceAge(); + boolean shouldVaryAge = maximumResourceAge > 0; + Set<Resource> newResources = new HashSet<Resource>(); + while (newResources.size() < tokensNeeded) { + Point point = new Point(random.nextInt(width), random.nextInt(height)); + Resource resource = new Resource(point); + if (! newResources.contains(resource)) { + if (ageMatters && shouldVaryAge) { + resource.setAge(random.nextInt(maximumResourceAge) + 1); + } + newResources.add(resource); + } + + } + return newResources; + } + } } \ No newline at end of file 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-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java 2009-03-03 03:36:25 UTC (rev 78) @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Random; @@ -28,6 +29,8 @@ 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.event.TokenMovedEvent; +import edu.asu.commons.foraging.event.TokensMovedEvent; import edu.asu.commons.foraging.event.UnlockResourceRequest; import edu.asu.commons.foraging.graphics.FractalTerrain; import edu.asu.commons.net.Identifier; @@ -44,13 +47,13 @@ public class ServerDataModel extends ForagingDataModel { private static final long serialVersionUID = 8166812955398387600L; - - private final Random randomNumberGenerator = new Random(); + private final transient Logger logger = Logger.getLogger( getClass().getName() ); + + private final transient Random random = new Random(); + private transient FractalTerrain terrain; - private Logger logger = Logger.getLogger( getClass().getName() ); - // Maps client Identifiers to the Group that client belongs to. private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); @@ -179,11 +182,27 @@ 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() { for (GroupDataModel group: clientsToGroups.values()) { group.clearResourceDistribution(); @@ -195,8 +214,8 @@ } public Point createRandomPoint() { - int x = randomNumberGenerator.nextInt(getBoardWidth()); - int y = randomNumberGenerator.nextInt(getBoardHeight()); + int x = random.nextInt(getBoardWidth()); + int y = random.nextInt(getBoardHeight()); return new Point(x, y); } 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-02-26 00:59:28 UTC (rev 77) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-03-03 03:36:25 UTC (rev 78) @@ -536,7 +536,7 @@ List<Double> expectedTokens = new ArrayList<Double>(); Set<GroupDataModel> groups = state.getGroups(); ResourceDispenser dispenser = new ResourceDispenser(state); - StochasticGenerator generator = dispenser.getStochasticGenerator(); + StochasticGenerator generator = dispenser.getDensityDependentGenerator(); for (GroupDataModel group: groups) { double tokenProbabilitySum = 0; for (int x = 0; x < state.getBoardWidth(); x++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-02-26 00:59:38
|
Revision: 77 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=77&view=rev Author: alllee Date: 2009-02-26 00:59:28 +0000 (Thu, 26 Feb 2009) Log Message: ----------- new events for mobile resource dispenser Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java 2009-02-26 00:59:28 UTC (rev 77) @@ -0,0 +1,29 @@ +package edu.asu.commons.foraging.event; + +import java.awt.Point; + +import edu.asu.commons.event.AbstractPersistableEvent; +import edu.asu.commons.net.Identifier; + +public class TokenBirthEvent extends AbstractPersistableEvent { + + private static final long serialVersionUID = -5583615580820624952L; + private final Point parent; + private final Point offspring; + + public TokenBirthEvent(Identifier id, Point source, Point offspring) { + super(id); + this.parent = source; + this.offspring = offspring; + } + + public Point getParent() { + return parent; + } + + public Point getOffspring() { + return offspring; + } + + +} Property changes on: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenBirthEvent.java ___________________________________________________________________ Added: svn:keywords + Date Revision Id Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java 2009-02-26 00:59:28 UTC (rev 77) @@ -0,0 +1,29 @@ +package edu.asu.commons.foraging.event; + +import java.awt.Point; + +import edu.asu.commons.event.AbstractPersistableEvent; +import edu.asu.commons.net.Identifier; + +public class TokenMovedEvent extends AbstractPersistableEvent { + + private static final long serialVersionUID = -8130009188192973062L; + private final Point source; + private final Point destination; + + public TokenMovedEvent(Identifier id, Point source, Point destination) { + super(id); + this.source = source; + this.destination = destination; + } + + public Point getSource() { + return source; + } + + public Point getDestination() { + return destination; + } + + +} Property changes on: foraging/trunk/src/main/java/edu/asu/commons/foraging/event/TokenMovedEvent.java ___________________________________________________________________ Added: svn:keywords + Date Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-02-25 18:02:43
|
Revision: 76 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=76&view=rev Author: alllee Date: 2009-02-25 18:02:38 +0000 (Wed, 25 Feb 2009) Log Message: ----------- starting test harness for resource dispenser, preparing to add MovingResourceDispenser Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.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 Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/StochasticGenerator.java foraging/trunk/src/test/java/edu/asu/commons/foraging/model/ResourceDispenserTest.java 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-02-20 22:55:53 UTC (rev 75) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-02-25 18:02:38 UTC (rev 76) @@ -10,6 +10,7 @@ import java.util.TreeSet; import java.util.logging.Logger; +import edu.asu.commons.experiment.DataModel; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.foraging.event.ClientPositionUpdateEvent; import edu.asu.commons.foraging.event.LockResourceRequest; @@ -32,7 +33,7 @@ * @version $Revision$ */ -public class GroupDataModel implements Serializable, Comparable<GroupDataModel> { +public class GroupDataModel implements Serializable, Comparable<GroupDataModel>, DataModel<RoundConfiguration> { private static final long serialVersionUID = -4756267788191037505L; Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java 2009-02-20 22:55:53 UTC (rev 75) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java 2009-02-25 18:02:38 UTC (rev 76) @@ -28,7 +28,9 @@ private double rate = 0.0d; private final Random random = new Random(); - private final StochasticGenerator stochasticGrowthGenerator = new StochasticGrowthGenerator(); + // FIXME: turn these into factory driven based on configuration parameter. + + private final StochasticGenerator stochasticGrowthGenerator = new DensityDependentResourceGenerator(); private final InitialResourceGenerator initialResourceGenerator = new InitialResourceGenerator(); private final TopBottomPatchGenerator patchyGrowthGenerator = new TopBottomPatchGenerator(); @@ -50,10 +52,7 @@ public void initialize() { RoundConfiguration configuration = serverDataModel.getRoundConfiguration(); - // initialize food cells - System.err.println("configuration's initial token distribution: " + configuration.getInitialDistribution() - + " " + configuration.getResourceFilename()); - // FIXME: clean this up. + // FIXME: this is hacky, clean it up. if (configuration.isPatchy()) { patchyGrowthGenerator.initialize(configuration); } @@ -82,7 +81,7 @@ stochasticGrowthGenerator.generate(group); } - public void generateResources(Generator generator) { + public void generateResources(ResourceGenerator generator) { for (GroupDataModel group : serverDataModel.getGroups()) { // logger.info("Making food with generator: " + generator + " for group : " + group); generator.generate(group); @@ -99,7 +98,7 @@ } - public class TopBottomPatchGenerator extends StochasticGrowthGenerator { + public class TopBottomPatchGenerator extends DensityDependentResourceGenerator { private double topRate; private double bottomRate; @@ -200,7 +199,7 @@ * that grid cell. */ - public class StochasticGrowthGenerator implements StochasticGenerator { + public class DensityDependentResourceGenerator implements StochasticGenerator { public double getProbabilityForCell(GroupDataModel group, int currentX, int currentY) { return getProbabilityForCell(group, currentX, currentY, rate); } @@ -254,10 +253,10 @@ } } - public class InitialResourceGenerator implements Generator { + public class InitialResourceGenerator implements ResourceGenerator { private double initialDistribution = 0.5d; - public Generator setInitialDistribution(double initialDistribution) { + public ResourceGenerator setInitialDistribution(double initialDistribution) { this.initialDistribution = initialDistribution; return this; } @@ -289,14 +288,5 @@ } } - public interface Generator { - public void generate(GroupDataModel group); - } - - public interface StochasticGenerator extends Generator { - public double getProbabilityForCell(GroupDataModel group, int x, int y); - // FIXME: replace InitialFoodGenerator with initialize() method. - } - } Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java 2009-02-25 18:02:38 UTC (rev 76) @@ -0,0 +1,13 @@ +package edu.asu.commons.foraging.model; + +/** + * $Id$ + * + * ResourceGenerators add resources directly to the GroupDataModel. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public interface ResourceGenerator { + public void generate(GroupDataModel group); +} \ No newline at end of file Property changes on: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceGenerator.java ___________________________________________________________________ Added: svn:keywords + Date Revision 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-02-20 22:55:53 UTC (rev 75) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java 2009-02-25 18:02:38 UTC (rev 76) @@ -12,6 +12,7 @@ import java.util.Queue; import java.util.Random; import java.util.Set; +import java.util.logging.Logger; import edu.asu.commons.event.EventChannel; import edu.asu.commons.event.EventTypeChannel; @@ -48,8 +49,14 @@ private transient FractalTerrain terrain; + private Logger logger = Logger.getLogger( getClass().getName() ); + // Maps client Identifiers to the Group that client belongs to. private final Map<Identifier, GroupDataModel> clientsToGroups = new HashMap<Identifier, GroupDataModel>(); + + public ServerDataModel() { + super(EventTypeChannel.getInstance()); + } public ServerDataModel(EventChannel channel) { super(channel); @@ -139,7 +146,7 @@ else { // FIXME: this is pretty draconian, maybe relax this a little bit // later. - System.err.println("unapplyable event:" + event); + logger.warning("could not apply event:" + event); } } Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/StochasticGenerator.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/StochasticGenerator.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/StochasticGenerator.java 2009-02-25 18:02:38 UTC (rev 76) @@ -0,0 +1,14 @@ +package edu.asu.commons.foraging.model; + +/** + * $Id$ + * + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public interface StochasticGenerator extends ResourceGenerator { + public double getProbabilityForCell(GroupDataModel group, int x, int y); + // FIXME: replace InitialFoodGenerator with initialize() method. +} \ No newline at end of file Property changes on: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/StochasticGenerator.java ___________________________________________________________________ Added: svn:keywords + Date Revision Id 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-02-20 22:55:53 UTC (rev 75) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2009-02-25 18:02:38 UTC (rev 76) @@ -646,19 +646,18 @@ transmit(new SetConfigurationEvent<RoundConfiguration>(facilitatorId, nextRoundConfiguration)); } - private boolean shouldShuffleParticipants(RoundConfiguration current, RoundConfiguration next) { + private boolean shouldShuffleParticipants(RoundConfiguration currentRoundConfiguration, RoundConfiguration nextRoundConfiguration) { // when do we _have_ to shuffle participants? - // 1. when randomize-groups is set + // 1. when randomize-groups is set for the next round // 2. when we move from a private property round to a open access round // 3. in general, when the clients per group in the current round is different from the - // clients per group in the next round..? - return next.shouldRandomizeGroup() - || (current.getClientsPerGroup() != next.getClientsPerGroup()); + // clients per group in the next round (FIXME: is this too broad or can #2 just be a special case of this?) + return nextRoundConfiguration.shouldRandomizeGroup() + || (currentRoundConfiguration.getClientsPerGroup() != nextRoundConfiguration.getClientsPerGroup()); } private void shuffleParticipants() { List<ClientData> randomizedClients = new ArrayList<ClientData>(clients.values()); - System.err.println("Shufflign participants: " + randomizedClients); Collections.shuffle(randomizedClients); // clear all existing group linkages serverDataModel.clear(); 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-02-20 22:55:53 UTC (rev 75) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-02-25 18:02:38 UTC (rev 76) @@ -33,7 +33,7 @@ import edu.asu.commons.foraging.model.Resource; import edu.asu.commons.foraging.model.ResourceDispenser; import edu.asu.commons.foraging.model.ServerDataModel; -import edu.asu.commons.foraging.model.ResourceDispenser.StochasticGenerator; +import edu.asu.commons.foraging.model.StochasticGenerator; import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Utils; Added: foraging/trunk/src/test/java/edu/asu/commons/foraging/model/ResourceDispenserTest.java =================================================================== --- foraging/trunk/src/test/java/edu/asu/commons/foraging/model/ResourceDispenserTest.java (rev 0) +++ foraging/trunk/src/test/java/edu/asu/commons/foraging/model/ResourceDispenserTest.java 2009-02-25 18:02:38 UTC (rev 76) @@ -0,0 +1,54 @@ +package edu.asu.commons.foraging.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import edu.asu.commons.foraging.conf.ServerConfiguration; +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public class ResourceDispenserTest { + + public final static int NUMBER_OF_CLIENTS = 10; + + private ResourceDispenser resourceDispenser; + private ServerConfiguration serverConfiguration; + private ServerDataModel serverDataModel; + + @Before + public void setUp() { + serverDataModel = new ServerDataModel(); + serverConfiguration = new ServerConfiguration("configuration"); + serverDataModel.setRoundConfiguration(serverConfiguration.getCurrentParameters()); + for (int i = 0; i < NUMBER_OF_CLIENTS; i++) { + ClientData clientData = new ClientData(new Identifier.Base()); + serverDataModel.addClient(clientData); + } + resourceDispenser = new ResourceDispenser(serverDataModel); + resourceDispenser.initialize(); + } + + @Test + public void testDensityDependentResourceGenerator() { + for (GroupDataModel group: serverDataModel.getGroups()) { + assertEquals(42, group.getResourceDistributionSize()); + } + + } + + @After + public void tearDown() { + + } + + + +} Property changes on: foraging/trunk/src/test/java/edu/asu/commons/foraging/model/ResourceDispenserTest.java ___________________________________________________________________ Added: svn:keywords + Date Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (V. Commons-JIRA) <all...@as...> - 2009-02-25 16:52:15
|
new features for foraging pretest --------------------------------- Key: CSAN-14 URL: https://dev.commons.asu.edu/jira/browse/CSAN-14 Project: Foraging Issue Type: New Feature Components: 2D Reporter: Allen Lee Assignee: Allen Lee Starting with the version that Rob Holahan used, we need to add the following: - with probmove a token moves to an empty neighbor cell. If there is no empty neighbor cell (8 surrounding cells) it stays within the cell. - With probbirth a token gets offspring and put it on an empty neighbor cell. If there is no empty neighbor cell no birth takes place. - An avatar can only see other avatars within radiusothers - An avatar can only see tokens within radiustokens + boolean parameters to enable/disable them. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://dev.commons.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <al...@us...> - 2009-02-20 23:22:59
|
Revision: 74 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=74&view=rev Author: alllee Date: 2009-02-20 22:44:39 +0000 (Fri, 20 Feb 2009) Log Message: ----------- fixed some issues with ivy 2.0.0, adding support for field of vision and mobile resource, still need to implement mobile resource dynamics in ResourceDispenser. Modified Paths: -------------- foraging/trunk/build.xml foraging/trunk/ivysettings.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GridView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/RoundConfigurationDialog.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml foraging/trunk/src/main/resources/configuration/round1.xml foraging/trunk/src/main/resources/configuration/round2.xml foraging/trunk/src/main/resources/configuration/round3.xml foraging/trunk/src/main/resources/configuration/round4.xml foraging/trunk/src/main/resources/configuration/round5.xml foraging/trunk/src/main/resources/configuration/round6.xml foraging/trunk/src/main/resources/configuration/server.xml Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/build.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -27,9 +27,9 @@ <!-- 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"/> - <unzip src='${ivy.jar.dir}/ivy-${ivy.install.version}-bin.zip' dest='${ivy.jar.dir}' /> - <move file='${ivy.jar.dir}/apache-ivy-${ivy.install.version}/ivy-${ivy.install.version}.jar' tofile='${ivy.jar.file}'/> - + <!-- 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"/> Modified: foraging/trunk/ivysettings.xml =================================================================== --- foraging/trunk/ivysettings.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/ivysettings.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -3,7 +3,7 @@ vim:sts=2:sw=2: --> <ivysettings> - <settings defaultResolver="chain-resolver" checkUpToDate="false"/> + <settings defaultResolver="chain-resolver" /> <property name='local-m2-pattern' value='${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision]'/> <resolvers> @@ -14,10 +14,6 @@ </filesystem> <ibiblio name='commons-archiva' m2compatible='true' root='http://dev.commons.asu.edu/archiva/repository/internal'/> <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> - <filesystem name="local"> - <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> - <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> - </filesystem> </chain> </resolvers> </ivysettings> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ClientDataModel.java 2009-02-20 22:44:39 UTC (rev 74) @@ -191,7 +191,7 @@ } public Point getCurrentPosition() { - return groupDataModel.getClientPosition(getId()); + return getClientData().getPosition(); } public int getCurrentTokens() { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java 2009-02-20 22:44:39 UTC (rev 74) @@ -133,7 +133,6 @@ if (dataModel.is2dExperiment()) { panel.add(gameWindow2D, BorderLayout.CENTER); if (gameWindow3D != null) { - panel.remove(gameWindow3D.getPanel()); gameWindow3D.dispose(); } } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow3D.java 2009-02-20 22:44:39 UTC (rev 74) @@ -24,7 +24,6 @@ * @version $Revision$ */ -@SuppressWarnings("serial") public class GameWindow3D implements GameWindow { private ForagingClient client; Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GridView.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GridView.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GridView.java 2009-02-20 22:44:39 UTC (rev 74) @@ -24,6 +24,7 @@ * * Superclass for experimenter and subject views of the simulation world. */ +@SuppressWarnings("serial") public abstract class GridView extends JPanel { /** @@ -152,6 +153,8 @@ // this super call to let the UI delegate some paintage as well. // super.paintComponent(graphics); Graphics2D graphics2D = (Graphics2D) graphics; + // FIXME: can be made more efficient. + // Could just update the parts that have changed (tokens removed, subjects moved) // paint the background paintBackground(graphics2D); // render the food particles in my mouth and on my shirt @@ -160,22 +163,32 @@ paintSubjects(graphics2D); } - protected void paintCollection(Collection<Point> collection, - Graphics2D graphics2D, Image image) { - paintCollection(collection, graphics2D, image, null); + protected void paintCollection(Collection<Point> collection, Graphics2D graphics2D, Image image) { + paintCollection(collection, graphics2D, image, this); } - protected void paintCollection(Collection<Point> collection, - Graphics2D graphics2D, Image image, ImageObserver observer) { + protected void paintCollection(Collection<Point> collection, Graphics2D graphics2D, Image image, ImageObserver observer) { synchronized (collection) { for (Point point: collection) { int x = scaleX(point.getX()); int y = scaleY(point.getY()); - graphics2D.drawImage(image, x, y, observer); + graphics2D.drawImage(image, x, y, observer); } } } + protected void paintCollection(Collection<Point> collection, Graphics2D graphics2D, Image image, ImageObserver observer, Circle fieldOfView) { + synchronized (collection) { + for (Point point: collection) { + if (fieldOfView.contains(point)) { + int x = scaleX(point.getX()); + int y = scaleY(point.getY()); + graphics2D.drawImage(image, x, y, observer); + } + } + } + } + protected int getCellWidth() { return (int) dw; } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/SubjectView.java 2009-02-20 22:44:39 UTC (rev 74) @@ -57,13 +57,21 @@ protected void paintTokens(Graphics2D graphics2D) { // three cases - show all food on the game board, show all food within // visible radius of the current player, or don't show any food. - paintCollection(dataModel.getResourcePositions(), graphics2D, scaledTokenImage); + if (dataModel.getRoundConfiguration().isTokensFieldOfVisionEnabled()) { + Point location = dataModel.getCurrentPosition(); + Circle viewTokensField = new Circle(location, dataModel.getRoundConfiguration().getViewTokensRadius()); + paintCollection(dataModel.getResourcePositions(), graphics2D, scaledTokenImage, this, viewTokensField); + } + else { + paintCollection(dataModel.getResourcePositions(), graphics2D, scaledTokenImage); + } // display animation for food that has been eaten. long elapsedTime = 0; int width = (int) dw; int height = (int) dh; int offset = 1; // paint residual tokens that you've consumed. + synchronized (collectedTokens) { for (Iterator<Map.Entry<Point, Duration>> iter = collectedTokens.entrySet().iterator(); iter.hasNext();) { Map.Entry<Point, Duration> entry = iter.next(); @@ -100,10 +108,18 @@ graphics2D.setFont(font); FontMetrics fontMetrics = graphics2D.getFontMetrics(font); int characterHeight = fontMetrics.getAscent(); - int verticalCharacterSpacing = (int) ( (dh - characterHeight) / 2); + int verticalCharacterSpacing = (int) ( (dh - characterHeight) / 2); + Circle fieldOfVision = null; + if (dataModel.getRoundConfiguration().isSubjectFieldOfVisionEnabled()) { + fieldOfVision = new Circle(dataModel.getCurrentPosition(), dataModel.getRoundConfiguration().getViewSubjectsRadius()); + } for (Map.Entry<Identifier, ClientData> entry : positions.entrySet()) { Identifier id = entry.getKey(); Point subjectLocation = entry.getValue().getPosition(); + if (fieldOfVision != null && ! fieldOfVision.contains(subjectLocation)) { + // the other participant is outside of this subject's field of vision. + continue; + } int scaledX = scaleX(subjectLocation.x); int scaledY = scaleY(subjectLocation.y); drawParticipant( graphics2D, id, scaledX, scaledY ); @@ -132,12 +148,12 @@ if (dataModel.isBeingSanctioned(id)) { graphics2D.setColor(Color.CYAN); graphics2D.fillRect(x, y, getCellWidth(), getCellHeight()); - graphics2D.drawImage(scaledBeingSanctionedImage, x, y, null); + graphics2D.drawImage(scaledBeingSanctionedImage, x, y, this); } else if (dataModel.isSanctioning(id)) { graphics2D.setColor(Color.WHITE); graphics2D.fillRect(x, y, getCellWidth(), getCellHeight()); - graphics2D.drawImage(scaledSanctioningImage, x, y, null); + graphics2D.drawImage(scaledSanctioningImage, x, y, this); } else if (id.equals(dataModel.getId())) { // self image @@ -145,11 +161,11 @@ graphics2D.drawImage(scaledSelfExplicitCollectionModeImage, x, y, null); } else { - graphics2D.drawImage(scaledSelfImage, x, y, null); + graphics2D.drawImage(scaledSelfImage, x, y, this); } } else { - graphics2D.drawImage(scaledOtherSubjectImage, x, y, null); + graphics2D.drawImage(scaledOtherSubjectImage, x, y, this); } } 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-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java 2009-02-20 22:44:39 UTC (rev 74) @@ -13,13 +13,16 @@ private final static long serialVersionUID = 8575239803733029326L; - public final static double DEFAULT_REGROWTH_SCALING_FACTOR = 0.01; + public final static double DEFAULT_REGROWTH_RATE = 0.01; public final static int DEFAULT_ROUND_TIME = 5 * 60; private static final int DEFAULT_SANCTION_FLASH_DURATION = 3; private static final double DEFAULT_DOLLARS_PER_TOKEN = .02d; + + private static final double DEFAULT_TOKEN_MOVEMENT_PROBABILITY = 0.02d; + private final static Map<String, SanctionType> sanctionTypeMap = new HashMap<String, SanctionType>(3); public enum SanctionType { @@ -40,6 +43,7 @@ } private final static Map<String, ExperimentType> experimentTypeMap = new HashMap<String, ExperimentType>(3); + public enum ExperimentType { TWO_DIMENSIONAL("2d"), ABSTRACT("abstract"), FORESTRY("forestry"); private final String name; @@ -84,9 +88,44 @@ public int getSanctionFlashDuration() { return getIntProperty("sanction-flash-duration", DEFAULT_SANCTION_FLASH_DURATION); } + + public double getTokenMovementProbability() { + return getDoubleProperty("token-movement-probability", DEFAULT_TOKEN_MOVEMENT_PROBABILITY); + } + + public boolean isMobileResource() { + return getBooleanProperty("mobile-resource", false); + } + + public boolean isTokensFieldOfVisionEnabled() { + return getBooleanProperty("tokens-field-of-vision", false); + } + + public boolean isSubjectFieldOfVisionEnabled() { + return getBooleanProperty("subject-field-of-vision", false); + } + + public double getViewSubjectsRadius() { + if (isSubjectFieldOfVisionEnabled()) { + return getDoubleProperty("view-subjects-radius"); + } + throw new UnsupportedOperationException("subject field of vision is not enabled."); + } + + public double getViewTokensRadius() { + if (isTokensFieldOfVisionEnabled()) { + return getDoubleProperty("view-tokens-radius"); + } + throw new UnsupportedOperationException("view tokens field of vision is not enabled."); + } - public double getRegrowthScalingFactor() { - return getDoubleProperty("regrowth-rate", DEFAULT_REGROWTH_SCALING_FACTOR); + /** + * Returns a double between [0, 1] used as a scaling factor modifying the probability + * that a token grows in a neighboring cell. + * @return + */ + public double getRegrowthRate() { + return getDoubleProperty("regrowth-rate", DEFAULT_REGROWTH_RATE); } public double getInitialDistribution() { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/RoundConfigurationDialog.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/RoundConfigurationDialog.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/facilitator/RoundConfigurationDialog.java 2009-02-20 22:44:39 UTC (rev 74) @@ -154,7 +154,7 @@ } public JTextField getFoodRate() { if (foodRate == null) { - foodRate = new JTextField(roundConfiguration.getRegrowthScalingFactor() + ""); + foodRate = new JTextField(roundConfiguration.getRegrowthRate() + ""); foodRate.setEditable(!readOnly); } return foodRate; Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/ResourceDispenser.java 2009-02-20 22:44:39 UTC (rev 74) @@ -58,7 +58,7 @@ patchyGrowthGenerator.initialize(configuration); } else { - setRate(configuration.getRegrowthScalingFactor()); + setRate(configuration.getRegrowthRate()); generateResources(initialResourceGenerator.setInitialDistribution(configuration.getInitialDistribution())); Resource.setConfiguration(configuration); } @@ -251,8 +251,6 @@ } } serverDataModel.addResources(group, newResources); - // XXX: this will get rid of all the resources in the serialized data as well..! -// newResources.clear(); } } 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-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-02-20 22:44:39 UTC (rev 74) @@ -105,6 +105,7 @@ resourceCountMap.put(groupDataModel, resources - 1); } } + System.err.println("resource count map should be all zeroed out: " + resourceCountMap); // tally their very last movement counts // (since ClientMovementStatistics only adds to the movement distribution when they change direction) for (ClientMovementStatistics summary: clientStatisticsMap.values()) { Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>Foraging XML-ized experiment round configuration</comment> +<comment>Foraging XML experiment round configuration</comment> <entry key="resource-width">13</entry> <entry key="resource-depth">13</entry> <entry key="practice-round">true</entry> Modified: foraging/trunk/src/main/resources/configuration/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round1.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/round1.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -14,16 +14,40 @@ <entry key="initial-distribution">.25</entry> <entry key="regrowth-rate">0.01</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> +<entry key="chat-duration">240</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and clicking the "send" button with your mouse or +pressing the "enter" key on your keyboard. </p> +]]> +</entry> + + <entry key="instructions"> <![CDATA[ <h3>Round 1 Instructions</h3> <hr> <p> This is the first round of the experiment. The length of the round is 4 -minutes. Like in the practice round you can collect green tokens. This time -you earn <b>two cents</b> for each token collected. This time you -<b>cannot</b> reset the distribution of green tokens. +minutes. As in the practice round you can collect green tokens but there are +two important differences. You will earn <b>two cents</b> for each token +collected and you <b>cannot reset</b> the distribution of green tokens. </p> <p> In this round the renewable resource will become five times bigger. You @@ -40,6 +64,14 @@ how many tokens each player has collected. </p> <p> +Before the next round starts you can anonymously communicate via text messages +for four minutes with the other participants in your group. You can use this +opportunity to discuss the experiment and coordinate your actions to improve +your earnings. You may not promise them side-payments after the experiment is +completed or make any threats. You are also not allowed to reveal your real +identity. We will be monitoring the chat traffic while you chat. +</p> +<p> If you have any questions please raise your hand. <b>Do you have any questions so far?</b> </p> Modified: foraging/trunk/src/main/resources/configuration/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round2.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/round2.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -13,7 +13,30 @@ <entry key="initial-distribution">.25</entry> <entry key="regrowth-rate">0.01</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> +<entry key="chat-duration">240</entry> +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and clicking the "send" button with your mouse or +pressing the "enter" key on your keyboard. </p> +]]> +</entry> + <entry key="instructions"> <![CDATA[ <h3>Round 2 Instructions</h3> Modified: foraging/trunk/src/main/resources/configuration/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round3.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/round3.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -15,6 +15,30 @@ <entry key="initial-distribution">.25</entry> <entry key="regrowth-rate">0.01</entry> +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> +<entry key="chat-duration">240</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and clicking the "send" button with your mouse or +pressing the "enter" key on your keyboard. </p> +]]> +</entry> + <!-- <entry key="patchy">true</entry> <entry key="top-initial-distribution">0.50</entry> Modified: foraging/trunk/src/main/resources/configuration/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round4.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/round4.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -11,10 +11,6 @@ <entry key='always-explicit'>true</entry> <entry key='max-cell-occupancy'>1</entry> -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> -<entry key="chat-duration">240</entry> - <entry key="initial-distribution">.25</entry> <entry key="regrowth-rate">0.01</entry> @@ -23,17 +19,10 @@ <h3>Round 4 Instructions</h3> <hr> <p> -Round 4 is the same as the previous two rounds with one exception. +Round 4 is the same as the previous rounds with one exception - you will not +be able to anonymously communicate with the other participants in your group. </p> <p> -Before the next round starts you can anonymously communicate by text messages -for four minutes with the other participants in your group. You can use this -opportunity to discuss the experiment and coordinate your actions to improve -your earnings. You may not promise them side-payments after the experiment is -completed or make any threats. You are also not allowed to reveal your real -identity. We are monitoring the chat traffic while you chat. -</p> -<p> The length of this round is four minutes. </p> <p> @@ -43,26 +32,4 @@ ]]> </entry> -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we see that somebody reveals his or her identity, we have to stop the -experiment and remove the whole group from which this person is a member out -of this room. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and clicking the "send" button with your mouse or -pressing the "enter" key on your keyboard. -</p> -]]> -</entry> - </properties> Modified: foraging/trunk/src/main/resources/configuration/round5.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round5.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/round5.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -14,10 +14,6 @@ <entry key='always-explicit'>true</entry> <entry key='max-cell-occupancy'>1</entry> -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> -<entry key="chat-duration">240</entry> - <entry key="instructions"> <![CDATA[ <h3>Round 5 Instructions</h3> @@ -34,35 +30,4 @@ ]]> </entry> -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we see that somebody reveals his or her identity, we have to stop the -experiment and remove the whole group from which this person is a member out -of this room. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and clicking the "send" button with your mouse or -pressing the "enter" key on your keyboard. -</p> -]]> -</entry> - -<entry key='private-chat-instructions'> -<![CDATA[ -You may send private messages to a specific participant by clicking on the -appropriately labeled button (1, 2, 3, 4, or 5) before typing your message in -the chat box and sending it. By default you are communicating with all -members of your group. -]]> -</entry> - </properties> Modified: foraging/trunk/src/main/resources/configuration/round6.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round6.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/round6.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -14,10 +14,6 @@ <entry key='always-explicit'>true</entry> <entry key='max-cell-occupancy'>1</entry> -<!-- before this round begins, we have a chat session --> -<entry key="chat-enabled">true</entry> -<entry key="chat-duration">240</entry> - <entry key="instructions"> <![CDATA[ <h3>Round 6 Instructions</h3> @@ -53,23 +49,4 @@ ]]> </entry> -<entry key="chat-instructions"> -<![CDATA[ -<p> -You can now chat with the other participants in your group for 4 minutes -total. During the chat round, you may communicate about any aspect of the -experiment that you would like to discuss with other participants with whom -you have been matched. You may not promise them side-payments after the -experiment is completed or threaten them with any consequence after the -experiment is finished. We are monitoring the chat traffic while you chat. If -we detect that somebody has revealed their identity, we will have to stop the -experiment and remove that person's entire group from the experiment. -</p> -<p> -You will see other participants labeled as "1", "2","3", "4", or "5" in the -chat box. You can send a chat message by typing into the textfield at the -bottom of the screen and clicking the "send" button with your mouse or -pressing the "enter" key on your keyboard. </p> -]]> -</entry> </properties> Modified: foraging/trunk/src/main/resources/configuration/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/server.xml 2009-02-17 21:49:41 UTC (rev 73) +++ foraging/trunk/src/main/resources/configuration/server.xml 2009-02-20 22:44:39 UTC (rev 74) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>Foraging XML experiment server configuration</comment> +<comment>Foraging XML experiment round configuration</comment> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-02-20 23:22:24
|
Revision: 75 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=75&view=rev Author: alllee Date: 2009-02-20 22:55:53 +0000 (Fri, 20 Feb 2009) Log Message: ----------- simple circle class for testing whether a point resides inside or outside the circle Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java 2009-02-20 22:55:53 UTC (rev 75) @@ -0,0 +1,36 @@ +package edu.asu.commons.foraging.client; + +import java.awt.Point; + +/** + * $Id$ + * + * Simple Circle class given a Point center and radius and providing methods to detect + * if a point is within the circle. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public class Circle { + + private Point center; + private final double radius; + + public Circle(Point center, double radius) { + this.center = center; + this.radius = radius; + } + + public boolean contains(Point point) { + if (point == null) { + throw new IllegalArgumentException("Null point passed to Circle.contains()"); + } + return center.distance(point) <= radius; + } + + public void setCenter(Point center) { + this.center = center; + } + + +} Property changes on: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/Circle.java ___________________________________________________________________ Added: svn:keywords + Date Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-02-17 23:22:42
|
Revision: 73 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=73&view=rev Author: alllee Date: 2009-02-17 21:49:41 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Adding dev.commons archiva repository, seems to be more robust outside the ASU network, need to check with UTO about why dev.tdar.org archiva seems to hang downloads outside the network. Updating ivy to 2.0 and now downloading the entire ivy distribution since ivy.jar seems to only be available for 2.0.0-beta1 Modified Paths: -------------- foraging/trunk/build.xml foraging/trunk/ivysettings.xml foraging/trunk/pom.xml Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2009-01-28 21:09:57 UTC (rev 72) +++ foraging/trunk/build.xml 2009-02-17 21:49:41 UTC (rev 73) @@ -13,7 +13,7 @@ uri='antlib:org.apache.ivy.ant' classpathref='ivy.lib.path'/> --> - <property name="ivy.install.version" value="2.0.0-beta1" /> + <property name="ivy.install.version" value="2.0.0" /> <condition property="ivy.home" value="${env.IVY_HOME}"> <isset property="env.IVY_HOME" /> </condition> @@ -23,10 +23,17 @@ <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 --> + <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"/> + <unzip src='${ivy.jar.dir}/ivy-${ivy.install.version}-bin.zip' dest='${ivy.jar.dir}' /> + <move file='${ivy.jar.dir}/apache-ivy-${ivy.install.version}/ivy-${ivy.install.version}.jar' tofile='${ivy.jar.file}'/> + + <!-- <get src="http://www.apache.org/dist/ant/ivy/${ivy.install.version}/ivy.jar" dest="${ivy.jar.file}" usetimestamp="true"/> + --> </target> <target name="init-ivy" depends="download-ivy"> Modified: foraging/trunk/ivysettings.xml =================================================================== --- foraging/trunk/ivysettings.xml 2009-01-28 21:09:57 UTC (rev 72) +++ foraging/trunk/ivysettings.xml 2009-02-17 21:49:41 UTC (rev 73) @@ -12,6 +12,7 @@ <ivy pattern='${local-m2-pattern}.pom' /> <artifact pattern='${local-m2-pattern}.[ext]'/> </filesystem> + <ibiblio name='commons-archiva' m2compatible='true' root='http://dev.commons.asu.edu/archiva/repository/internal'/> <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> <filesystem name="local"> <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2009-01-28 21:09:57 UTC (rev 72) +++ foraging/trunk/pom.xml 2009-02-17 21:49:41 UTC (rev 73) @@ -13,6 +13,11 @@ <url>http://commons.asu.edu/foraging</url> <repositories> <repository> + <id>dev.commons.asu.edu</id> + <name>dev.commons Maven2 repository</name> + <url>http://dev.commons.asu.edu/archiva/repository/internal</url> + </repository> + <repository> <id>dev.tdar.org</id> <name>tDAR Maven2 repository</name> <url>http://dev.tdar.org/archiva/repository/internal</url> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2009-01-28 21:10:02
|
Revision: 72 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=72&view=rev Author: alllee Date: 2009-01-28 21:09:57 +0000 (Wed, 28 Jan 2009) Log Message: ----------- ensuring that a save file processor's resultant output file gets closed properly, minor version bumps in pom and letting ivy look at the ~/.m2 local maven cache before searching for resources online. Modified Paths: -------------- csidex/trunk/ivysettings.xml csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java csidex/trunk/src/main/java/edu/asu/commons/util/ResourceLoader.java csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java Modified: csidex/trunk/ivysettings.xml =================================================================== --- csidex/trunk/ivysettings.xml 2009-01-02 23:06:31 UTC (rev 71) +++ csidex/trunk/ivysettings.xml 2009-01-28 21:09:57 UTC (rev 72) @@ -3,12 +3,14 @@ vim:sts=2:sw=2: --> <ivysettings> - <settings defaultResolver="tdar-archiva" checkUpToDate="false"/> + <settings defaultResolver="chain-resolver" checkUpToDate="false"/> <resolvers> - <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> - <filesystem name="internal"> - <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> - <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> - </filesystem> + <chain name='chain-resolver' returnFirst='true'> + <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> + <filesystem name="internal"> + <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> + <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> + </filesystem> + </chain> </resolvers> </ivysettings> Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2009-01-02 23:06:31 UTC (rev 71) +++ csidex/trunk/pom.xml 2009-01-28 21:09:57 UTC (rev 72) @@ -6,15 +6,33 @@ <modelVersion>4.0.0</modelVersion> <groupId>edu.asu.commons</groupId> <artifactId>csidex</artifactId> + <packaging>jar</packaging> + <version>0.2-SNAPSHOT</version> + <name>csidex</name> + <url>http://commons.asu.edu/software/csidex</url> + <description>The csidex experimental framework is utilized in + several concrete experiments developed by the Virtual Commons, namely the + foraging and irrigation experiments. + </description> + <licenses> + <license> + <name>GNU General Public License, Version 3.0</name> + <url>http://www.gnu.org/copyleft/gpl.html</url> + <distribution>repo</distribution> + </license> + </licenses> + <scm> + <url>https://virtualcommons.svn.sourceforge.net/svnroot/virtualcommons/csidex</url> + </scm> <repositories> <repository> <id>dev.tdar.org</id> - <name>tDAR Maven2 repository</name> + <name>tDAR Maven2 archiva repo</name> <url>http://dev.tdar.org/archiva/repository/internal</url> </repository> <repository> <id>csid.asu.edu</id> - <name>CSID Maven2 repository</name> + <name>CSID Maven2 archiva repo</name> <url>http://csid.asu.edu/archiva/repository/internal</url> </repository> <repository> @@ -24,15 +42,11 @@ <layout>default</layout> </repository> </repositories> - <packaging>jar</packaging> - <version>0.2-SNAPSHOT</version> - <name>csidex</name> - <url>http://commons.asu.edu/software/csidex</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.4</version> + <version>4.5</version> <scope>test</scope> </dependency> <dependency> @@ -52,8 +66,8 @@ <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> </configuration> </plugin> </plugins> Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2009-01-02 23:06:31 UTC (rev 71) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java 2009-01-28 21:09:57 UTC (rev 72) @@ -45,8 +45,9 @@ public void process(SavedRoundData savedRoundData, String roundSaveFile) { this.roundSaveFile = roundSaveFile; + FileOutputStream defaultFileOutputStream = null; try { - FileOutputStream defaultFileOutputStream = new FileOutputStream( getOutputFileName() ); + defaultFileOutputStream = new FileOutputStream( getOutputFileName() ); process(savedRoundData, defaultFileOutputStream); } catch (IOException e) { @@ -55,6 +56,15 @@ } finally { dispose(); + if (defaultFileOutputStream != null) { + try { + defaultFileOutputStream.close(); + } + catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } } } @@ -68,7 +78,7 @@ } /** - * + * Returns a unique output file name for this save file processor. */ public String getOutputFileName() { return roundSaveFile.concat( getOutputFileExtension() ); Modified: csidex/trunk/src/main/java/edu/asu/commons/util/ResourceLoader.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/util/ResourceLoader.java 2009-01-02 23:06:31 UTC (rev 71) +++ csidex/trunk/src/main/java/edu/asu/commons/util/ResourceLoader.java 2009-01-28 21:09:57 UTC (rev 72) @@ -12,6 +12,12 @@ import java.net.URL; import java.security.AccessControlException; +/** + * $Id$ + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ public class ResourceLoader { public static String getString(String path) { Modified: csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2009-01-02 23:06:31 UTC (rev 71) +++ csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2009-01-28 21:09:57 UTC (rev 72) @@ -148,6 +148,18 @@ } return builder.toString(); } + + public static List<Integer> iota(int end) { + return iota(0, end); + } + + public static List<Integer> iota(int start, int end) { + List<Integer> list = new ArrayList<Integer>(); + for (int i = start; i < end; i++) { + list.add(Integer.valueOf(i)); + } + return list; + } public static <T, R> List<R> map(Collection<T> in, MapOp<T, R> op) { List<R> out = new ArrayList<R>(in.size()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (V. Commons-JIRA) <all...@as...> - 2009-01-09 22:58:17
|
migrate participant database to struts 2 ---------------------------------------- Key: VC-4 URL: https://dev.commons.asu.edu/jira/browse/VC-4 Project: Virtual Commons Issue Type: Improvement Components: participant database Reporter: Allen Lee Assignee: Allen Lee Priority: Minor Migrate participant database to Struts 2 when free time magically appears. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://dev.commons.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <al...@us...> - 2009-01-02 23:06:36
|
Revision: 71 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=71&view=rev Author: alllee Date: 2009-01-02 23:06:31 +0000 (Fri, 02 Jan 2009) Log Message: ----------- adding movement statistics processor to save file conversion to generate movement distribution (distribution of how often player X moves in the same direction) Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 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 2008-12-20 00:01:02 UTC (rev 70) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/GroupDataModel.java 2009-01-02 23:06:31 UTC (rev 71) @@ -44,8 +44,8 @@ private final Map<Point, Resource> resourceDistribution = new HashMap<Point, Resource>(); private final transient Map<Identifier, Resource> resourceOwners = new HashMap<Identifier, Resource>(); - private final transient Set<Resource> removedResources; - private final transient Set<Resource> addedResources; + private transient Set<Resource> removedResources; + private transient Set<Resource> addedResources; private transient ServerDataModel serverDataModel; @@ -92,7 +92,7 @@ for (ClientData clientState : clients.values()) { clientState.reset(); } - removedResources.addAll(resourceDistribution.values()); + getRemovedResources().addAll(resourceDistribution.values()); addedResources.clear(); resourceDistribution.clear(); } @@ -116,14 +116,14 @@ public void addResource(Resource resource) { Point position = resource.getPosition(); resourceDistribution.put(position, resource); - addedResources.add(resource); + getAddedResources().add(resource); } public void addResources(Set<Resource> resources) { for (Resource resource: resources) { Point position = resource.getPosition(); resourceDistribution.put(position, resource); - addedResources.add(resource); + getAddedResources().add(resource); } } @@ -232,7 +232,7 @@ public void collectToken(ClientData clientData) { Point position = clientData.getPoint(); if (resourceDistribution.containsKey(position)) { - removedResources.add( resourceDistribution.remove(position) ); + getRemovedResources().add( resourceDistribution.remove(position) ); clientData.addToken(); serverDataModel.getEventChannel().handle(new TokenCollectedEvent(clientData.getId(), position)); } @@ -309,12 +309,11 @@ ClientData clientData = clients.get(id); clientData.addTokens( getRoundConfiguration().calculateTokens(resource.getAge()) ); Point position = resource.getPosition(); - removedResources.add(resourceDistribution.remove(position)); + getRemovedResources().add(resourceDistribution.remove(position)); resourceOwners.remove(id); } } - //TODO: Add # tokens and/or dollars per token for fruits public void harvestFruits(Identifier id, Resource resource) { if ( isResourceOwner(id, resource) ) { ClientData clientData = clients.get(id); @@ -414,10 +413,16 @@ public Set<Resource> getRemovedResources() { + if (removedResources == null) { + removedResources = new HashSet<Resource>(); + } return removedResources; } public Set<Resource> getAddedResources() { + if (addedResources == null) { + addedResources = new HashSet<Resource>(); + } return addedResources; } 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 2008-12-20 00:01:02 UTC (rev 70) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2009-01-02 23:06:31 UTC (rev 71) @@ -7,6 +7,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -27,6 +28,7 @@ import edu.asu.commons.foraging.event.ResourcesAddedEvent; import edu.asu.commons.foraging.event.TokenCollectedEvent; import edu.asu.commons.foraging.model.ClientData; +import edu.asu.commons.foraging.model.Direction; import edu.asu.commons.foraging.model.GroupDataModel; import edu.asu.commons.foraging.model.Resource; import edu.asu.commons.foraging.model.ResourceDispenser; @@ -45,7 +47,8 @@ processors.addAll(Arrays.asList( new AllDataProcessor(), new AggregateTimeIntervalProcessor(), - new SummaryProcessor())); + new SummaryProcessor(), + new MovementStatisticsProcessor())); Persister.processSaveFiles(allSaveFilesDirectory, processors); return true; } @@ -60,6 +63,137 @@ convert(args[0]); } + 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(); + for (GroupDataModel group: serverDataModel.getGroups()) { + for (Identifier id: group.getOrderedClientIdentifiers()) { + clientStatisticsMap.put(id, new ClientMovementStatistics(id, (RoundConfiguration) savedRoundData.getRoundParameters())); + } + resourceCountMap.put(group, 0); + } + + for (PersistableEvent event: savedRoundData.getActions()) { + if (event instanceof MovementEvent) { + MovementEvent movementEvent = (MovementEvent) event; + Identifier id = movementEvent.getId(); + GroupDataModel groupDataModel = serverDataModel.getGroup(id); + if (resourceCountMap.get(groupDataModel) > 0) { + clientStatisticsMap.get(id).move(movementEvent.getDirection()); + } + else { + // stop counting for this group. +// System.err.println("Ignoring movement due to 0 resource count " + movementEvent + resourceCountMap); + } + } + else if (event instanceof ResourcesAddedEvent) { + ResourcesAddedEvent resourcesAddedEvent = (ResourcesAddedEvent) event; + GroupDataModel group = resourcesAddedEvent.getGroup(); + int resources = resourceCountMap.get(group); + resources += resourcesAddedEvent.getResources().size(); + resourceCountMap.put(group, resources); + } + else if (event instanceof TokenCollectedEvent) { + TokenCollectedEvent tokenCollectedEvent = (TokenCollectedEvent) event; + Identifier id = tokenCollectedEvent.getId(); + GroupDataModel groupDataModel = serverDataModel.getGroup(id); + int resources = resourceCountMap.get(groupDataModel); + resourceCountMap.put(groupDataModel, resources - 1); + } + } + // tally their very last movement counts + // (since ClientMovementStatistics only adds to the movement distribution when they change direction) + for (ClientMovementStatistics summary: clientStatisticsMap.values()) { + summary.incrementMovementDistribution(); + } + int maximumMoves = Math.max(serverDataModel.getBoardHeight(), serverDataModel.getBoardWidth()); + final Integer[] movementHeader = new Integer[maximumMoves]; + for (int iotaIndex = 0; iotaIndex < maximumMoves; iotaIndex++) { + movementHeader[iotaIndex] = iotaIndex + 1; + } + + // 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(',', + Arrays.asList(entry.getValue().getMovementDistribution())))); + } + } + + @Override + public String getOutputFileExtension() { + return "-movement-summary-statistics.txt"; + } + + @Override + public void dispose() { + clientStatisticsMap.clear(); + resourceCountMap.clear(); + } + + } + + private static class ClientMovementStatistics { + private final Identifier id; + private Direction lastDirection; + // distribution of moves, each entry in the array represents the number of times they've moved. + 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]; + } + public synchronized void move(Direction direction) { + if (direction != null) { + allMoves++; + } + if (lastDirection == null) { + lastDirection = direction; + currentMoveCount = 1; + } + else if (lastDirection.equals(direction)) { + currentMoveCount++; + } + else { + lastDirection = direction; + 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++) { + sum += ((i+1) * movementDistribution[i]); + } + if (allMoves != sum) { + throw new RuntimeException("Identifier id: " + id + " -- allMoves: " + allMoves + " not equal to sum of all moves: " + sum); + } + } + + } + private static class SummaryProcessor extends SaveFileProcessor.Base { @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { @@ -319,11 +453,11 @@ // accumulated stats if (secondsElapsed >= endOfInterval) { // generate group expected token counts -// List<Double> expectedTokenProbabilities = getExpectedTokenProbabilities(gameState); + List<Double> expectedTokenProbabilities = getExpectedTokenProbabilities(serverDataModel); // report summary stats and reset List<Integer> movesTaken = new ArrayList<Integer>(); List<Integer> harvestedTokens = new ArrayList<Integer>(); -// List<Integer> tokensLeft = getTokensLeft(groups); + List<Integer> tokensLeft = getTokensLeft(groups); List<Double> distances = getClientDistances(groups); for (Identifier id : orderedIdentifiers) { ClientStats stats = clientStatistics.get(id); @@ -335,9 +469,10 @@ Utils.join(',', endOfInterval, Utils.join(',', movesTaken), Utils.join(',', harvestedTokens), + Utils.join(',', expectedTokenProbabilities), + Utils.join(',', tokensLeft), Utils.join(',', distances) ); -// System.err.println("dataline: " + dataline); writer.println(dataline); currentInterval++; } @@ -369,18 +504,16 @@ stats.tokens += roundConfiguration.calculateTokens(request.getResource().getAge()); } else if (event instanceof ResourceAddedEvent) { -// ResourceAddedEvent resourceAddedEvent = (ResourceAddedEvent) event; -// assert serverDataModel.getGroups().contains(resourceAddedEvent.getGroup()); -// resourceAddedEvent.getGroup().addResource(resourceAddedEvent.getPosition()); + ResourceAddedEvent resourceAddedEvent = (ResourceAddedEvent) event; + assert serverDataModel.getGroups().contains(resourceAddedEvent.getGroup()); + resourceAddedEvent.getGroup().addResource(resourceAddedEvent.getPosition()); } else if (event instanceof ResourcesAddedEvent) { -// ResourcesAddedEvent resourcesAddedEvent = (ResourcesAddedEvent) event; -// assert serverDataModel.getGroups().contains(resourcesAddedEvent.getGroup()); -// resourcesAddedEvent.getGroup().addResources(resourcesAddedEvent.getResources()); + ResourcesAddedEvent resourcesAddedEvent = (ResourcesAddedEvent) event; + assert serverDataModel.getGroups().contains(resourcesAddedEvent.getGroup()); + resourcesAddedEvent.getGroup().addResources(resourcesAddedEvent.getResources()); } } - writer.flush(); - writer.close(); } private List<Double> getClientDistances(List<GroupDataModel> groups) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |