| 1 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // When switching to a Mode, all flags are put to 'false', Clients are moved and flags are reactivated |
|---|
| 3 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 4 | void basculeToMode(int m) { |
|---|
| 5 | setTypeColors() ; |
|---|
| 6 | currMode = m ; |
|---|
| 7 | if(m==0) basculeToRandomPosition() ; |
|---|
| 8 | if(m==1) basculeToLocation() ; |
|---|
| 9 | if(m==2) basculeToStats() ; |
|---|
| 10 | if(m==3) basculeToParcours() ; |
|---|
| 11 | if(m==4) basculeToGroups() ; |
|---|
| 12 | if(m==5) basculeToHorizontalWithArcs() ; |
|---|
| 13 | print("BASCULING TO MODE: "+m+"\n") ; |
|---|
| 14 | } |
|---|
| 15 | //////////////////////////////////////////////////////////// |
|---|
| 16 | void basculeToRandomPosition() |
|---|
| 17 | { |
|---|
| 18 | randomizeClientAngles() ; |
|---|
| 19 | repartClientsRandomly(myClients,width/2,centerY,width/4) ; |
|---|
| 20 | |
|---|
| 21 | deactivateAllFlags() ; |
|---|
| 22 | |
|---|
| 23 | setRepulsionToAnother(true) ; |
|---|
| 24 | setSpringsToAnchor(false) ; |
|---|
| 25 | //showTentacules = true ; |
|---|
| 26 | processPhysics = true ; |
|---|
| 27 | |
|---|
| 28 | showClientBox = true ; |
|---|
| 29 | showLinkArcs = true ; |
|---|
| 30 | showLinkCurves = true ; |
|---|
| 31 | showFlagsText = false ; |
|---|
| 32 | |
|---|
| 33 | allowDragX = true ; |
|---|
| 34 | allowDragY = true ; |
|---|
| 35 | } |
|---|
| 36 | //////////////////////////////////////////////////////////// |
|---|
| 37 | void basculeToLocation() { |
|---|
| 38 | |
|---|
| 39 | clientsLocationUtils = new LocationUtils() ; |
|---|
| 40 | clientsLocationUtils.repartClients() ; |
|---|
| 41 | |
|---|
| 42 | deactivateAllFlags() ; |
|---|
| 43 | showLocations = true ; |
|---|
| 44 | showLinkSimple = true ; |
|---|
| 45 | |
|---|
| 46 | allowDragX = true ; |
|---|
| 47 | allowDragY = true ; |
|---|
| 48 | } |
|---|
| 49 | //////////////////////////////////////////////////////////// |
|---|
| 50 | void basculeToStats() |
|---|
| 51 | { |
|---|
| 52 | //repartClientsOnCircleWithDate( myClients, cirMX, cirMY, cirMR ) ; |
|---|
| 53 | repartClientsByStats( myClients ) ; |
|---|
| 54 | |
|---|
| 55 | deactivateAllFlags() ; |
|---|
| 56 | //showNormalCircle = true ; // old : (when showing ages with concentric circles) |
|---|
| 57 | showLinkSimple = true ; |
|---|
| 58 | showStatsBackg = true ; |
|---|
| 59 | |
|---|
| 60 | allowDragX = true ; |
|---|
| 61 | allowDragY = true ; |
|---|
| 62 | } |
|---|
| 63 | //////////////////////////////////////////////////////////// |
|---|
| 64 | void basculeToHorizontalWithArcs() |
|---|
| 65 | { |
|---|
| 66 | repartClientsHorizontal( myClients, hwcYPos ) ; |
|---|
| 67 | |
|---|
| 68 | deactivateAllFlags() ; |
|---|
| 69 | |
|---|
| 70 | showLinkHalfCircles = true ; |
|---|
| 71 | showBigPreview = true ; |
|---|
| 72 | onlyRolloverText = true ; |
|---|
| 73 | |
|---|
| 74 | for(int u=0;u<nClients;u++) { |
|---|
| 75 | Client cli = getClient(u) ; |
|---|
| 76 | if(cli.connected) { |
|---|
| 77 | cli.thePNGs.loadImages() ; |
|---|
| 78 | cli.showSmallPreview = true ; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | pleaseWait = false ; |
|---|
| 82 | |
|---|
| 83 | allowDragY = false ; |
|---|
| 84 | allowDragX = true ; |
|---|
| 85 | } |
|---|
| 86 | //////////////////////////////////////////////////////////// |
|---|
| 87 | void basculeToGroups() |
|---|
| 88 | { |
|---|
| 89 | clientGraphUtils = new GraphUtils(myClients,drawnState.vConfig) ; |
|---|
| 90 | clientGraphUtils.moveClientsByGroups() ; |
|---|
| 91 | |
|---|
| 92 | deactivateAllFlags() ; |
|---|
| 93 | showLinkDirect = true ; |
|---|
| 94 | showLinkTriangles = true ; |
|---|
| 95 | |
|---|
| 96 | allowDragX = true ; |
|---|
| 97 | allowDragY = true ; |
|---|
| 98 | } |
|---|
| 99 | //////////////////////////////////////////////////////////// |
|---|
| 100 | //////////////////////////////////////////////////////////// |
|---|
| 101 | void basculeToParcours() |
|---|
| 102 | { |
|---|
| 103 | deactivateAllFlags() ; |
|---|
| 104 | |
|---|
| 105 | showEllipses = true ; |
|---|
| 106 | showLinkSimple = true ; |
|---|
| 107 | showBigPreview = true ; |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | clientGraphUtils = new GraphUtils(myClients,drawnState.vConfig) ; |
|---|
| 111 | selected = clientGraphUtils.getRandomOfBiggestGroup() ; |
|---|
| 112 | selected.buildExplorator( explDepthMAX, explDepthMAX ) ; |
|---|
| 113 | selected.thePNGs.loadImages() ; |
|---|
| 114 | selected.showPreview = true ; |
|---|
| 115 | pleaseWait = false ; |
|---|
| 116 | |
|---|
| 117 | allowDragX = true ; |
|---|
| 118 | allowDragY = true ; |
|---|
| 119 | } |
|---|
| 120 | //////////////////////////////////////////////////////////// |
|---|
| 121 | //////////////////////////////////////////////////////////// |
|---|
| 122 | //////////////////////////////////////////////////////////// |
|---|
| 123 | //////////////////////////////////////////////////////////// |
|---|
| 124 | //////////////////////////////////////////////////////////// |
|---|
| 125 | //////////////////////////////////////////////////////////// |
|---|
| 126 | //////////////////////////////////////////////////////////// |
|---|
| 127 | //////////////////////////////////////////////////////////// |
|---|
| 128 | //////////////////////////////////////////////////////////// |
|---|
| 129 | void repartClientsByStats( Vector clients ) { |
|---|
| 130 | float rv = 80 ; // random pour etaler les positions |
|---|
| 131 | float margin = stMargin ; // cf debut INIT |
|---|
| 132 | float ox = margin ; |
|---|
| 133 | float oy = height-margin ; |
|---|
| 134 | float ax = width-margin ; |
|---|
| 135 | float ay = margin ; |
|---|
| 136 | int nb = clients.size() ; |
|---|
| 137 | Client cc ; |
|---|
| 138 | for(int i=0;i<nb;i++) { |
|---|
| 139 | cc = (Client)clients.elementAt(i) ; |
|---|
| 140 | float act = cc.sActivity ; |
|---|
| 141 | float reach = cc.sReachability ; |
|---|
| 142 | float nx = ox + (ax-ox)*reach + random(-rv,rv) ; |
|---|
| 143 | float ny = ay + (oy-ay)*(1-act) + random(-rv,rv); |
|---|
| 144 | cc.moveTo( nx, ny ) ; |
|---|
| 145 | } |
|---|
| 146 | } |
|---|
| 147 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 148 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 149 | /////// Set clients position |
|---|
| 150 | void repartClientsVertical( Vector clients, float _x ) |
|---|
| 151 | { |
|---|
| 152 | float ny ; |
|---|
| 153 | float border = 100 ; |
|---|
| 154 | float ll = height - upControlZone - 2*border ; |
|---|
| 155 | float start = upControlZone + border ; |
|---|
| 156 | int nb = clients.size() ; |
|---|
| 157 | for(int i=0;i<nb;i++) { |
|---|
| 158 | ny = start + i*ll/(nb-1) ; |
|---|
| 159 | Client cc = (Client)clients.elementAt(i) ; |
|---|
| 160 | cc.moveTo( _x, ny ) ; |
|---|
| 161 | } |
|---|
| 162 | } |
|---|
| 163 | void repartClientsHorizontal( Vector clients, float _y ) |
|---|
| 164 | { |
|---|
| 165 | float nx ; |
|---|
| 166 | float border = 30 ; |
|---|
| 167 | float ll = width - 2*border ; |
|---|
| 168 | float start = border ; |
|---|
| 169 | int nb = clients.size() ; |
|---|
| 170 | for(int i=0;i<nb;i++) { |
|---|
| 171 | nx = start + i*ll/(nb-1) ; |
|---|
| 172 | Client cc = (Client)clients.elementAt(i) ; |
|---|
| 173 | cc.moveTo( nx, _y ) ; |
|---|
| 174 | } |
|---|
| 175 | } |
|---|
| 176 | //////////////////////////////////////////////////////////////////////// |
|---|
| 177 | //////////////////////////////////////////////////////////////////////// |
|---|
| 178 | //////////////////////////////////////////////////////////////////////// |
|---|
| 179 | void repartClientsOnCircleWithDate( Vector clients, float xpos, float ypos, float radius ) { |
|---|
| 180 | float nx,ny; |
|---|
| 181 | int nb = clients.size() ; |
|---|
| 182 | float realRadius ; |
|---|
| 183 | for(int i=0;i<nb;i++) { |
|---|
| 184 | Client cc = (Client)clients.elementAt(i) ; |
|---|
| 185 | int currDate = int(cc.lastDate) ; |
|---|
| 186 | realRadius = radius - cirMDateWidth* ( currDate - clientsOldestDate )/(1+clientsNewestDate-clientsOldestDate) ; |
|---|
| 187 | nx = xpos + realRadius*cos(cirMbeginAng+i*cirMapertureAng/nb) ; |
|---|
| 188 | ny = ypos + realRadius*sin(cirMbeginAng+i*cirMapertureAng/nb) ; |
|---|
| 189 | cc.moveTo( nx, ny ) ; |
|---|
| 190 | } |
|---|
| 191 | } |
|---|
| 192 | void repartClientsOnCircle( Vector clients, float xpos, float ypos, float radius ) { |
|---|
| 193 | float nx,ny; |
|---|
| 194 | int nb = clients.size() ; |
|---|
| 195 | float begAng = 2*PI/3 ; |
|---|
| 196 | for(int i=0;i<nb;i++) { |
|---|
| 197 | nx = xpos + radius*cos(cirMbeginAng+i*cirMapertureAng/nb) ; |
|---|
| 198 | ny = ypos + radius*sin(cirMbeginAng+i*cirMapertureAng/nb) ; |
|---|
| 199 | Client cc = (Client)clients.elementAt(i) ; |
|---|
| 200 | cc.moveTo( nx, ny ) ; |
|---|
| 201 | } |
|---|
| 202 | } |
|---|
| 203 | void repartClientsRandomly( Vector clients, float xpos, float ypos, float radius ) { |
|---|
| 204 | float nx,ny; |
|---|
| 205 | int nb = clients.size() ; |
|---|
| 206 | for(int i=0;i<nb;i++) { |
|---|
| 207 | nx = xpos +random(-radius,radius); |
|---|
| 208 | ny = ypos +random(-radius,radius); |
|---|
| 209 | Client cc = (Client)clients.elementAt(i) ; |
|---|
| 210 | cc.moveTo( nx, ny ) ; |
|---|
| 211 | } |
|---|
| 212 | } |
|---|
| 213 | //////////////////////////////////////////////////////////// |
|---|
| 214 | //////////////////////////////////////////////////////////// |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|