//GLOBAL VARIABLES int fieldNum = 5; // how many pieces of data (i.e.: country, magnitude, lat, long) String lines[]; String myData[][]; float scaleFactor = .25; // to fit magnitudes on page float scaleFactorDeaths = -.0005; // to fit deaths on page int latCorrection = -1; // to make negative latitude values appear below equator int hSpace = 500; // horizontal spacing //TYPEFACES PFont typeface; //IMPORT PDF LIBRARY import processing.pdf.*; import processing.opengl.*; void setup(){ size(200,200); background(255); // background color typeface = createFont("Helvetica",20); lines = loadStrings("magnitude_location-deaths.txt"); // calls data source file myData = new String[lines.length][fieldNum]; // sets up number of items and pieces of data per item for (int i=0; i < lines.length; i++){ myData[i] = lines[i].split(","); } } void draw(){ beginRecord(PDF, "earthquakes.pdf"); textMode(SHAPE); textFont(typeface,1); // size of type textAlign(LEFT); for (int i=0; i < lines.length; i++){ fill(255,0,0); // magnitude color noStroke(); ellipse(float(myData[i][3]),float(myData[i][2])*latCorrection,float(myData[i][1])*scaleFactor,float(myData[i][1])*scaleFactor); // magnitude x,y coordinates of circle center, circle width, circle height fill(220); // deaths color rect(float(myData[i][3])-.5,float(myData[i][2])*latCorrection,1,float(myData[i][4])*scaleFactorDeaths); // deaths x,y coordinates of rect lower left corner, rect width, rect height fill(0); // text color text(myData[i][0],float(myData[i][3]),float(myData[i][2])*latCorrection); // text content, x,y coordinates } noLoop(); endRecord(); }