| 1 | //////////////////////////////////////////////////////////////// |
|---|
| 2 | // Keyboard and mouse events |
|---|
| 3 | //////////////////////////////////////////////////////////////// |
|---|
| 4 | void keyPressed() { |
|---|
| 5 | getOutAutoPilot() ; |
|---|
| 6 | |
|---|
| 7 | if(!contextualMenu) { |
|---|
| 8 | ////////////////////////////////////////////////// MODES |
|---|
| 9 | if(keyCode==RIGHT) { |
|---|
| 10 | highlighted = null ; |
|---|
| 11 | if(selected!=null) { |
|---|
| 12 | Vector outClients = getOutLinkedClients(selected) ; |
|---|
| 13 | if(outClients.size()!=0) { |
|---|
| 14 | selected = (Client)outClients.elementAt(int(random(outClients.size()))) ; |
|---|
| 15 | basculeToParcours() ; |
|---|
| 16 | } |
|---|
| 17 | } |
|---|
| 18 | } |
|---|
| 19 | if(keyCode==LEFT) { |
|---|
| 20 | highlighted = null ; |
|---|
| 21 | if(selected!=null) { |
|---|
| 22 | Vector inClients = getInLinkedClients(selected) ; |
|---|
| 23 | if(inClients.size()!=0) { |
|---|
| 24 | selected = (Client)inClients.elementAt(int(random(inClients.size()))) ; |
|---|
| 25 | basculeToParcours() ; |
|---|
| 26 | } |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | ////////////////////////////////////////////////// MODES |
|---|
| 30 | if(key=='<') { |
|---|
| 31 | bascNewMode=0; //basculeToMode(0) ; |
|---|
| 32 | } |
|---|
| 33 | if(key=='w') { |
|---|
| 34 | bascNewMode=1; //basculeToMode(1) ; |
|---|
| 35 | } |
|---|
| 36 | if(key=='x') { |
|---|
| 37 | bascNewMode=2; //basculeToMode(2) ; |
|---|
| 38 | } |
|---|
| 39 | if(key=='c') { |
|---|
| 40 | bascNewMode=3; //basculeToMode(3) ; |
|---|
| 41 | } |
|---|
| 42 | if(key=='v') { |
|---|
| 43 | bascNewMode=4; //basculeToMode(4) ; |
|---|
| 44 | } |
|---|
| 45 | if(key=='b') { |
|---|
| 46 | bascNewMode=5; //basculeToMode(5) ; |
|---|
| 47 | } |
|---|
| 48 | ////////////////////////////////////////////////// PHYSICS |
|---|
| 49 | if(key=='?') { |
|---|
| 50 | processPhysics=!processPhysics ; |
|---|
| 51 | } |
|---|
| 52 | if(key=='a') { |
|---|
| 53 | springsToAnchor = !springsToAnchor ; |
|---|
| 54 | setSpringsToAnchor( springsToAnchor ) ; |
|---|
| 55 | } |
|---|
| 56 | if(key=='z') { |
|---|
| 57 | repulsionToAnother = !repulsionToAnother ; |
|---|
| 58 | setRepulsionToAnother( repulsionToAnother ) ; |
|---|
| 59 | } |
|---|
| 60 | if(key=='e') { |
|---|
| 61 | springsToClients = !springsToClients ; |
|---|
| 62 | setSpringsToClients( springsToClients ) ; |
|---|
| 63 | } |
|---|
| 64 | ////////////////////////////////////////////////// |
|---|
| 65 | if(keyCode==' ') { |
|---|
| 66 | showFlagsText = !showFlagsText ; |
|---|
| 67 | } |
|---|
| 68 | if(keyCode==BACKSPACE) { |
|---|
| 69 | showFlagsText = !showFlagsText ; |
|---|
| 70 | } |
|---|
| 71 | if(key=='q') { |
|---|
| 72 | clearBackground=!clearBackground ; |
|---|
| 73 | } |
|---|
| 74 | if(key=='=') { |
|---|
| 75 | showType[0]=!showType[0] ; |
|---|
| 76 | } |
|---|
| 77 | if(key=='/') { |
|---|
| 78 | showType[1]=!showType[1] ; |
|---|
| 79 | } |
|---|
| 80 | if(key=='*') { |
|---|
| 81 | showType[2]=!showType[2] ; |
|---|
| 82 | } |
|---|
| 83 | ////////////////////////////////////////////////// |
|---|
| 84 | if(key=='1') { |
|---|
| 85 | showClientBox=!showClientBox ; |
|---|
| 86 | } |
|---|
| 87 | if(key=='3') { |
|---|
| 88 | showClientName=!showClientName ; |
|---|
| 89 | } |
|---|
| 90 | if(key=='9') { |
|---|
| 91 | showClientInfo=!showClientInfo ; |
|---|
| 92 | } |
|---|
| 93 | if(key=='2') { |
|---|
| 94 | showClientScore = !showClientScore ; |
|---|
| 95 | } |
|---|
| 96 | ////////////////////////////////////////////////// |
|---|
| 97 | if(key=='4') { |
|---|
| 98 | showLinkCurves=!showLinkCurves ; |
|---|
| 99 | } |
|---|
| 100 | if(key=='5') { |
|---|
| 101 | showLinkDirect=!showLinkDirect ; |
|---|
| 102 | } |
|---|
| 103 | if(key=='6') { |
|---|
| 104 | showLinkArcs=!showLinkArcs ; |
|---|
| 105 | } |
|---|
| 106 | if(key=='0') { |
|---|
| 107 | showLinkTriangles=!showLinkTriangles ; |
|---|
| 108 | } |
|---|
| 109 | if(key=='8') { |
|---|
| 110 | showLinkSimple=!showLinkSimple ; |
|---|
| 111 | } |
|---|
| 112 | ////////////////////////////////////////////////// |
|---|
| 113 | if(key=='r') { |
|---|
| 114 | loadFromXMLlistAutoRun = !loadFromXMLlistAutoRun ; |
|---|
| 115 | } |
|---|
| 116 | if(key=='h') { |
|---|
| 117 | displayClients = !displayClients ; |
|---|
| 118 | } |
|---|
| 119 | if(key=='t') { |
|---|
| 120 | print("Launching Live Traject\n") ; |
|---|
| 121 | deactivateAllFlags() ; |
|---|
| 122 | initTrajet() ; |
|---|
| 123 | displayTrajet = !displayTrajet ; |
|---|
| 124 | clearBackground = !displayTrajet ; |
|---|
| 125 | } |
|---|
| 126 | if(key=='i') { |
|---|
| 127 | showClientInFriends = !showClientInFriends ; |
|---|
| 128 | } |
|---|
| 129 | if(key=='o') { |
|---|
| 130 | showClientOutFriends = !showClientOutFriends ; |
|---|
| 131 | } |
|---|
| 132 | if(key=='n') { |
|---|
| 133 | onlyRolloverText = !onlyRolloverText ; |
|---|
| 134 | } |
|---|
| 135 | if(key=='l') { |
|---|
| 136 | loadXmlNow = true ; |
|---|
| 137 | } |
|---|
| 138 | if(key=='s') { |
|---|
| 139 | autoXmlLoad = !autoXmlLoad ; |
|---|
| 140 | } |
|---|
| 141 | if(key=='u') { |
|---|
| 142 | loadXmlFromSample = !loadXmlFromSample; |
|---|
| 143 | myClients = new Vector() ; |
|---|
| 144 | nClients = int(N_nClients) ; |
|---|
| 145 | nClients2 = nClients*nClients ; |
|---|
| 146 | drawnState = new State(nClients2) ; |
|---|
| 147 | loadXmlNow = true ; |
|---|
| 148 | } |
|---|
| 149 | } |
|---|
| 150 | } |
|---|
| 151 | //////////////////////////////////////////////////////////// |
|---|
| 152 | void mouseMoved(){ |
|---|
| 153 | if(highlighted!=null) { |
|---|
| 154 | if(abs(mouseX-highlighted.x()) > 20) |
|---|
| 155 | highlighted = null ; |
|---|
| 156 | } |
|---|
| 157 | getOutAutoPilot() ; |
|---|
| 158 | } |
|---|
| 159 | void mousePressed() { |
|---|
| 160 | if(mouseX>width-21 && mouseY<29 && mouseY>11) { |
|---|
| 161 | bascNewMode=(currMode+1)%6; |
|---|
| 162 | } else if(mouseX>width-21 && mouseY>height-21) { |
|---|
| 163 | showFlagsText = !showFlagsText ; |
|---|
| 164 | } else |
|---|
| 165 | if(highlighted!=null) { |
|---|
| 166 | selected=highlighted ; |
|---|
| 167 | } |
|---|
| 168 | if(loadFromXMLlist && mouseY>height-2*timeLineMargin && mouseY<height-timeLineMargin ) { |
|---|
| 169 | int fts=0 ; |
|---|
| 170 | float wtedTmS=(maxTimeStamp-minTimeStamp)/(float)width ; |
|---|
| 171 | wtedTmS=wtedTmS*(mouseX-timeLineMargin)+minTimeStamp; |
|---|
| 172 | //println(wtedTmS); |
|---|
| 173 | int u=-1; |
|---|
| 174 | while(fts<wtedTmS && u<nXmlFiles) { |
|---|
| 175 | u++; |
|---|
| 176 | fts=getTimeStampFromFileName(xmlFiles[u]) ; |
|---|
| 177 | //print("AA:"+formatTimeStamp(fts)+"\n") ; |
|---|
| 178 | } |
|---|
| 179 | currXmlListN=u; |
|---|
| 180 | print("Going to switch to file: "+xmlFiles[currXmlListN]+"\n") ; |
|---|
| 181 | loadXmlNow=true ; |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | void mouseDragged() { |
|---|
| 185 | if(highlighted!=null && mouseY>upControlZone) { |
|---|
| 186 | float newX = mouseX ; |
|---|
| 187 | float newY = mouseY ; |
|---|
| 188 | if(!allowDragX) newX = highlighted.x() ; |
|---|
| 189 | if(!allowDragY) newY = highlighted.y() ; |
|---|
| 190 | highlighted.setTo(newX,newY) ; |
|---|
| 191 | } |
|---|
| 192 | getOutAutoPilot() ; |
|---|
| 193 | } |
|---|
| 194 | void mouseReleased() { |
|---|
| 195 | if(highlighted==null && selected!=null && mouseY>upControlZone && !selected.isInContextual(mouseX,mouseY)) { |
|---|
| 196 | selected=null ; |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | ////////////////////////////////////////////////////////////////// |
|---|
| 200 | void showData(boolean theFlag) { |
|---|
| 201 | showType[0] = theFlag ; |
|---|
| 202 | } |
|---|
| 203 | void showAudio(boolean theFlag) { |
|---|
| 204 | showType[1] = theFlag ; |
|---|
| 205 | } |
|---|
| 206 | void showVideo(boolean theFlag) { |
|---|
| 207 | showType[2] = theFlag ; |
|---|
| 208 | } |
|---|
| 209 | ////////////////////////////////////////////////////////////////// |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|