Commit 42f1e99c authored by Gaurav Arora (gaa721)'s avatar Gaurav Arora (gaa721)
Browse files

Indentation and date fix

parent 24cde7e2
......@@ -25,8 +25,8 @@ class Box {
// Add the box to the box2d world
makeBody(new Vec2(x, y), w, h);
}
Box(float x, float y,float w,float h) {
Box(float x, float y, float w, float h) {
// w = random(4, 16);
// h = random(4, 16);
this.w=w;
......@@ -38,8 +38,8 @@ class Box {
// Add the box to the box2d world
makeBody(new Vec2(x, y), w, h);
}
// This function removes the particle from the box2d world
void killBody() {
......@@ -111,13 +111,12 @@ class Box {
body.applyForce(v, body.getWorldCenter());
//body.setLinearVelocity(v);
}
boolean contains(float x, float y) {
boolean contains(float x, float y) {
Vec2 worldPoint = box2d.coordPixelsToWorld(x, y);
Fixture f = body.getFixtureList();
boolean inside = f.testPoint(worldPoint);
return inside;
}
}
......@@ -62,22 +62,21 @@ class Person {
noStroke();
translate(a.x, a.y);
rotate(-a.angle);
if(i%4==0)
rect(0, 0, 20, 20);
if (i%4==0)
rect(0, 0, 20, 20);
popMatrix();
}
if (a.seen)
{
rpoints.add(a);
rpoints.add(a);
}
}
this.points.removeAll(rpoints);
}
......
......@@ -9,19 +9,19 @@ class Question implements Serializable
String tAnswer;
public Question(String type ,String quest, Rectangle ans)
public Question(String type, String quest, Rectangle ans)
{
this.type = type;
this.question = quest;
this.answer = ans;
}
public Question( String type,String quest)
public Question( String type, String quest)
{
this.type = type;
this.question = quest;
}
public Question(String type ,String quest, String ans)
public Question(String type, String quest, String ans)
{
this.type = type;
this.question = quest;
......
......@@ -20,7 +20,8 @@ public class Rectangle implements Serializable {
}
public String show() {
return x + " , " + y ; }
return x + " , " + y ;
}
public boolean isEqual(Point p) {
return this.x == p.x && this.y == p.y;
......@@ -156,6 +157,4 @@ public class Rectangle implements Serializable {
......@@ -66,7 +66,11 @@ void setup()
box2d = new Box2DProcessing(this);
box2d.createWorld();
boundaries = new ArrayList<Boundary>();
background(255);
setupInside();
textSize(20);
fill(0);
text("Welcome to the Attention Study.\n In this part of the study There would be tanks bouncing and moving on the screen and then after sometime there will be a black screen. Black screen would mean that you are not attentive at that time. After the black Screen there would be Questions asking what do you think happened when you were not attentive that is when where was a black screen. Press Enter when you want to start.", width/2-150, height/2-150, 400, 400);
// boundaries.add(new Boundary(3*width/4,height-50,width/2-50,10,0));
events = " ddddddddddddddaass asdawd aaaaaaaaawdawdaaaaaaadddddddaass aaaaaaaaaaaaaaaaaaadddddddaass aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddwwwwwwwwwwwwwwwwwwwwwwwwwwwaaaaaaaaaaaaaaaaaadddddddwaaaaaaaaaaaaaaaaaaaaaawwwwwwwwwwwwwwwwwwwwwdddddddddddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddda aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaa";
......@@ -254,38 +258,36 @@ void setupInside()
return;
}
}
// eof = false;
// if (!questionSaving)
// {
// try {
// print("\n");
// while (!eof)
// {
// Question tempQuest = (Question) inQ.readObject();
// print(QuestiontoString(tempQuest) +",\n");
// questions.add(tempQuest);
// }
// }
// catch(ClassNotFoundException i) {
// }
//
// catch(java.io.EOFException ex1)
// {
// eof=true;
// }
// catch(IOException i)
// {
// i.printStackTrace();
// return;
// }
// }
if(!questionSaving && !saveornot)
{
for(int i=0;i<questionandanswers[((int)tempFiler) - 65].length;i++)
questions.add(questionandanswers[((int)tempFiler) - 65][i]);
}
// eof = false;
// if (!questionSaving)
// {
// try {
// print("\n");
// while (!eof)
// {
// Question tempQuest = (Question) inQ.readObject();
// print(QuestiontoString(tempQuest) +",\n");
// questions.add(tempQuest);
// }
// }
// catch(ClassNotFoundException i) {
// }
//
// catch(java.io.EOFException ex1)
// {
// eof=true;
// }
// catch(IOException i)
// {
// i.printStackTrace();
// return;
// }
// }
if (!questionSaving && !saveornot)
{
for (int i=0;i<questionandanswers[((int)tempFiler) - 65].length;i++)
questions.add(questionandanswers[((int)tempFiler) - 65][i]);
}
boundaries.add(new Boundary(5, height/2, 10, height, 0));
boundaries.add(new Boundary(width-5, height/2, 10, height, 0));
......@@ -310,10 +312,10 @@ String Recshow1(Rectangle r) {
}
String QuestiontoString(Question q )
{
if(q.type.equals("Rectangle"))
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "\"," + Recshow1(q.answer)+")" ;
if (q.type.equals("Rectangle"))
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "\"," + Recshow1(q.answer)+")" ;
else
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "\",\"" + q.tAnswer+"\")" ;
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "\",\"" + q.tAnswer+"\")" ;
}
void draw()
......@@ -363,7 +365,7 @@ void draw()
String rightorwrong;
double tempScore = similarity(tempAnswer, questions.get(QuestionCounter).tAnswer)*100;
if (tempScore>70)
rightorwrong = "yes";
else if (tempScore>40)
......@@ -375,12 +377,12 @@ void draw()
writer.println("Date " + date.toString() + " Timestamp: " + millis() + " Partipation ID: " + participationID +" Trial number: " + tempFiler + (QuestionCounter+1) + " Correct Answer: " + questions.get(QuestionCounter).tAnswer + " Answer Given: " + tempAnswer + "Answer Percent: " + tempScore + " Comment: " + rightorwrong );
pushMatrix();
textSize(20);
fill(0, 0, 0);
text( "participationID: " + participationID, 200, 200);
popMatrix();
text(tempAnswer,400,400);
pushMatrix();
textSize(20);
fill(0, 0, 0);
text( "participationID: " + participationID, 200, 200);
popMatrix();
text(tempAnswer, 400, 400);
save(folderName + "/" + day()+"-"+month()+"-"+year()+"-"+ hour()+"-"+minute() +"-"+second()+ "-" +millis() +"-"+ participationID +"-" + tempFiler + (QuestionCounter+1)+ ".png");
......@@ -549,7 +551,7 @@ void mouseReleased()
else if ( intersection > 40.0)
rightorwronng = "overFlow maybe";
else rightorwronng = "Incorrect";
date = new Date();
writer.println("Date " + date.toString() + " Timestamp: " + millis() + " Partipation ID: " + participationID +" Trial number: " + tempFiler + (QuestionCounter+1) + " Correct Answer: " + RectoString(questions.get(QuestionCounter).answer) + " Answer Given: " + RectoString(r1) +" Intersection Percentage: " + intersection + " Answer Given/ Answer Ratio: "+ bigRecRatio +" Comment: " + rightorwronng );
pushMatrix();
......@@ -943,41 +945,44 @@ public String RectoString(Rectangle r)
// return m;
//}
public static double similarity(String s1, String s2) {
String longer = s1, shorter = s2;
if (s1.length() < s2.length()) { // longer should always have greater length
longer = s2; shorter = s1;
}
int longerLength = longer.length();
if (longerLength == 0) { return 1.0; /* both strings are zero length */ }
/* // If you have StringUtils, you can use it to calculate the edit distance:
return (longerLength - StringUtils.getLevenshteinDistance(longer, shorter)) /
(double) longerLength; */
return (longerLength - editDistance(longer, shorter)) / (double) longerLength;
}
String longer = s1, shorter = s2;
if (s1.length() < s2.length()) { // longer should always have greater length
longer = s2;
shorter = s1;
}
int longerLength = longer.length();
if (longerLength == 0) {
return 1.0; /* both strings are zero length */
}
/* // If you have StringUtils, you can use it to calculate the edit distance:
return (longerLength - StringUtils.getLevenshteinDistance(longer, shorter)) /
(double) longerLength; */
return (longerLength - editDistance(longer, shorter)) / (double) longerLength;
}
public static int editDistance(String s1, String s2) {
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
int[] costs = new int[s2.length() + 1];
for (int i = 0; i <= s1.length(); i++) {
int lastValue = i;
for (int j = 0; j <= s2.length(); j++) {
if (i == 0)
costs[j] = j;
else {
if (j > 0) {
int newValue = costs[j - 1];
if (s1.charAt(i - 1) != s2.charAt(j - 1))
newValue = Math.min(Math.min(newValue, lastValue),
costs[j]) + 1;
costs[j - 1] = lastValue;
lastValue = newValue;
}
}
}
if (i > 0)
costs[s2.length()] = lastValue;
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
int[] costs = new int[s2.length() + 1];
for (int i = 0; i <= s1.length(); i++) {
int lastValue = i;
for (int j = 0; j <= s2.length(); j++) {
if (i == 0)
costs[j] = j;
else {
if (j > 0) {
int newValue = costs[j - 1];
if (s1.charAt(i - 1) != s2.charAt(j - 1))
newValue = Math.min(Math.min(newValue, lastValue),
costs[j]) + 1;
costs[j - 1] = lastValue;
lastValue = newValue;
}
return costs[s2.length()];
}
}
}
if (i > 0)
costs[s2.length()] = lastValue;
}
return costs[s2.length()];
}
......@@ -5,9 +5,9 @@
* designer and care should be taken when editing this file.
* Only add/edit code inside the event handlers i.e. only
* use lines between the matching comment tags. e.g.
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
// It is safe to enter your event code here
// It is safe to enter your event code here
} //_CODE_:button1:12356:
* Do not rename this tab!
......@@ -15,15 +15,15 @@
*/
public void textfield1_change1(GTextField source, GEvent event) { //_CODE_:textfield1:215102:
// println("textfield1 - GTextField >> GEvent." + event + " @ " + p.Ecounter);
// println("textfield1 - GTextField >> GEvent." + event + " @ " + p.Ecounter);
if (event == GEvent.ENTERED)
{
print(source.getText());
participationID = source.getText();
folderName = sketchPath("")+"/gameStudyData/"+day()+"-"+month()+"-"+year()+"-"+ hour()+"-"+minute() +"-"+second()+ "-" +millis() +"-"+ participationID;
File file = new File(folderName);
file.mkdirs();
......@@ -40,11 +40,11 @@ public void textfield1_change1(GTextField source, GEvent event) { //_CODE_:textf
{
print(e.toString());
}
startMenu =false;
label1.setVisible(false);
textfield1.setVisible(false);
......@@ -56,46 +56,41 @@ public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:9830
println("button1 - GButton >> GEvent." + event + " @ " + millis());
// tempFiler = (char)((int)(tempFiler-1);
tempFiler++;
if(tempFiler>'J')
{
source.setVisible(false);
noLoop();
text("Thanks",200,200);
}
else
setupInside();
source.setVisible(false);
tempFiler++;
if (tempFiler>'J')
{
source.setVisible(false);
noLoop();
text("Thanks", 200, 200);
}
else
setupInside();
source.setVisible(false);
//
// loop();
} //_CODE_:button1:983045:
public void textfield2_change1(GTextField source, GEvent event) { //_CODE_:questionToBeSaved:568734:
println("question - GTextField >> GEvent." + event + " @ " + millis());
if (event == GEvent.ENTERED)
{
tempQuestion = source.getText();
tempQuestion = source.getText();
source.setVisible(false);
}
} //_CODE_:questionToBeSaved:568734:
public void textfield2_change2(GTextField source, GEvent event) { //_CODE_:QuestionType:844807:
println("QuestionType - GTextField >> GEvent." + event + " @ " + millis());
if (event == GEvent.ENTERED)
{
tempType = source.getText();
source.setVisible(false);
loop();
}
} //_CODE_:QuestionType:844807:
public void textfield2_change3(GTextField source, GEvent event) { //_CODE_:textfield2:870671:
......@@ -106,11 +101,11 @@ public void textfield2_change3(GTextField source, GEvent event) { //_CODE_:textf
// Create all the GUI controls.
// autogenerated do not edit
public void createGUI(){
public void createGUI() {
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
G4P.setCursor(ARROW);
if(frame != null)
if (frame != null)
frame.setTitle("Sketch Window");
label1 = new GLabel(this, 63, 195, 122, 24);
label1.setText("Enter Participation ID:");
......
......@@ -25,8 +25,8 @@ class Box {
// Add the box to the box2d world
makeBody(new Vec2(x, y), w, h);
}
Box(float x, float y,float w,float h) {
Box(float x, float y, float w, float h) {
// w = random(4, 16);
// h = random(4, 16);
this.w=w;
......@@ -38,8 +38,8 @@ class Box {
// Add the box to the box2d world
makeBody(new Vec2(x, y), w, h);
}
// This function removes the particle from the box2d world
void killBody() {
......@@ -111,13 +111,12 @@ class Box {
body.applyForce(v, body.getWorldCenter());
//body.setLinearVelocity(v);
}
boolean contains(float x, float y) {
boolean contains(float x, float y) {
Vec2 worldPoint = box2d.coordPixelsToWorld(x, y);
Fixture f = body.getFixtureList();
boolean inside = f.testPoint(worldPoint);
return inside;
}
}
......@@ -62,22 +62,21 @@ class Person {
noStroke();
translate(a.x, a.y);
rotate(-a.angle);
if(i%4==0)
rect(0, 0, 20, 20);
if (i%4==0)
rect(0, 0, 20, 20);
popMatrix();
}
if (a.seen)
{
rpoints.add(a);
rpoints.add(a);
}
}
this.points.removeAll(rpoints);
}
......
......@@ -9,19 +9,19 @@ class Question implements Serializable
String tAnswer;
public Question(String type ,String quest, Rectangle ans)
public Question(String type, String quest, Rectangle ans)
{
this.type = type;
this.question = quest;
this.answer = ans;
}
public Question( String type,String quest)
public Question( String type, String quest)
{
this.type = type;
this.question = quest;
}
public Question(String type ,String quest, String ans)
public Question(String type, String quest, String ans)
{
this.type = type;
this.question = quest;
......
......@@ -20,7 +20,8 @@ public class Rectangle implements Serializable {
}
public String show() {
return x + " , " + y ; }
return x + " , " + y ;
}
public boolean isEqual(Point p) {
return this.x == p.x && this.y == p.y;
......@@ -156,6 +157,4 @@ public class Rectangle implements Serializable {
......@@ -67,7 +67,10 @@ void setup()
box2d.createWorld();
boundaries = new ArrayList<Boundary>();
setupInside();
background(255);
textSize(20);
fill(0);
text("Welcome to the Attention Study.\nIn this part of the study There would be tanks bouncing and moving on the screen and then after sometime there will be a black screen. Black screen would mean that you are not attentive at that time. After the black Screen there would be Questions asking what do you think happened when you were not attentive that is when where was a black screen. Press Enter when you want to start.", width/2-150, height/2-150, 400, 400);
// boundaries.add(new Boundary(3*width/4,height-50,width/2-50,10,0));
events = " ddddddddddddddaass asdawd aaaaaaaaawdawdaaaaaaadddddddaass aaaaaaaaaaaaaaaaaaadddddddaass aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddwwwwwwwwwwwwwwwwwwwwwwwwwwwaaaaaaaaaaaaaaaaaadddddddwaaaaaaaaaaaaaaaaaaaaaawwwwwwwwwwwwwwwwwwwwwdddddddddddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddda aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaa";
events1 =" ddddddddddddddaass aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaa aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddd aaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddwwwwwwwwwwwwwwwwwwwwwwwwwwwaaaaaaaaaaaaaaaaaadddddddwaaaaaaaaaaaaaaaaaaaaaawwwwwwwwwwwwwwwwwwwwwdddddddddddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddassssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssasssssssssssssssssssasssssssssssssdasaaaaaddddddddddddddddddddddddddddddaaaaaaassssssssssssssssssssssssssssssssssssssssssssssdsssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddsssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd";
......@@ -254,38 +257,36 @@ void setupInside()
return;
}
}
// eof = false;
// if (!questionSaving)
// {
// try {
// print("\n");
// while (!eof)
// {
// Question tempQuest = (Question) inQ.readObject();
// print(QuestiontoString(tempQuest) +",\n");
// questions.add(tempQuest);
// }
// }
// catch(ClassNotFoundException i) {
// }
//
// catch(java.io.EOFException ex1)
// {
// eof=true;
// }
// catch(IOException i)
// {
// i.printStackTrace();
// return;
// }
// }
if(!questionSaving && !saveornot)
{
for(int i=0;i<questionandanswers[((int)tempFiler) - 65].length;i++)
questions.add(questionandanswers[((int)tempFiler) - 65][i]);