Skip to content

Instantly share code, notes, and snippets.

@y-yu
Created June 6, 2013 09:08
Show Gist options
  • Save y-yu/5720296 to your computer and use it in GitHub Desktop.
Save y-yu/5720296 to your computer and use it in GitHub Desktop.
import java.util.*;
import controlP5.*;
class Date {
String body;
HashSet<String> ok = new HashSet<String>();
Date (String b) {
body = b;
}
void add (String p) {
ok.add(p);
}
boolean contains (String p) {
return ok.contains(p);
}
void draw_result (String p, int x, int y) {
if ( contains(p) ) {
fill(0);
text("ok", x, y);
print("ok\n");
} else {
fill(0);
text("ng", x, y);
print("ng\n");
}
}
}
void result (ArrayList<Date> dates, ArrayList<String> persons) {
int x = 10,
y = 10;
for (String p : persons) {
x += 50;
fill(0);
text(p, x, y);
line(x, y - 10, x, y + 50);
}
y = 50;
for (Date d : dates) {
x = 10;
fill(0);
text(d.body, x, y);
x += 50;
line(x, y - 10, x, y + 50);
for (String p : persons) {
d.draw_result(p, x, y);
x += 50;
line(x, y - 10, x, y + 50);
}
line(x - persons.size() * 50, y - 10, x, y - 10);
y += 50;
}
}
void input_date (ArrayList<Date> dates) {
int y = 10;
ArrayList<RadioButton> r = new ArrayList<RadioButton>();
ControlP5 cp = new ControlP5(this);
for (Date d : dates) {
r.add(cp.addRadioButton(d.body).setPosition(50, y).setSize(10, 10).addItem( d.body + "OK", 0).activate(0));
fill(0);
text(d.body, 10, y);
line(10, y - 10, 10, y + 50);
line(50, y - 10, 50, y + 50);
line(10, y - 10, 50 + dates.size() * 50, y - 10);
y += 50;
}
}
void setup() {
ArrayList<Date> dates = new ArrayList<Date>();
ArrayList<String> persons = new ArrayList<String>();
size(500, 500);
background(255);
dates.add( new Date("10/1") );
dates.add( new Date("10/2") );
dates.add( new Date("10/3") );
dates.add( new Date("10/4") );
persons.add("man1");
persons.add("man2");
dates.get(0).add("man1");
dates.get(0).add("man2");
dates.get(3).add("man2");
result(dates, persons);
//input_date(dates);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment