import java.util.Random; import java.util.Arrays; boolean txt = false; String[]estadosNulos={ "Hesitation", "Slowness", "Nervous laughter", "Blank stare", "Lack of stimulus", "Dry mouth","Legs weakness", "Loss of appetite", "Common places","Hard concentration", "Flat feet", "Sparkle missing", "Ambition lack", "Crawling tendence", "Anaemia","Lack of charisma","Social failure", "Metereological conversation", "General clash", "Uncertain gait", "Undefinition","Blurry thought", "Vacant stare", "Short phrases", "Tiredness","Negativity","Bad sleeping","Elusive thought","Inconsistency", "Clumsiness","Flaccidity" ,"Eyestrain", "Lazy eye", "Babbling speech","Parasites"}; String[] mercados={"Dow_Jones", "IBEX_35", "EURO_STOXX_50", "IBM_US", "FTSE", "NASDAQ_COMPOSITE", "NASDAQ_100", "Nikkei_225", "Hong_Kong_Hang_Seng", "MEXBOL", "Santiago_Stock", "Buenos_Aires", "STOXX"}; String[] currencies={"Dollar_Index", "EURJPY"}; boolean empresasBol=true; boolean mercadosBol=false; boolean currBol=false; float[] data; int indexOsc = 0; float preValue; float valorActual; float cuoc; int evoIndex = 0; int numCambios; int numFrases; String salto="//"; ArrayList arrNombres; ArrayList arrValores; ArrayList arrCuoc; String[] nombresOut = new String[12]; float[] valOut = new float[12]; float[] percOut = new float[12]; boolean lee=true; String[] lines; String[] frases; String evoTxt = "//"; String[] humoresS = {"bbb", "bb", "b", "lb", "rb", "rm", "lm", "m", "mm", "mmm"}; //float[] humoresF = {10, 6,2, 1, 0.5, -0.5, -1, -2, -6, -10}; //float[] humoresF = {5, 3,1, 0.5, 0.25, -0.25, -0.5, -1, -3, -5}; float[] humoresF = {4, 2,0.75, 0.3, 0.15, -0.15, -0.3, -0.75, -2, -4}; String[] frasesVal; String[] frasesJer1, frasesJer2; ArrayList> frasesJerArr = new ArrayList> () ; ArrayList> frasesJerArrIndx = new ArrayList> () ; boolean eligeFrase = true; frase Frase; int countFrases =0; boolean fillArr = false; String[][] bloquesLineas; ArrayList> bloquesLineasArrL; ArrayList> frasesSec=new ArrayList>(); ArrayList frasesPrinc=new ArrayList(); ArrayList> frasesSecVal=new ArrayList>(); ArrayList pausasArr=new ArrayList(); ArrayList Frases=new ArrayList(); int posYfrasePrev; ArrayList posYfrases = new ArrayList(); int guardaFr = 0; int elecFraseTitular; int margen = 50; String nuli = "null"; ArrayList humoresPr = new ArrayList(); String NomElect; float valElect; float cuocElect; boolean cambio=false; boolean inicioBool = true; boolean llenadoInit=false; int indexLlenado=0; int indexFrInit = 0; int posIniY = 100; cronometro crona; crono tempo; int posX;// = 110; int anchoCaja=100; int altoCaja =30; int anchTr = 15; int initY=100; int poSXT; boolean parpadea = false; int colorFondo = 0; int alfa = 255; int evoInit; int horaX= 20; int randInit; int evos = 0; int minEll = 10; int eleccionPrincipal; boolean elecPr = true; color rojo = color(238, 39, 91); color verde = color(47, 194, 178); color azul= color(0, 0, 255); int sizeFont1= 15; int sizeFont2= 16; int sizeFont3=20; int sizeFont4=12; int sizeFontVal = 13; int sizeFont5 = 18; int margenPag = 40; int posR1X; int posR1Y; int anchoRect2; int altoRect2 = 70; int posTxtYB1; int posTxtR2; int posCajasX; int margenRecuad=10; int translateB1Y = 50;//50 int translateB2Y = 100;//50 int translateB3Y = 100;//50 int translateB4Y = 150;//50 String titulo ="INCOME MOOD"; String subtit1 ="FIELD OF REFLECTION"; String subtit2 ="SYMPTOMS"; String subtit3 = "RELATED INFLUXES"; String subtit4 = "INFLUENCED THOUGHT"; String subtit5 = "Variations Detected"; int estGraph = 12; float[][] valGraph; int evGraph=0; boolean variations; String[] _valTxt; int _x,_x2,xAnt; String pieV=""; concha conchi, conchita; color[] colores = {#E1DD8F, #E0777D, #4C86A8, #A4031F, #ABC4AB, #DAEDBD, #7DBBC3, #FFFBFF, #BD4F6C, #939F5C}; ArrayList conchas = new ArrayList(); ArrayList conchasInicio = new ArrayList(); ArrayList FrasePrincipal=new ArrayList(); String strValue=""; String[] linesUrl; int evoCron; int topEvoCron = 25; int timeResid; int tempCarencial = 4500; String fr; String lectura = "data/lectura_02.txt"; String valoresTxt = "data/backup_valores/valores.txt"; String valoresUlt = "data/valoresUltimos.txt"; boolean timeReadMin; ArrayList distr; int globalIndexFr=-1; String mrkt="Market"; String IBX = "IBEX 35"; PFont dinM, verd, dinMAlt,frutIt,frutB,frutBit; boolean overbooking; indEmpr=0; int topeItems=5; color wh = color(255); void setup(){ console.log("processing.code.index.php"); size(w, h); smooth(); frameRate(24); background(colorFondo); //fonts dinM=createFont("dinM",25); verd=createFont("verd",25); dinMAlt= createFont("dinMAlt",25); frutIt=createFont("frutIt",25); frutB=createFont("frutB",25); frutBit=createFont("frutBit",25); arrNombres = new ArrayList(); arrValores = new ArrayList(); arrCuoc= new ArrayList(); for (int i =0; i <2; i++) { frasesJerArr.add(new ArrayList()); frasesJerArrIndx.add(new ArrayList()); } //setNumIt(); organizaFrases(); String[] valoresInicio = loadStrings(valoresUlt); if (valoresInicio.length > 0)data = float(split(valoresInicio[0], ',')); for (int i =0; i0)recorreEmpresas(indEmpr); } void chCss(){ if(!variations){ document.getElementById("reflection").style.fontSize="2.5em"; document.getElementById("thoughtContent").style.fontSize="2em"; if(mob && portrait)document.getElementById("lecturaMain").style.paddingLeft="0px"; //lecturaMain //document.getElementsByClassName("cajaNega").style.width="auto"; }else{ document.getElementById("reflection").style.fontSize="5.5em"; document.getElementById("thoughtContent").style.fontSize="4em"; } } String[] divEmpresas(String _emp){ String[] _temp=new String[]; _temp=split(_emp,'/'); return _temp; } void chequeaPos(int _x, int _y) { fill(255, 130, 0); rect(_x, _y, 4, 4); } boolean purga(float[] _valoresArr) { int suma = 0; boolean negativ=true; for (int i = 0; i<_valoresArr.length; i++) { float valorArr = _valoresArr[i]; suma = int(suma+valorArr); if (i==(_valoresArr.length)-1&&suma!=0)negativ=false; } return negativ; } void evo() { numCambios = 0; limpiaArrLists(); } int _evTiempTxt=1; void evoluciones() { //console.log("evoluciones"); destroyInfluxes(); if(getData){ //console.log("evoluciones.rastreos: "+rastreos); conchas.clear(); if(rastreos!=null)distribuyeVal(rastreos,cuenta,valores); else distribuyeVal(preRastreos,cuenta,valores); getData=false; } } void hora(int _posX, int _posY) { int s = second(); // 0 - 59 int m = minute(); // 0 - 59 int h = hour(); // 0 - 23 String sStr=s+""; String mStr=m+""; String hStr=h+""; if (sStr.length()<2)sStr="0"+sStr; if (mStr.length()<2)mStr="0"+mStr; if (hStr.length()<2)hStr="0"+hStr; String laHora = ""; int tiempoActM = tiempoActualM(hour(), minute(), second()); laHora = hStr+" : "+mStr+" : "+ sStr; pushMatrix(); textAlign(RIGHT, BOTTOM); textSize(sizeFont3); text(laHora, _posX, _posY); popMatrix(); } String extraeHumor(float _cuocFr) { String cuocS =""; float _prepreVal = 10.0; if (_cuocFr>humoresF[0])cuocS=humoresS[0]; else if (_cuocFr0 && _cuocFr < humoresF[4])cuocS=humoresS[4]; else if (_cuocFr<0 && _cuocFr < humoresF[6])cuocS=humoresS[6]; else { for (int itt=0; itthumoresF[itt]) { cuocS=humoresS[itt]; } _prepreVal=humoresF[itt]; } } return cuocS; } void inicio() { if (inicioBool) { inicioCss(); if(conchitaBool){ conchasInicio.clear(); int posY =0; if(/*mob && */ portrait)posY=h-100; else posY=(h/3)*2; conchita = new concha(w/2, posY, conchSize, 0, wh, 0); conchasInicio.add(conchita); } evoInit++; tempo.parpad(); if (tempo._end()) { tempo.reinit(); randInit = int(random(0, estadosNulos.length)); } estadoNUll = estadosNulos[randInit]; parpadeo(alfa, evoInit); document.getElementById("symptomContent").innerHTML = estadoNUll; textSize(sizeFontVal);//35 //valoresNull conchitaBool=false; }else{ inicioElseCss(); } } int parpadeo(int _alfa, int _evo) { if (parpadea) { if (_evo >4)_alfa=0; else alfa=255; if (_evo>8)evoInit=0; randInit = int(random(0, estadosNulos.length)); alfa=255; } return _alfa; } void lecturaTxtVal() { _valTxt = loadStrings(lectura); boolean negativo = purga(valores); } float cuociente(float _valor, float _preV) { float porcV = (_valor/100)*(abs(_valor-_preV)); if ((_valor - _preV)<0)porcV = -porcV; return porcV; } float[] compara(int _ind, float _val) { float[] _temp = new float[2]; if (preValores[_ind]!=_val) { _temp[0]=_val; _temp[1]=float(_ind); } return _temp; } void llenaArrays(float _cuoc,float _value, String _nombre,boolean _fin){ // console.log("llenaArrays._nombre: "+_nombre+", value: "+_value+", _cuoc: "+_cuoc+", _fin: "+_fin); if(!_fin){ if(_cuoc!=0.000 && cuoc!=100.000){ cambio = true; if(_nombre!=null){ arrNombres.add(_nombre); } if(_value!=0.0)arrValores.add(_value); arrCuoc.add(_cuoc); } if (arrNombres.size()>0) { eleccion(); } } } void distribuyeVal(String _linea, int _cuenta,_valores) { limpiaArrLists(); String[] lecturas = split(_linea, '/'); int _ind=0; for(int i=0; i -maxCambio){ _ind++; if(_ind=estGraph)evGraph=0; String[] chain = split(_str,_cut); for(int i =0; i0){ var _r=_rand[i]; Frases.add(new frase(arrNombres.get(_r),arrValores.get(_r),arrCuoc.get(_r), Frases.size(),_eleccion)); variations = true; inicioBool = false; }else{ } } } } void pintaFrases(){ //console.log("pintaFrases.Frases.size(): "+Frases.size()); if(Frases.size()>3)overbooking=true; else overbooking=false; if(Frases.size()==0){ variations = false; inicioBool = true; }else{ variations = true; inicioBool = false; } for (int i = 0; i0){ for(int i =0;i 1; i--) { int j = int(random(0,i)); // 0 <= j <= i-1 (0-based array) int tmp = array[j]; array[j] = array[i-1]; array[i-1] = tmp; } } void limpiaArrLists() { elecPr=true; arrNombres.clear(); arrValores.clear(); arrCuoc.clear(); Frases.clear(); FrasePrincipal.clear(); Frases.clear(); posYfrases.clear(); conchas.clear(); } void limpiaArrFrases() { Frases.clear(); posYfrases.clear(); conchas.clear(); } void recorreArrays(ArrayList _arr) { for (int i =0; i<_arr.size(); i++) { println(_arr.get(i)); } } String abc =" .,'aáAÁbBcCdDeéEÉfFgGhHiíIÍjJkKlLmMnNñPÑoóOÓpPqqrRsStTuúüUÚvVwWxXyYzZ¡?!¿*-"; class changeChar { int l1; int l2; int residu; int iter=0; int __letPos; int distL = 15; int _posX,_posY; changeChar(char _ch1, char _ch2, int _letPos, int _px,int _py) { _posX = _px; _posY = _py; for (int i =0; i chChArr = new ArrayList(); int _px,_py; String _palabra=""; changeText() { } String evoDiv(String _t1, String _t2){ char[] _chars1 = _t1.toCharArray(); char[] _chars2 = _t2.toCharArray(); int lettPos = 0; int numLett = 0; if(_chars1.length <_chars2.length)numLett =_chars2.length; else if(_chars2.length <_chars1.length)numLett =_chars1.length; else numLett = _chars1.length; if (_toArr){ for(int i =0; i<=numLett;i++){ toArr(chChArr, i, _t1, _t2); } } _toArr = false; _palabra=""; for (int i =0; i _chChArr, int _lettPos, String __t1, String __t2){ if(_lettPos <__t1.toCharArray().length && _lettPos < __t2.toCharArray().length){ _chChArr.add(new changeChar(__t1.toCharArray()[_lettPos], __t2.toCharArray()[_lettPos],_lettPos,_px,_py)); }else if(_lettPos <__t1.toCharArray().length && _lettPos >= __t2.toCharArray().length){ _chChArr.add(new changeChar(__t1.toCharArray()[_lettPos], ' ',_lettPos,_px,_py)); }else if(_lettPos >=__t1.toCharArray().length && _lettPos < __t2.toCharArray().length){ _chChArr.add(new changeChar(' ', __t2.toCharArray()[_lettPos],_lettPos,_px,_py)); } } } class concha{ int x,y; float move,wh,cuoqui; color col; float rad1=0; float rad2=0; int cambio; concha(int _x,int _y,float _wh,float _cuoc, color _col, int _numCamb){ x = _x; y = _y; wh = _wh; col = _col; cuoqui=_cuoc; cambio = _numCamb+1; } void evoluciona(float _st, float _stp){ float _stt ,_stpp; int mult = 10; if(cuoqui>=0) move +=radians(10); else move -=radians(10); _stt=_st; _stpp=((PI*2)/100)*_stp; pushMatrix(); noStroke(); fill (col); rad2=_stp; rad1=_st+move; arc(x, y, wh,wh, _st+move+(radians(cambio)), _stp+move+(radians(cambio)),PIE); popMatrix(); fill(255); } } class crono{ int time; int wait = 0; boolean end = false; int tiempo; int tiempoParpad; boolean inicial; crono(int _duracion, boolean _inicial){ time = millis();//store the current time wait = _duracion; inicial = _inicial; tiempoParpad = _duracion-1500; } boolean _end(){ int m = millis(); if(millis() - time >= wait){ end = true; time = millis();//also update the stored time } return end; } void parpad(){ if((millis() - time) >= (wait-tiempoParpad)){ parpadea=true; } } void reinit(){ if (inicial){ parpadea=false; } end = false; } } class cronometro{ int duracion; int tiempoActual; boolean inicio = false; int tiempoInicio; cronometro(int _duracion){ duracion=_duracion; } void init(boolean _init){ if(_init){ inicio = true; tiempoInicio=millis(); } } boolean func(){ boolean func; tiempoActual = millis(); if(tiempoActual-tiempoInicio>=duracion){ func=false; }else func = true; return func; } void reinit(boolean _again){ if(_again)init(true); } } class frase { String nombreFr; float valueFr, cuocFr; int numCamb; String _frase=""; String preNombre =""; boolean principal; int indexFr; int altoLinea = 10; int posXtr=posX+325; int posFraseX = int(width/3.3)+50; boolean positivo = false; String cuocFrStr = ""; int altoBl3l = 80; int altoBl2l = 40; int posY; int finTxt =((width/4)*3)+posX+100;// (width/2)+posX;//(width/3)*2;//width-posX; int cajaTxtAnch=(finTxt-posX)-posR1X-50;//(width/2)-margenPag; int desplY = 25; concha conchi; int mult=25; String frasePrinc =""; String _nuli = " NULL";// THOUGHT"; changeText chTx ; int elecNull = -1; float cuocNull=-0.0; String frPre=""; String hum; //vius! frase(String _nombre, float _value, float _cuoc, int _numCamb, int _indexFr){ indexFr = _indexFr; countFrases++; nombreFr = _nombre; valueFr = _value; //console.log("Frase.cuoc: "+_cuoc); cuocFr = _cuoc; numCamb = _numCamb; hum = extraeHumor(_cuoc); eligePrinc(_indexFr,_cuoc, _numCamb, _nombre,_value, hum); crona.init(true); color Col = colores[int(random(0, colores.length))]; //vius! //mult debería ser un valor mapeado //cuanto más pequeño el valor, la proporción debería ser algo mayor, para que las conchas con valores negativos no sean tan peques conchi = new concha(w/2, (h/3)*2, (_value*mult), _cuoc, Col, _numCamb); conchas.add(conchi); chTx = new changeText(); } void pinta() { pintaValores(_frase,indexFr,cuocFr,nombreFr,numCamb,valueFr,hum); } void pintaValpr(String _nom, float _val, float _cuoc, int _trX, int _trY) { //console.log("pintaValpr._nom: "+_nom); cuocFrStr =nf(_cuoc, 1,3); String _escritura=_nom+" "; int mrg = 5; pushMatrix(); translate(_trX, _trY); textAlign(LEFT); fill(255); textSize(sizeFontVal); float posText = textWidth(_escritura)+textWidth(_val+" ")+20; int trX = 90; pushMatrix(); translate(0, translateB1Y); console.log("_cuoc: "+_cuoc); if ((_cuoc)>0) { positivo = true; document.getElementById("perc").style.backgroundColor="#2FC2B2"; } else { positivo = false; document.getElementById("perc").style.backgroundColor="#EE275B"; } popMatrix(); fill(255); document.getElementById("valor").style.color="#EE275B"; document.getElementById("empresa").innerHTML=_escritura; pushMatrix(); if (positivo){ document.getElementById("valor").style.color="#2FC2B2"; fill(verde); } else { document.getElementById("valor").style.color="#EE275B"; fill(rojo); } document.getElementById("valor").innerHTML=_val+" "; popMatrix(); fill(255); String _fraseCuoc=cuocFrStr+" %"; //console.log(".innerHTML.fraseCuoc: "+_fraseCuoc); document.getElementById("val").innerHTML=_fraseCuoc; } String eligePrinc(int _indFr, float _cuoci,int _nCamb, String _n, float _v, String _h){ String _frPr=""; String _tempHum = _h; _v=_v.toFixed(2); _cuoci=_cuoci.toFixed(2); if(_nCamb==0){ ArrayList _tempIntArr = new ArrayList(); for(int i = 0; i0){ _tempIntArr.add(i); } } if(_tempIntArr.size ()>0){ int _tempFrPrInt=int(round(random(0,_tempIntArr.size()-1))); int _elec=_tempIntArr.get(_tempFrPrInt); frasePrinc=frasesPrinc.get(_elec); globalIndexFr = _elec; _frase = eligeFrase(globalIndexFr,cuocFr,_tempHum, _n, _v); }else { frasePrinc="Random thought: "+frasesPrinc.get(int(random(0,frasesPrinc.size()))); _frase = eligeFrase(elecNull, cuocNull,_tempHum,_n, _v); } }else{ //console.log("numCamb != 0"); if(globalIndexFr!= -1){ _frase = eligeFrase(globalIndexFr,cuocFr,_tempHum,_n, _v); } else eligeFrase(elecNull, cuocNull, _tempHum, _n , _v); } return _frPr; } String eligeFrase(int _index, float _cuocF, String _humor,String _nombreFr, float _valueFr) { String _fraseEl = ""; if(_index==elecNull && _cuocF == cuocNull){ _fraseEl=_nuli; }else{ ArrayList _tempStr = new ArrayList(); ArrayList _tempIntArr = new ArrayList(); for (int i =0; i0){ _tempIntArr.add(i); } } if(_tempIntArr.size()>0){ int _tempFrSInt=int((random(0,_tempIntArr.size()-1))); _fraseEl=frasesSec.get(_index).get(_tempIntArr.get(_tempFrSInt)); }else _fraseEl=_nuli; } return _fraseEl; } void pintaValores(String __frase, int _ind, float _percen, String _nombre, int _camb, float _v, String _h) { _percen = _percen.toFixed(2); if (!inicioBool){ String escritura =_nombre+" "; int lineaH = 40; console.log("pintaValores._camb: "+_camb); if (_camb<1) { textSize(sizeFont1); fill(255); pintaValpr(_nombre, _v, _percen, posR1X+10, 0); document.getElementById("reflection").innerHTML=frasePrinc; } pushMatrix(); translate(0, translateB3Y+50); //frases textSize(sizeFont4); pushMatrix(); if (_camb<1) { document.getElementById("thoughtContent").innerHTML=__frase; } else { if(posYfrases.size()>0){ textSize(sizeFont4); String _tempHum = _h; if(__frase=="")__frase=nuli; String stDiv = chTx.evoSimple("",__frase); if(_camb>0)influxDivs(_camb,stDiv,_nombre ,_v ,_percen); } } posYfrasePrev = posY+lineaH; if (posYfrases.size() > Frases.size())posYfrases.remove(Frases.size()); posYfrases.add(posYfrasePrev); popMatrix();//4 popMatrix();//2 textFont(verd); } } boolean[] cheqTextPos(String _text, int _posInit, int _tSize, int _limite) { boolean dobleL; boolean tripleL; pushMatrix(); textSize(_tSize); int _textW = int(textWidth(_text)); popMatrix(); int _PX=_posInit; int result = _textW + _posInit-20; if (result>_limite)dobleL = true; else dobleL = false; if (result-cajaTxtAnch > _limite)tripleL = true; else tripleL = false; boolean[]_bs =new boolean[2]; _bs[0]=dobleL; _bs[1]=tripleL; return _bs; } } void distribuyeLineas(){ int count = -1; int pausas=0; String preLectura=""; bloquesLineasArrL = new ArrayList>(); for(int i = 0; i()); } if(!lecturas[0].startsWith(evoTxt))bloquesLineasArrL.get(count).add(lectura); preLectura = lecturas[0]; } } void organizaFrases() { //String narrativa = "data/narrativa_06.txt"; String narrativa = "data/narrative.txt"; frases = loadStrings(narrativa); int index = -1; int indxPr = 0; int indxSec = 0; for (int i=0; i()); frasesSecVal.add(new ArrayList()); humoresPr.add(_frSpl[0]); frasesPrinc.add(_frSpl[1]); indxPr++; } else { indxSec++; float indxFl = float(indxPr+"."+indxSec); frasesJerArr.get(1).add((""+indxFl)); frasesJerArrIndx.get(1).add(i); frasesSec.get(index).add(_frSpl[1]); frasesSecVal.get(index).add(_frSpl[0]); } } frasesJer1 = new String[frasesJerArr.get(0).size()]; frasesJer2 = new String[frasesJerArr.get(1).size()]; for (int it =0; it distrFunct(String[] _stArr ){ ArrayList _temp = new ArrayList(); for(int i=1;i<_stArr.length;i++){ String _temp2=_stArr[i]; if(!_temp2.equals("") && (_temp2.toCharArray()[2] == ':'))_temp.add(tiempoConv(_stArr[i])+"/"+i);//tiempoConv(_stArr[i]) } return _temp; }