PImage mapImage; PFont plotFont; Table locationTable; Room[] rooms; int roomCount = 0; color[] certLevelColor = new color[6]; String[] certLevelString = new String[6]; static final int SMALL_ELLIPSE = 20; static final int MEDIUM_ELLIPSE = 40; static final int LARGE_ELLIPSE = 60; void setup() { size(700, 575, P2D); plotFont = createFont("SansSerif", 13); textFont(plotFont); textMode(SCREEN); smooth(); mapImage = loadImage("DBV.jpg"); certLevelColor[0] = color(255, 255, 255); certLevelColor[1] = color(254, 235, 226); certLevelColor[2] = color(251, 180, 185); certLevelColor[3] = color(247, 104, 161); certLevelColor[4] = color(197, 27, 138); certLevelColor[5] = color(122, 1, 119); certLevelString[0] = "None"; certLevelString[1] = "Student"; certLevelString[2] = "Open Water"; certLevelString[3] = "Advanced"; certLevelString[4] = "Rescue"; certLevelString[5] = "Instructor"; locationTable = new Table("locations.tsv"); readData(locationTable); } void draw() { background(255); image(mapImage, 0, 0); drawDiveLegend(); drawCertLegend(); for (int i = 0; i < roomCount; i++) { rooms[i].draw(); } } void readData(Table locationTable) { rooms = new Room[locationTable.getRowCount()]; for(int row = 0; row < locationTable.getRowCount(); row++) { String name = locationTable.getString(row, 0); int x = locationTable.getInt(row, 1); int y = locationTable.getInt(row, 2); int certLevel1 = locationTable.getInt(row, 3); int certLevel2 = locationTable.getInt(row, 4); int dives = locationTable.getInt(row, 5); rooms[roomCount++] = new Room(name, x, y, certLevel1, certLevel2, dives); } } void drawDiveLegend() { fill(0); text("Hover over data point to display image:", 200, 260); text("Total number of dives\nmade during the week:", 20, 320); text("< 7", 20, 370); text("7-10", 20, 410); text("> 10", 20, 470); fill(215); noStroke(); ellipse(90, 365, SMALL_ELLIPSE, SMALL_ELLIPSE); ellipse(90, 405, MEDIUM_ELLIPSE, MEDIUM_ELLIPSE); ellipse(90, 465, LARGE_ELLIPSE, LARGE_ELLIPSE); } void drawCertLegend() { fill(0); textAlign(RIGHT); text("Certification\nLevel:", 115, 520); rectMode(CENTER); for (int i = 0; i < certLevelString.length; i++) { if (i == 0) stroke(0); else noStroke(); fill(certLevelColor[i]); rect(150 + 85 * i, 535, 15, 15); fill(0); textAlign(CENTER); text(certLevelString[i], 150 + 85 * i, 520); } textAlign(LEFT); }