/** * V3 * PROTEST GEGEN INETRNETSPERREN * VON LAIEN REGIERT * * with data from http://www.spreeblick.com/protest-gegen-internetsperren/ * * feel free to play around and make something meaningful * feel free to play around and make something beautiful * * Michael Schieben, 2009 * http://www.rockitbaby.de/ * http://www.twoantennas.com/ * * Design: Johannes Schardt * http://www.precious-forever.com * * thanks to @mlnmln, @jhns, @preciousforever, @spreeblick * */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; XMLElement markers; int[] votesPerHour = new int[24]; int maxVotesPerHour = 0; long start, end, currentTime = 0; PFont font; ArrayList visualizations = new ArrayList(); void setup() { size(487, 651, P3D); frameRate(10); noStroke(); rectMode(CORNER); imageMode(CORNER); start = currentTime = timestamp("2009-04-22 00:00:01"); end = timestamp("2009-04-22 23:59:59"); font = loadFont("HelveticaNeue-Bold-48.vlw"); textFont(font, 18); markers = new XMLElement(this, "markersxy.xml"); fill(0); rect(0, 0, width, height); initHours(); initVis(); initImages(); } PImage buttonPlay; PImage buttonPause; PImage chromeBg; PImage pointer; void initImages() { buttonPlay = loadImage("button-play.png"); buttonPause = loadImage("button-pause.png"); chromeBg = loadImage("chrome-bg.png"); pointer = loadImage("pointer.png"); } void initHours() { int added = 0; XMLElement hours = new XMLElement(this, "hours.xml"); int num = hours.getChildCount(); while (added < num) { XMLElement h = hours.getChild(added); int count = h.getIntAttribute("count"); votesPerHour[h.getIntAttribute("hour")] = h.getIntAttribute("count"); maxVotesPerHour = max(maxVotesPerHour, count); added++; } println(maxVotesPerHour); } void initVis() { int added = 0; int numMarkers = markers.getChildCount(); while (added < numMarkers) { visualizations.add(new Vis(markers.getChild(added))); added++; } } long timestamp(String s) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date d = sdf.parse(s); return sdf.parse(s).getTime(); } catch(Exception e) { return 0; } } class Vis { XMLElement marker; Point p; long time = 0; String name = ""; Vis(XMLElement marker) { this.marker = marker; this.name = marker.getStringAttribute("name"); this.time = timestamp(marker.getStringAttribute("timestamp")); this.p = new Point(marker.getFloatAttribute("x"), marker.getFloatAttribute("y")); } void draw() { fill(72, 246, 230, 60); translate(this.p.x, this.p.y); if (currentTime > this.time) { ellipse(0,0,4,4); absolute++; } if (abs(currentTime - this.time) < 100000) { fill(180, 255, 255); ellipse(0,0,6,6); } } } class Point { float x, y = 0; Point(float x, float y) { this.x = x; this.y = y; } String toString() { return str(x) + " " + str(y); } }