void setup() {
size(displayResolutionX, displayResolutionY);
colorMode(HSB, 360, 100, 100);
frameRate(30);
smooth();
bg = loadImage("Gradient_Background.jpg");
bg.resize(displayResolutionX, displayResolutionY);
image(bg, 0, 0);
unitsOfMeasure[0] ="Quadrillion\nBtu";
unitsOfMeasure[1] ="Quadrillion\nBtu";
unitsOfMeasure[2] ="Million\nBtu\nper Person";
unitsOfMeasure[3] ="Million\nMetric\nTons";
unitsOfMeasure[4] ="Metric Tons\nof CO2\nper Person";
unitsOfMeasure[5] ="Billion\nKilowatt\nHours";
background(315);
//Define important data members first:
data = new EntryTable("Total_Primary_Energy_Production_(Quadrillion_Btu).txt");
rowCount = data.getRowCount();
columnCount = data.getColumnCount();
years = int(data.getColumnNames());
yearMin = years[0];
yearMax = years[columnCount - 1];
countries = data.getRowNames();
dataMin = 0;
dataMax = ceil(data.getTableMax() / roundAway) * roundAway;
graphMax = dataMax + (dataMax * 0.1);
showCountries = new boolean[countries.length];
colorsOfCountries= new color[rowCount];
colorCodeCountries();
data.calculateSortSumData();
arrayOfSmallestAreas = data.sumData;
//Sets up initial Integrators for the default graph thats loaded
interpolators = new Integrator[rowCount][columnCount];
for(int row = 0; row < rowCount; row++){
for(int col = 0; col < columnCount; col++){
float initialValue = float(data.getEntry(row, col));
interpolators[row][col] = new Integrator(initialValue);
interpolators[row][col].attraction = 0.1; //Set lower than default
showCountries[row] = true;
}
}
configureYMarkers();
plotFont = createFont("Gulim", 8);
tabFont = createFont("Gulim", 12);
axisUnitFont = createFont("Cordia New", 24);
axisLabelFont = createFont("Euphimia", 30);
countryFont = createFont("Gulim", 20);
graphPlotX1 = width * 0.35;
graphPlotX2 = width - (0.01 * width);
axisLabelY = graphPlotX1 - (0.08 *width);
graphPlotY1 = 60;
graphPlotY2 = height - 120;
axisLabelX = height - 25;
filterGraphPlotX1 = int(.01 * width);
filterGraphPlotY1 = int(graphPlotY1 - (.03 * width));
filterGraphPlotX2 = int(graphPlotX1 - (.15 * width));
filterGraphPlotY2 = int(graphPlotY2);
filterLabelX = filterGraphPlotX1 + 10;
filterLabelY = filterGraphPlotY1 + 10;
cp5 = new ControlP5(this);// TEXT WONT POPULATE THE LISTBOXITEMS!!!!!!!
l = cp5.addListBox("myList")
.setPosition(filterGraphPlotX1, (filterGraphPlotY1 + 35))
.setSize((filterGraphPlotX2 - filterGraphPlotX1), (filterGraphPlotY2 - filterGraphPlotY1))
.setItemHeight(20)
.setBarHeight(35)
.setColorBackground(color(250))
.setColorActive(color(330))
;
l.captionLabel().toUpperCase(true);
l.captionLabel().set("Filter by Country:");
l.captionLabel().setColor(#020208);
l.captionLabel().style().marginTop = 3;
l.valueLabel().style().marginTop = 3;
for(int i = 0; i < rowCount; i++){
ListBoxItem lbi = l.addItem(countries[i], i);
lbi.setColorBackground(colorsOfCountries[i]);
}
range = cp5.addRange("rangeController")
// disable broadcasting since setRange and setRangeValues will trigger an event
.setBroadcast(false)
.setPosition(graphPlotX1, (graphPlotY2+45))
.setSize(int(graphPlotX2 - graphPlotX1),10)
.setHandleSize(20)
.setRange(0, 29)
.setRangeValues(0,29)
// after the initialization we turn broadcast back on again
.setBroadcast(true)
.setColorForeground(color(75,360))
.setColorBackground(color(180,180))
.setNumberOfTickMarks(30)
;
}