axis[] myaxis; PFont fontA; PFont fontB; String josh; things[] mythings1; PImage img1; PImage img2; void setup() { stroke(255); size(1200,800); // THINGS STUFF:: img1 = createImage(50, 50, ARGB); img2 = createImage(50, 50, ARGB); //String name = {" ", " "}; mythings1 = new things[33]; for (int j0 = 0; j0 < 33; j0++) { mythings1[j0] = new things(); } String[] lines = loadStrings(("data_things.txt")); for (int j0 = 0; j0 < 33; j0++) { mythings1[j0].ID = lines[ 0+ j0* 15]; mythings1[j0].SPECSFR = float(lines[ 1+ j0* 15]); mythings1[j0].RA = float(lines[ 2+ j0* 15]); mythings1[j0].DEC = float(lines[ 3+ j0* 15]); mythings1[j0].DIST = float(lines[ 4+ j0* 15]); mythings1[j0].DIST_SOURCE = lines[ 5+ j0* 15]; mythings1[j0].LOGD25 = float(lines[ 6+ j0* 15]); mythings1[j0].M_B = float(lines[ 7+ j0* 15]); mythings1[j0].MAG_B = float(lines[ 8+ j0* 15]); mythings1[j0].INCL = float(lines[ 9+ j0* 15]); mythings1[j0].PA = float(lines[ 10+ j0* 15]); mythings1[j0].METAL = float(lines[ 11+ j0* 15]); mythings1[j0].SFR = float(lines[ 12+ j0* 15]); mythings1[j0].TYPE = int(lines[ 13+ j0* 15]); mythings1[j0].NOTES = lines[ 14+ j0* 15]; } for (int j0 = 0; j0 < 33; j0++) { mythings1[j0].dx = mythings1[j0].RA*2.; mythings1[j0].dy = 180-mythings1[j0].DEC*2.; String name[] = {mythings1[j0].ID, ".png"}; // name = ; mythings1[j0].IMG = loadImage((join(name, ""))); } //AXES STUFF:: boolean isx; isx = false; josh = ""; fontA = loadFont("Futura-CondensedMedium-18.vlw"); fontB = loadFont("Futura-CondensedMedium-18.vlw"); // Set the font and its size (in units of pixels) textFont(fontA, 18); if (isx) { textAlign(CENTER, CENTER); } if (!isx) { textAlign(LEFT, CENTER); } myaxis = new axis[2]; for (int j0 = 0; j0 < 2; j0++) { myaxis[j0] = new axis(11); } for (int j0 = 0; j0 < 2; j0++) { myaxis[j0].varnames[0] = "RA"; myaxis[j0].varnames[1] = "dec"; myaxis[j0].varnames[2] = "distance"; myaxis[j0].varnames[3] = "specific SFR"; myaxis[j0].varnames[4] = "ang diameter"; myaxis[j0].varnames[5] = "brightness"; myaxis[j0].varnames[6] = "luminosity"; myaxis[j0].varnames[7] = "inclination"; myaxis[j0].varnames[8] = "position angle"; myaxis[j0].varnames[9] = "metals"; myaxis[j0].varnames[10] = "SFR"; myaxis[j0].units[0] = "[deg]"; myaxis[j0].units[1] = "[deg]"; myaxis[j0].units[2] = "[Mpc]"; myaxis[j0].units[3] = "[M_o/yr/pc^2]"; myaxis[j0].units[4] = "[arcmin]"; myaxis[j0].units[5] = "[mag]"; myaxis[j0].units[6] = "[mag]"; myaxis[j0].units[7] = "[deg]"; myaxis[j0].units[8] = "[deg]"; myaxis[j0].units[9] = "12+log(O/H)"; myaxis[j0].units[10] = "[M_o/yr]"; myaxis[j0].findpos(); } myaxis[0].isx = true; myaxis[1].isx = false; myaxis[0].selected[0] = true; myaxis[1].selected[1] = true; myaxis[0].get_range(); myaxis[0].assign_pos(mythings1); myaxis[0].varcolor[0] = color(255); myaxis[1].get_range(); myaxis[1].assign_pos(mythings1); myaxis[1].varcolor[1] = color(255); myaxis[0].findpos(); myaxis[0].display(); myaxis[1].findpos(); myaxis[1].display(); } void draw() { background(200); myaxis[0].findpos(); myaxis[0].display(); myaxis[0].display_units(); myaxis[1].findpos(); myaxis[1].display(); myaxis[1].display_units(); for (int j0 = 0; j0 < 33; j0++) { mythings1[j0].display(); mythings1[j0].move(); } nameplot(mythings1); if (mousePressed) { // myaxis[0].findpos(); myaxis[0].clickeval(mythings1); // myaxis[1].findpos(); myaxis[1].clickeval(mythings1); } } //void mousePressed() { // // myaxis[0].findpos(); // myaxis[0].clickeval(mythings1); // myaxis[1].findpos(); // myaxis[1].clickeval(mythings1); // myaxis[0].assign_pos(mythings1[0]); //} //AXIS CLASS class axis { int nvar; String[] varnames; int[] varlengths; int charpixwid; int margin; float[] pos; boolean isx; float isx1; color[] varcolor; boolean[] selected; float maxp; float minp; float[] mmx; float[] mmy; String[] units; axis(String[] tempvarnames, int[] tempvarlengths, int tempcharpixwid, int tempmargin, float[] temppos, boolean tempisx, color[] tempvarcolor, boolean[] tempselected, float tempminp, float tempmaxp, float[] tempmmx, float[] tempmmy, String[] tempunits) { varnames = tempvarnames; varlengths = tempvarlengths; margin = tempmargin; charpixwid = tempcharpixwid; pos = temppos; isx = tempisx; varcolor=tempvarcolor; selected = tempselected; maxp = tempmaxp; minp = tempminp; mmx = tempmmx; mmy = tempmmy; units = tempunits; } axis() { nvar = 5; varnames = new String[5]; varlengths = new int[5]; margin = 10; charpixwid = 7; pos = new float[5]; isx =false; isx1 = 0.; varcolor= new color[5]; selected = new boolean[5]; minp = 0.; maxp=1.; mmx = new float[2]; mmy = new float[2]; mmx[0] = width/10.; mmx[1] = width - width/10.; mmy[0] = height - height/10.; mmy[1] = height/10.; units = new String[5]; } axis(int tempnvar) { nvar = tempnvar; varnames = new String[nvar]; varlengths = new int[nvar]; margin = 20; charpixwid = 7; pos = new float[nvar]; isx =false; isx1 = 0.; varcolor= new color[nvar]; for (int j0 = 0; j0 < nvar; j0++) { varcolor[j0] = color(128); } selected = new boolean[nvar]; minp = 0.; maxp=1.; mmx = new float[2]; mmy = new float[2]; mmx[0] = width/10.; mmx[1] = width - width/10.; mmy[0] = height - height/10.; mmy[1] = height/10.; units = new String[nvar]; } void clickeval(things[] th_obj) { isx1 = 0.; if (isx) { isx1 = 1.; } for (int j0 = 0; j0 < varnames.length; j0++) { if (overRect(isx1*pos[j0] + (1-isx1)*(20 + varnames[j0].length()*charpixwid/2.),(height - 50.)*isx1 + (1-isx1)*pos[j0], varnames[j0].length()*charpixwid, 32.)) { for (int j1 = 0; j1 < varnames.length; j1++) { varcolor[j1] = color(128); selected[j1] = false; } varcolor[j0] = color(255) ; selected[j0] = true; get_range(); assign_pos(th_obj); for (int j2 = 0; j2 < th_obj.length; j2++) { th_obj[j2].tl = th_obj[j2].t; } } } } void display() { isx1 = 0.; if (isx) { isx1 = 1.; } for (int j0 = 0; j0 < varnames.length; j0++) { fill(varcolor[j0]); text(varnames[j0], isx1*pos[j0] + (1-isx1)*20., (height - 50.)*isx1 + (1-isx1)*pos[j0]); } } void display_units() { fill(color(255)); if (isx) { textAlign(CENTER); text(str(minp), width/10., 40.); text(str(maxp), width- width/10., 40.); for (int j0 = 0; j0 < varnames.length; j0++) { if (selected[j0]) { text(units[j0], width/2., 40.); } } } if (!isx) { textAlign(RIGHT); text(str(maxp), width - 20., height/10.); text(str(minp), width- 20., height - height/10.); for (int j0 = 0; j0 < varnames.length; j0++) { if (selected[j0]) { text(units[j0], width - 20., height/2.); } } } } void findpos() { float sp; float[] totlen; isx1 = 0.; if (isx) { isx1 = 1.; } if (!isx) { textAlign(LEFT, CENTER); } if (isx) { textAlign(CENTER, CENTER); } totlen= new float[varnames.length]; // totlen = new float totlen[0] = charpixwid*varnames[0].length(); for (int j0 = 1; j0 < varnames.length; j0++) { totlen[j0] = totlen[j0-1] + charpixwid*varnames[j0].length(); } sp = (isx1*width + (1-isx1)*height - 2.*margin-isx1*totlen[varnames.length-1])/(varnames.length +1); pos[0] = margin + sp + varnames[0].length()*charpixwid/2.*isx1; for (int j0 = 1; j0 < varnames.length; j0++) { pos[j0] = margin + sp*(j0+1) + varnames[j0].length()*charpixwid/2.*isx1+totlen[j0-1]*isx1; } } void get_range() { if (selected[0]) { //RA maxp = 360.; minp = 0.; } if (selected[1]) { //DEC maxp=90.; minp = -90.; } if (selected[2]) { //DIST maxp = 15.; minp= 0.; } if (selected[3]) { //Specific SFR maxp = 10. ; minp= 0. ; } if (selected[4]) { //log(D25) maxp = 2.5; minp= 0.5; } if (selected[5]) { //Brightness maxp = 6.; minp= 17.; } if (selected[6]) { //Luminosity maxp = -22.; minp=-10. ; } if (selected[7]) { //inclination maxp = 90.; minp= 0.; } if (selected[8]) { //position angle maxp = 360.; minp= 0.; } if (selected[9]) { //metalicity maxp = 10.; minp= 7.; } if (selected[10]) { //SFR maxp = 7.; minp= 0.; } } void assign_pos(things[] th_obj) { if (selected[0]) { //RA if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] + (th_obj[j0].RA -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] + ((th_obj[j0].RA -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[1]) { //DEC if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].DEC -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].DEC -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[2]) { //DIST if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].DIST -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].DIST -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[3]) { //Specific SFR if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].SPECSFR -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].SPECSFR -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[4]) { //log(D25) if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].LOGD25 -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].LOGD25 -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[5]) { //Brightness if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].M_B -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].M_B -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[6]) { //Luminosity if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].MAG_B -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].MAG_B -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[7]) { //inclination if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].INCL -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].INCL -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[8]) { //position angle if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].PA -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].PA -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[9]) { //metalicity if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].METAL -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].METAL -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } if (selected[10]) { //SFR if (isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dx = mmx[0] +(th_obj[j0].SFR -minp)/(maxp - minp)*(mmx[1]-mmx[0]); } } if (!isx) { for (int j0 = 0; j0 < th_obj.length; j0++) { th_obj[j0].dy = mmy[0] +( (th_obj[j0].SFR -minp)/(maxp - minp))*(mmy[1]-mmy[0]); } } } } } //THINGS CLASS class things { String ID; float SPECSFR; float RA; float DEC; float DIST; String DIST_SOURCE; float LOGD25; float M_B; float MAG_B; float INCL; float PA; float METAL; float SFR; int TYPE; String NOTES; float x; float y; float dx; float dy; float vx; float vy; float ax; float ay; float t; // total number of ticks to do a move float tl; // number of time ticks left PImage IMG; ; things(String tempID , float tempSPECSFR , float tempRA , float tempDEC , float tempDIST , String tempDIST_SOURCE , float tempLOGD25 , float tempM_B , float tempMAG_B , float tempINCL , float tempPA , float tempMETAL , float tempSFR , int tempTYPE , String tempNOTES, float tempx, float tempy, float tempdx, float tempdy, float tempvx, float tempvy, float tempax, float tempay, float temptl, int tempt){ ID = tempID; SPECSFR = tempSPECSFR; RA = tempRA; DEC = tempDEC; DIST = tempDIST; DIST_SOURCE = tempDIST_SOURCE; LOGD25 = tempLOGD25; M_B = tempM_B; MAG_B = tempMAG_B; INCL = tempINCL; PA = tempPA; METAL = tempMETAL; SFR = tempSFR; TYPE = tempTYPE; NOTES = tempNOTES; x = tempx; y = tempy; dx = tempdx; dy = tempdy; vx = tempvx; vy = tempvy; ax = tempax; ay = tempay; tl = temptl; t = tempt; // IMG = tempIMG; } things(){ ID = " "; SPECSFR = 0.; RA = 0.; DEC = 0.; DIST = 0.; DIST_SOURCE = " "; LOGD25 = 0.; M_B = 0.; MAG_B = 0.; INCL = 0.; PA = 0.; METAL = 0.; SFR = 0.; TYPE = 0; NOTES = " "; x = 0.; y = 0.; dx =0.; dy= 0.; vx= 0.; vy = 0.; ax= 0.; ay=0.; t = 100.; // total number of ticks to do a move tl = 100.; // number of time ticks left IMG = createImage(50, 50, ARGB); } void move() { float tix = 0.; float tiy = 0.; float ax_init =0.; float ay_init =0.; float vx_old =0.; float vy_old =0.; if (tl > 0) { if (vx != 0.) { if (((dx-x)-0.5*vx*tl) < 0. ) { tix = (2*(dx-x)+sqrt(2)*sqrt(2*sq(dx-x)-2*(dx-x)*(tl)*vx + sq(tl)*sq(vx)))/(2*vx); // this is the inflection point for the curve - where it starts to decrease in velocity } if (((dx-x)-0.5*vx*tl) >= 0. ) { tix = (2*(dx-x)-sqrt(2)*sqrt(2*sq(dx-x)-2*(dx-x)*(tl)*vx + sq(tl)*sq(vx)))/(2*vx); // this is the inflection point for the curve - where it starts to decrease in velocity } ax_init = vx/(tl - 2*tix); } if (abs(vx) < 1e-6) { ax_init = 4*(dx-x)/sq(tl); tix = tl/2.; } if (tix >= 1) { ax = ax_init; } if (tix <= 0) { ax = (-1.)*ax_init; } if ((tix > 0) && (tix < 1)) { ax = ax_init*(tix-floor(tix)) - ax_init*(floor(tix)-tix+1.); } vx_old = vx ; vx = vx + ax; x = x + (vx + vx_old)/2. ; if (vy != 0.) { if (((dy-y)-0.5*vy*tl) < 0. ) { tiy = (2*(dy-y)+sqrt(2)*sqrt(2*sq(dy-y)-2*(dy-y)*(tl)*vy + sq(tl)*sq(vy)))/(2*vy); // this is the inflection point for the curve - where it starts to decrease in velocity } if (((dy-y)-0.5*vy*tl) >= 0. ) { tiy = (2*(dy-y)-sqrt(2)*sqrt(2*sq(dy-y)-2*(dy-y)*(tl)*vy + sq(tl)*sq(vy)))/(2*vy); // this is the inflection point for the curve - where it starts to decrease in velocity } ay_init = vy/(tl - 2*tiy); } if (abs(vy) < 1e-6) { ay_init = 4*(dy-y)/sq(tl); tiy = tl/2.; } if (tiy >= 1) { ay = ay_init; } if (tiy <= 0) { ay = (-1.)*ay_init; } if ((tiy > 0) && (tiy < 1)) { ay = ay_init*(tiy-floor(tiy)) - ay_init*(floor(tiy)-tiy+1.); } vy_old = vy ; vy = vy + ay; y = y + (vy + vy_old)/2. ; tl = tl -1 ; } } void display() { image(IMG, x-IMG.width/2., y-IMG.height/2.); } } boolean overRect(float xx, float yy, float width, float height) { if (mouseX >= xx-width/2 && mouseX <= xx+width/2 && mouseY >= yy-height/2 && mouseY <= yy+height/2) { return true; } else { return false; } } void nameplot(things[] th_obj) { textFont(fontB, 18); float dmin ; int obnum; obnum = 0; dmin = 1000.; for (int j0 = 0; j0 < th_obj.length; j0++) { if (dmin > sqrt(sq(th_obj[j0].x - mouseX) + sq(th_obj[j0].y - mouseY))) { dmin = sqrt(sq(th_obj[j0].x - mouseX) + sq(th_obj[j0].y - mouseY)); obnum = j0; } } if (dmin < 30) { textAlign(CENTER, CENTER); fill(color(255,200)); text(th_obj[obnum].ID, th_obj[obnum].x, th_obj[obnum].y+40); } textFont(fontA, 18); }