1 // ========================================================================== 2 // Papercube.PaperGraphController 3 // 4 // License: PaperCube is open source software released under 5 // the MIT License (see license.js) 6 // ========================================================================== 7 8 require('core'); 9 10 /** @class 11 12 Controls the sliders used for the paper graph. 13 14 @extends NodeGraph.NodeGraphDelegate 15 @author Peter Bergstrom 16 @version 1.0 17 @copyright 2008-2009 Peter Bergström. 18 @static 19 */ 20 Papercube.paperGraphController = NodeGraph.NodeGraphDelegate.create( 21 /** @scope Papercube.paperGraphController */ { 22 23 24 /** 25 The increment value for the depth slider. 26 27 @property {Integer} 28 @default 1 29 */ 30 depthStep: 1, 31 32 /** 33 The max value for the depth slider. 34 35 @property {Integer} 36 @default 15 37 */ 38 depthValueMax: 15, 39 40 /** 41 The min value for the depth slider. 42 43 @property {Integer} 44 @default 1 45 */ 46 depthValueMin: 1, 47 48 /** 49 The value for the depth slider. 50 51 @property {Integer} 52 @default 1 53 */ 54 depth: 1, 55 56 /** 57 The default depth value. 58 59 @property {Integer} 60 @default 1 61 */ 62 defaultDepth: 1, 63 64 /** 65 The increment value for the refThreshold slider. 66 67 @property {Integer} 68 @default 1 69 */ 70 refThresholdStep: 1, 71 72 /** 73 The max value for the refThreshold slider. 74 75 @property {Integer} 76 @default 30 77 */ 78 refThresholdValueMax: 30, 79 80 /** 81 The min value for the refThreshold slider. 82 83 @property {Integer} 84 @default 0 85 */ 86 refThresholdValueMin: 0, 87 88 /** 89 The value for the refThreshold slider. 90 91 @property {Integer} 92 @default 0 93 */ 94 refThreshold: 0, 95 96 /** 97 The default refThreshold value. 98 99 @property {Integer} 100 @default 0 101 */ 102 defaultRefThreshold: 0, 103 104 /** 105 The increment value for the citeThreshold slider. 106 107 @property {Integer} 108 @default 1 109 */ 110 citeThresholdStep: 1, 111 112 /** 113 The max value for the citeThreshold slider. 114 115 @property {Integer} 116 @default 30 117 */ 118 citeThresholdValueMax: 30, 119 120 /** 121 The min value for the citeThreshold slider. 122 123 @property {Integer} 124 @default 0 125 */ 126 citeThresholdValueMin: 0, 127 128 /** 129 The value for the citeThreshold slider. 130 131 @property {Integer} 132 @default 0 133 */ 134 citeThreshold: 0, 135 136 /** 137 The default citeThreshold value. 138 139 @property {Integer} 140 @default 0 141 */ 142 defaultCiteThreshold: 0, 143 144 /** 145 Called by the NodeGraph instance when a mouseDown is triggered. 146 147 @param {DOM Event} evt The mouseDown event. 148 @param {NodeGraph.NodeGraphView} The NodeGraph view. 149 @param guid {String} The guid of the node. 150 */ 151 nodeGraphDidMouseDown: function(evt, view, guid) { 152 var type = evt.target.getAttribute('type'); 153 if(guid && type) 154 { 155 Papercube.canvasController.showFan(Event.pointerX(evt), 156 Event.pointerY(evt), 157 view.viewName, (type+"Fan")); 158 return YES; 159 } 160 return NO; 161 }, 162 163 /** 164 Allow for additional customized setup of the NodeGraph view. 165 166 @param {NodeGraph.NodeGraphView} nodeGraph The NodeGraph instance. 167 */ 168 finishInitForGraph: function(nodeGraph) { 169 Papercube.canvasController.fanForNodeGraph(nodeGraph); 170 }, 171 172 /** 173 Route to the appropriate max strength action. 174 175 @param opt {boolean} If YES, ref, if NO, cite. 176 */ 177 maxStrength: function(opt) 178 { 179 if(opt) 180 { 181 this.maxRefStrength(); 182 } 183 else 184 { 185 this.maxCiteStrength(); 186 } 187 }, 188 189 /** 190 Route to the appropriate min strength action. 191 192 @param opt {boolean} If YES, ref, if NO, cite. 193 */ 194 minStrength: function(opt) 195 { 196 197 if(opt) 198 { 199 this.minRefStrength(); 200 } 201 else 202 { 203 this.minCiteStrength(); 204 } 205 }, 206 207 /** 208 Increment the ref strength towards the maximum. 209 */ 210 211 maxRefStrength: function() 212 { 213 if(this.get('refThreshold') < this.get('refThresholdValueMax')) 214 this.set('refThreshold', this.get('refThreshold')+1); 215 }, 216 217 /** 218 Increment the ref strength towards the minimum. 219 */ 220 minRefStrength: function() 221 { 222 if(this.get('refThreshold') > this.get('refThresholdValueMin')) 223 this.set('refThreshold', this.get('refThreshold')-1); 224 }, 225 226 /** 227 Increment cite ref strength towards the maximum. 228 */ 229 230 maxCiteStrength: function() 231 { 232 if(this.get('citeThreshold') < this.get('citeThresholdValueMax')) 233 this.set('citeThreshold', this.get('citeThreshold')+1); 234 }, 235 236 /** 237 Increment cite ref strength towards the miniumum. 238 */ 239 minCiteStrength: function() 240 { 241 if(this.get('citeThreshold') > this.get('citeThresholdValueMin')) 242 this.set('citeThreshold', this.get('citeThreshold')-1); 243 }, 244 245 /** 246 Increment the depth towards the maximum. 247 Take her down! 248 */ 249 maxDepth: function() 250 { 251 if(this.get('depth') < this.get('depthValueMax')) 252 this.set('depth',this.get('depth')+1); 253 }, 254 255 /** 256 Increment the depth towards the maximum. 257 258 Rig for surface! 259 */ 260 minDepth: function() 261 { 262 if(this.get('depth') > this.get('depthValueMin')) 263 this.set('depth',this.get('depth')-1); 264 }, 265 266 /** 267 Set the default values for the controller. 268 */ 269 setDefaults: function() 270 { 271 this.set('refThreshold', this.get('defaultRefThreshold')); 272 this.set('citeThreshold', this.get('defaultCiteThreshold')); 273 this.set('depth', this.get('defaultDepth')); 274 } 275 276 277 }) ; 278