social_cheesecake 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/kinetic.js +1710 -1081
- data/app/assets/javascripts/socialcheesecake/_header.js +2 -3
- data/app/assets/javascripts/socialcheesecake/actor.js +30 -20
- data/app/assets/javascripts/socialcheesecake/cheesecake.js +118 -72
- data/app/assets/javascripts/socialcheesecake/eventCallbackHandlers.js +14 -5
- data/app/assets/javascripts/socialcheesecake/grid.js +35 -10
- data/app/assets/javascripts/socialcheesecake/search.js +12 -20
- data/app/assets/javascripts/socialcheesecake/sector.js +93 -71
- data/app/assets/javascripts/socialcheesecake/subsector.js +16 -2
- data/app/assets/javascripts/socialcheesecake/text.js +13 -0
- data/lib/social_cheesecake/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/main.js +36 -4
- data/test/dummy/app/assets/stylesheets/style.css +9 -0
- metadata +4 -4
@@ -56,8 +56,9 @@ var socialCheesecake = socialCheesecake || {};
|
|
56
56
|
mouseout : function() {
|
57
57
|
document.body.style.cursor = "default";
|
58
58
|
},
|
59
|
-
click : function() {
|
60
|
-
|
59
|
+
click : function(sector) {
|
60
|
+
sector.changeProperty("label","");
|
61
|
+
sector.getCheesecake().unfocusAndUnblurCheesecake();
|
61
62
|
},
|
62
63
|
mouseup : function() {
|
63
64
|
return;
|
@@ -70,13 +71,13 @@ var socialCheesecake = socialCheesecake || {};
|
|
70
71
|
mouseover : function(subsector) {
|
71
72
|
var cheesecake = subsector.getCheesecake();
|
72
73
|
document.body.style.cursor = "pointer";
|
73
|
-
|
74
|
+
cheesecake.grid.focus(subsector.actors);
|
74
75
|
cheesecake.setHighlightedSector(subsector);
|
75
76
|
},
|
76
77
|
mouseout : function(subsector) {
|
77
78
|
var cheesecake = subsector.getCheesecake();
|
78
79
|
document.body.style.cursor = "default";
|
79
|
-
|
80
|
+
cheesecake.grid.unfocus(subsector.actors);
|
80
81
|
cheesecake.setHighlightedSector(subsector.parent);
|
81
82
|
},
|
82
83
|
click : function(subsector) {
|
@@ -111,6 +112,14 @@ var socialCheesecake = socialCheesecake || {};
|
|
111
112
|
mouseup : function() {
|
112
113
|
return;
|
113
114
|
}
|
114
|
-
}
|
115
|
+
},
|
116
|
+
onSectorHighlight : null,
|
117
|
+
onSubsectorAddedBegin : null,
|
118
|
+
onSubsectorAddedEnd : null,
|
119
|
+
onSectorFocusBegin : null,
|
120
|
+
onSectorFocusEnd : null,
|
121
|
+
onSectorUnfocusBegin : null,
|
122
|
+
onSectorUnfocusEnd : null,
|
123
|
+
onChange : null
|
115
124
|
}
|
116
125
|
})();
|
@@ -7,21 +7,23 @@ var socialCheesecake = socialCheesecake || {};
|
|
7
7
|
|
8
8
|
//Actors dimensions and positions
|
9
9
|
this.actors = [];
|
10
|
+
this.orphans = [];
|
10
11
|
this.parent = settings.parent;
|
11
12
|
this.id = settings.grid_id;
|
12
13
|
this.divIdPrefix = settings.divIdPrefix;
|
13
|
-
|
14
|
-
|
14
|
+
this.maxOpacity = settings.maxOpacity;
|
15
|
+
this.minOpacity = settings.minOpacity;
|
15
16
|
}
|
16
17
|
|
17
|
-
socialCheesecake.Grid.prototype.addActor = function(
|
18
|
+
socialCheesecake.Grid.prototype.addActor = function(actorInfo, subsector) {
|
18
19
|
var actors = this.actors;
|
19
|
-
var
|
20
|
+
var orphans = this.orphans;
|
21
|
+
var actor = null;
|
20
22
|
|
21
23
|
//Check if the actor is already in the array
|
22
24
|
var actorAlreadyDeclared = false;
|
23
25
|
for(var i in actors) {
|
24
|
-
if(actors[i].id ==
|
26
|
+
if(actors[i].id == actorInfo.id) {
|
25
27
|
actorAlreadyDeclared = true;
|
26
28
|
actor = actors[i];
|
27
29
|
//Check if the subsector has already been declared a parent of the actor
|
@@ -34,10 +36,25 @@ var socialCheesecake = socialCheesecake || {};
|
|
34
36
|
actor.parents.push(subsector);
|
35
37
|
}
|
36
38
|
}
|
37
|
-
// If the actor was not in the array
|
39
|
+
// If the actor was not in the array:
|
38
40
|
if(!actorAlreadyDeclared) {
|
39
|
-
|
40
|
-
|
41
|
+
//Check if the actor exists as an orphan (with no subsectors parents)
|
42
|
+
var orphanActor = false;
|
43
|
+
for(var i in orphans){
|
44
|
+
//If it exists, take it out from this array and add its new parent
|
45
|
+
if(orphans[i].id == actorInfo.id){
|
46
|
+
orphanActor = true;
|
47
|
+
actor = orphans[i];
|
48
|
+
orphans.splice(i, 1);
|
49
|
+
actor.removeClass("orphan");
|
50
|
+
actor.parents.push(subsector);
|
51
|
+
}
|
52
|
+
}//If it doesn't, create new Actor and add its parent.
|
53
|
+
if(!orphanActor){
|
54
|
+
actorInfo.parent = subsector;
|
55
|
+
actorInfo.grid = this;
|
56
|
+
actor = new socialCheesecake.Actor(actorInfo);
|
57
|
+
}
|
41
58
|
actors.push(actor);
|
42
59
|
}
|
43
60
|
return actor;
|
@@ -45,9 +62,12 @@ var socialCheesecake = socialCheesecake || {};
|
|
45
62
|
|
46
63
|
socialCheesecake.Grid.prototype.removeActor = function(actor) {
|
47
64
|
var actors = this.actors;
|
65
|
+
var orphans = this.orphans;
|
48
66
|
for(var actorIndex in actors) {
|
49
|
-
if((actors[actorIndex].id == actor.id) && (actor.
|
67
|
+
if((actors[actorIndex].id == actor.id) && (actor.isOrphan())) {
|
50
68
|
actors.splice(actorIndex, 1);
|
69
|
+
orphans.push(actor);
|
70
|
+
actor.addClass("orphan");
|
51
71
|
}
|
52
72
|
}
|
53
73
|
}
|
@@ -64,11 +84,16 @@ var socialCheesecake = socialCheesecake || {};
|
|
64
84
|
|
65
85
|
socialCheesecake.Grid.prototype.getSelectedActors = function() {
|
66
86
|
var actors = this.actors;
|
87
|
+
var orphans = this.orphans;
|
67
88
|
var selectedActors = [];
|
68
89
|
for(var i in actors) {
|
69
|
-
if(actors[i]
|
90
|
+
if(actors[i].isSelected())
|
70
91
|
selectedActors.push(actors[i]);
|
71
92
|
}
|
93
|
+
for (var i in orphans){
|
94
|
+
if(orphans[i].isSelected())
|
95
|
+
selectedActors.push(orphans[i]);
|
96
|
+
}
|
72
97
|
return selectedActors;
|
73
98
|
}
|
74
99
|
|
@@ -1,26 +1,18 @@
|
|
1
1
|
var socialCheesecake = socialCheesecake || {};
|
2
2
|
(function() {
|
3
|
-
socialCheesecake.SearchEngine =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
} else {
|
16
|
-
actor.filter();
|
3
|
+
socialCheesecake.SearchEngine = {
|
4
|
+
filter : function(pattern, actors) {
|
5
|
+
var actors = actors;
|
6
|
+
var patt = new RegExp(pattern.toLowerCase());
|
7
|
+
|
8
|
+
for(var i in actors) {
|
9
|
+
var actor = actors[i];
|
10
|
+
if(actor.name.toLowerCase().match(patt)) {
|
11
|
+
actor.unfilter();
|
12
|
+
} else {
|
13
|
+
actor.filter();
|
14
|
+
}
|
17
15
|
}
|
18
16
|
}
|
19
|
-
|
20
|
-
if(this.parent.highlightedSector) {
|
21
|
-
this.parent.grid.fadeIn(this.parent.highlightedSector.actors, 100, true);
|
22
|
-
} else {
|
23
|
-
this.parent.grid.fadeIn(this.parent.grid.actors, 100, true);
|
24
|
-
}
|
25
17
|
}
|
26
18
|
})();
|
@@ -24,10 +24,10 @@ var socialCheesecake = socialCheesecake || {};
|
|
24
24
|
while(settings.phi <0){
|
25
25
|
settings.phi += 2*Math.PI;
|
26
26
|
}
|
27
|
-
|
27
|
+
// Possible exceptions
|
28
|
+
if(settings.delta <= 0 || settings.delta > 2 * Math.PI)
|
28
29
|
throw "Delta must be greater than 0 and less than 2*pi";
|
29
|
-
|
30
|
-
if(settings.id) this.id = settings.id;
|
30
|
+
if(settings.id != undefined) this.id = settings.id;
|
31
31
|
this.x = settings.center.x;
|
32
32
|
this.y = settings.center.y;
|
33
33
|
this.rOut = settings.rOut;
|
@@ -86,6 +86,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
86
86
|
|
87
87
|
this._region = null;
|
88
88
|
}
|
89
|
+
//ID beginning fot the new subsectors created by the user.
|
90
|
+
socialCheesecake.Sector.newSubsectorIdRoot = "new_";
|
89
91
|
|
90
92
|
socialCheesecake.Sector.prototype._draw = function(context) {
|
91
93
|
var x = this.x;
|
@@ -94,11 +96,13 @@ var socialCheesecake = socialCheesecake || {};
|
|
94
96
|
var delta = this.delta;
|
95
97
|
var rIn = this.rIn;
|
96
98
|
var rOut = this.rOut;
|
97
|
-
var color = this.color;
|
99
|
+
var color = this.color || socialCheesecake.colors[type]["background"];
|
98
100
|
var label = this.label;
|
99
101
|
var actors = this.actors;
|
100
102
|
var type = this.type;
|
101
103
|
var fontColor = this.fontColor || socialCheesecake.colors[type]["font"];
|
104
|
+
var rLabel = 0.7*(rOut-rIn) + rIn;
|
105
|
+
var rNumber = rLabel;
|
102
106
|
|
103
107
|
context.restore();
|
104
108
|
context.save();
|
@@ -112,28 +116,35 @@ var socialCheesecake = socialCheesecake || {};
|
|
112
116
|
context.lineWidth = 2;
|
113
117
|
context.strokeStyle = this.borderColor || socialCheesecake.colors[type]["border"];
|
114
118
|
context.stroke();
|
119
|
+
|
120
|
+
//Write on them
|
115
121
|
if((this.auxiliar)&&(label=="+")){
|
116
122
|
socialCheesecake.text.addPlusCharacter(context, x, y, 0.5*(rOut-rIn) + rIn,
|
117
123
|
phi, delta, fontColor);
|
118
124
|
}else if((this.parent.auxiliar)&&(this.parent.label=="+")){
|
119
|
-
socialCheesecake.text.writeCurvedText(label, context, x, y,
|
125
|
+
socialCheesecake.text.writeCurvedText(label, context, x, y, rLabel,
|
120
126
|
phi, delta, fontColor, "newStyle");
|
121
127
|
}else{
|
122
|
-
socialCheesecake.text.writeCurvedText(label, context, x, y,
|
128
|
+
socialCheesecake.text.writeCurvedText(label, context, x, y, rLabel,
|
123
129
|
phi, delta, fontColor);
|
124
130
|
}
|
125
|
-
if(!this.auxiliar)
|
131
|
+
if(!this.auxiliar){
|
132
|
+
rNumber -= socialCheesecake.text.getTextHeight(label);
|
126
133
|
socialCheesecake.text.writeCurvedText("(" + actors.length + ")", context, x, y,
|
127
|
-
|
134
|
+
rNumber, phi, delta, fontColor);
|
135
|
+
}
|
128
136
|
}
|
129
137
|
|
130
138
|
socialCheesecake.Sector.prototype.getRegion = function() {
|
131
139
|
if(this._region == null) {
|
132
140
|
var sector = this;
|
133
|
-
sector._region = new Kinetic.
|
134
|
-
|
135
|
-
|
136
|
-
|
141
|
+
sector._region = new Kinetic.Geometry({
|
142
|
+
drawFunc : function() {
|
143
|
+
var context = this.getContext();
|
144
|
+
sector._draw(context);
|
145
|
+
},
|
146
|
+
name : sector.label
|
147
|
+
});
|
137
148
|
sector._region.on('mouseover', function() {
|
138
149
|
sector.eventHandler('mouseover');
|
139
150
|
});
|
@@ -150,6 +161,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
150
161
|
return this._region
|
151
162
|
}
|
152
163
|
|
164
|
+
socialCheesecake.Sector.prototype.getLayer = function(){
|
165
|
+
if(this.getRegion().getParent()) return this.getRegion().getLayer(); /*KINETIC FIX*/
|
166
|
+
return undefined;
|
167
|
+
}
|
168
|
+
|
153
169
|
socialCheesecake.Sector.prototype.eventHandler = function(eventName) {
|
154
170
|
this.colorHandler(eventName);
|
155
171
|
this.callbackHandler(eventName);
|
@@ -180,6 +196,18 @@ var socialCheesecake = socialCheesecake || {};
|
|
180
196
|
socialCheesecake.Sector.prototype.getCheesecake = function () {
|
181
197
|
return this.parent;
|
182
198
|
}
|
199
|
+
/*
|
200
|
+
* Returns the sector's index IN CHEESECAKE
|
201
|
+
*/
|
202
|
+
socialCheesecake.Sector.prototype.getIndex = function(){
|
203
|
+
var sector = this;
|
204
|
+
var cheesecake = sector.getCheesecake();
|
205
|
+
var index = null;
|
206
|
+
for(var i in cheesecake.sectors){
|
207
|
+
if(cheesecake.sectors[i] === sector ) index = i;
|
208
|
+
}
|
209
|
+
return index;
|
210
|
+
}
|
183
211
|
|
184
212
|
socialCheesecake.Sector.prototype.turnExtraIntoNewSubsector = function (subsectorIndex){
|
185
213
|
var sector = this;
|
@@ -189,7 +217,14 @@ var socialCheesecake = socialCheesecake || {};
|
|
189
217
|
var dummyExtra = [];
|
190
218
|
var step = 1.5;
|
191
219
|
var mainExtraAnchor = "m";
|
192
|
-
|
220
|
+
var onSubsectorAddedBegin = socialCheesecake.eventCallbackHandlers.onSubsectorAddedBegin;
|
221
|
+
var onSubsectorAddedEnd = socialCheesecake.eventCallbackHandlers.onSubsectorAddedEnd;
|
222
|
+
|
223
|
+
if(this.subsectors.length >= 4){
|
224
|
+
console.log("Reached subsectors limit. No new subsectors will be added");
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
|
193
228
|
//Create dummies for the animation
|
194
229
|
for(var i in allSubsectors){
|
195
230
|
var settings = {
|
@@ -201,28 +236,30 @@ var socialCheesecake = socialCheesecake || {};
|
|
201
236
|
phi : allSubsectors[i].phi,
|
202
237
|
delta : allSubsectors[i].delta,
|
203
238
|
type : allSubsectors[i].type,
|
204
|
-
auxiliar :
|
239
|
+
auxiliar : true,
|
205
240
|
parent : allSubsectors[i].parent,
|
206
241
|
color : allSubsectors[i].color
|
207
242
|
};
|
208
243
|
if(i < this.extraSubsectors.length){
|
209
244
|
dummyExtra.push(new socialCheesecake.Subsector(settings));
|
210
|
-
dummyExtra[i].listen(false);
|
211
245
|
}else{
|
212
246
|
dummyNormal.push(new socialCheesecake.Subsector(settings));
|
213
|
-
dummyNormal[i - dummyExtra.length].listen(false);
|
214
247
|
}
|
215
248
|
}
|
249
|
+
cheesecake.disable();
|
216
250
|
cheesecake.addToLayer(dummyNormal.concat(dummyExtra));
|
217
251
|
//Add new Subsector and calculate subsector's new sizes
|
218
252
|
cheesecake.removeFromLayer(allSubsectors);
|
219
253
|
this.addNewSubsector(subsectorIndex);
|
254
|
+
//Initial callback
|
255
|
+
if(onSubsectorAddedBegin != null) onSubsectorAddedBegin(sector.subsectors[subsectorIndex]);
|
220
256
|
var normalSubsectors = this.subsectors;
|
221
257
|
this.extraSubsectors = [];
|
222
258
|
var extraSubsectors = sector.extraSubsectors;
|
223
259
|
var clone = this.getCheesecake().getAuxiliarClone();
|
224
260
|
clone.calculateSubportions();
|
225
|
-
clone.label="";
|
261
|
+
clone.label ="";
|
262
|
+
clone.color =socialCheesecake.colors.normalSector.background;
|
226
263
|
|
227
264
|
for(var i in dummyExtra){
|
228
265
|
if(i != subsectorIndex){
|
@@ -281,8 +318,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
281
318
|
};
|
282
319
|
dummyExtra.push(new socialCheesecake.Subsector(settings));
|
283
320
|
dummyExtra.push(new socialCheesecake.Subsector(settings));
|
321
|
+
var done = false;
|
284
322
|
for(var i = 0; i < dummyExtra.length; i++){
|
285
|
-
var done = false;
|
286
323
|
if(i != subsectorIndex){
|
287
324
|
dummyExtra[i].rIn = (i < subsectorIndex) ? extraSubsectors[i].getMediumRadius() : extraSubsectors[i-1].getMediumRadius();
|
288
325
|
dummyExtra[i].rOut = dummyExtra[i].rIn;
|
@@ -291,10 +328,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
291
328
|
width : (i < subsectorIndex) ? extraSubsectors[i].getWidth() : extraSubsectors[i-1].getWidth(),
|
292
329
|
anchor : "m",
|
293
330
|
step : step,
|
294
|
-
callback :
|
295
|
-
|
331
|
+
callback : function (){
|
332
|
+
if(done) return;
|
296
333
|
done = true;
|
297
|
-
|
334
|
+
return finalAnimationCallback;
|
335
|
+
}()
|
298
336
|
});
|
299
337
|
}
|
300
338
|
}
|
@@ -302,9 +340,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
302
340
|
};
|
303
341
|
var finalAnimationCallback = function(){
|
304
342
|
cheesecake.removeFromLayer(dummyNormal.concat(dummyExtra));
|
305
|
-
cheesecake.addToLayer(normalSubsectors);
|
343
|
+
cheesecake.addToLayer(normalSubsectors);
|
306
344
|
if(extraSubsectors) cheesecake.addToLayer(extraSubsectors);
|
307
345
|
cheesecake.drawLayer();
|
346
|
+
cheesecake.enable();
|
347
|
+
if(onSubsectorAddedEnd != null) onSubsectorAddedEnd(sector.subsectors[subsectorIndex]);
|
308
348
|
};
|
309
349
|
for (var i = 0; i< dummyNormal.length; i++){
|
310
350
|
dummyNormal[i].resizeWidth({
|
@@ -318,7 +358,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
318
358
|
|
319
359
|
socialCheesecake.Sector.prototype.splitUp = function() {
|
320
360
|
var cheesecake = this.getCheesecake();
|
321
|
-
var
|
361
|
+
var onSectorFocusEnd = socialCheesecake.eventCallbackHandlers.onSectorFocusEnd;
|
322
362
|
var sector = (this.simulate != null) ? cheesecake.sectors[this.simulate] : this;
|
323
363
|
var subsectors = sector.subsectors;
|
324
364
|
|
@@ -328,9 +368,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
328
368
|
this.calculateSubportions();
|
329
369
|
cheesecake.addToLayer(subsectors.concat(sector.extraSubsectors));
|
330
370
|
cheesecake.drawLayer();
|
331
|
-
if(
|
332
|
-
callback(cheesecake);
|
333
|
-
}
|
371
|
+
if(onSectorFocusEnd) onSectorFocusEnd(cheesecake);
|
334
372
|
}
|
335
373
|
|
336
374
|
socialCheesecake.Sector.prototype.putTogether = function() {
|
@@ -416,12 +454,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
416
454
|
|
417
455
|
socialCheesecake.Sector.prototype.changeProperty = function (name, value){
|
418
456
|
var sector = this;
|
419
|
-
var
|
420
|
-
var
|
457
|
+
var cheesecake = sector.getCheesecake();
|
458
|
+
var layer = sector.getLayer();
|
421
459
|
sector[name] = value;
|
422
|
-
|
423
|
-
|
424
|
-
stage.draw();
|
460
|
+
if((sector.type == "normalSector") && (name == "label")) cheesecake.updateSectorChanges(sector);
|
461
|
+
if(layer) cheesecake.drawLayer(layer);
|
425
462
|
}
|
426
463
|
|
427
464
|
/**
|
@@ -438,8 +475,6 @@ var socialCheesecake = socialCheesecake || {};
|
|
438
475
|
if(!options)
|
439
476
|
throw "No arguments passed to the function";
|
440
477
|
var sector = this;
|
441
|
-
var stage = sector.getCheesecake().stage;
|
442
|
-
var context = stage.mainLayer.getContext();
|
443
478
|
var currentDelta = sector.delta;
|
444
479
|
var currentPhi = sector.phi;
|
445
480
|
var step = 0.05;
|
@@ -484,9 +519,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
484
519
|
sector.phi = currentPhi;
|
485
520
|
|
486
521
|
//Redraw
|
487
|
-
|
488
|
-
context.save();
|
489
|
-
stage.draw();
|
522
|
+
sector.getCheesecake().drawLayer(sector.getLayer());
|
490
523
|
//Repeat if necessary
|
491
524
|
if(goOn && (Math.round(currentDelta*1000) != Math.round(goalDelta*1000))) {
|
492
525
|
requestAnimFrame(function() {
|
@@ -512,8 +545,6 @@ var socialCheesecake = socialCheesecake || {};
|
|
512
545
|
*/
|
513
546
|
socialCheesecake.Sector.prototype.resizeWidth = function(options) {
|
514
547
|
var sector = this;
|
515
|
-
var stage = sector.getCheesecake().stage;
|
516
|
-
var context = stage.mainLayer.getContext();
|
517
548
|
var currentRIn = this.rIn;
|
518
549
|
var currentROut = this.rOut;
|
519
550
|
var currentWidth = (currentROut - currentRIn);
|
@@ -566,9 +597,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
566
597
|
sector.rOut = currentROut;
|
567
598
|
sector.rIn = currentRIn;
|
568
599
|
//Redraw
|
569
|
-
|
570
|
-
context.save();
|
571
|
-
stage.draw();
|
600
|
+
sector.getCheesecake().drawLayer(sector.getLayer());
|
572
601
|
//Repeat if necessary
|
573
602
|
if ((goOn) &&(Math.round(currentWidth *1000) != Math.round(goalWidth *1000))) {
|
574
603
|
requestAnimFrame(function() {
|
@@ -590,7 +619,6 @@ var socialCheesecake = socialCheesecake || {};
|
|
590
619
|
if(options.radius - this.getWidth()/2 < 0) options.radius = this.getWidth()/2;
|
591
620
|
var goalMedRad = options.radius || currentMedRad;
|
592
621
|
var step = options.step || 0.05;
|
593
|
-
var context = this.getCheesecake().stage.mainLayer.getContext();
|
594
622
|
|
595
623
|
if(goalMedRad > currentMedRad){
|
596
624
|
if(goalMedRad - currentMedRad < step) step = goalMedRad - currentMedRad;
|
@@ -605,9 +633,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
605
633
|
this.rOut = Math.round(currentROut *1000)/1000;
|
606
634
|
currentMedRad = this.getMediumRadius();
|
607
635
|
//Redraw
|
608
|
-
|
609
|
-
context.save();
|
610
|
-
this.getCheesecake().stage.draw();
|
636
|
+
sector.getCheesecake().drawLayer(sector.getLayer());
|
611
637
|
//Repeat if necessary
|
612
638
|
if ((Math.round(currentMedRad *1000) != Math.round(goalMedRad *1000))) {
|
613
639
|
requestAnimFrame(function() {
|
@@ -622,22 +648,12 @@ var socialCheesecake = socialCheesecake || {};
|
|
622
648
|
|
623
649
|
socialCheesecake.Sector.prototype.focus = function() {
|
624
650
|
var sector = this;
|
625
|
-
|
626
|
-
var context = stage.mainLayer.getContext();
|
627
|
-
sector.rOut = sector.originalAttr.rOut * 1.05;
|
628
|
-
context.restore();
|
629
|
-
context.save();
|
630
|
-
stage.draw();
|
651
|
+
sector.changeProperty("rOut", sector.originalAttr.rOut * 1.05);
|
631
652
|
}
|
632
653
|
|
633
654
|
socialCheesecake.Sector.prototype.unfocus = function() {
|
634
655
|
var sector = this;
|
635
|
-
|
636
|
-
var context = stage.mainLayer.getContext();
|
637
|
-
sector.rOut = sector.originalAttr.rOut;
|
638
|
-
context.restore();
|
639
|
-
context.save();
|
640
|
-
stage.draw();
|
656
|
+
sector.changeProperty("rOut", sector.originalAttr.rOut);
|
641
657
|
}
|
642
658
|
|
643
659
|
/**
|
@@ -668,14 +684,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
668
684
|
}
|
669
685
|
|
670
686
|
socialCheesecake.Sector.prototype.rotateTo = function(options) {
|
671
|
-
// update stage
|
672
687
|
var sector = this;
|
673
688
|
var currentPhi = this.phi % (2 * Math.PI);
|
674
689
|
var delta = this.delta;
|
675
690
|
var step = 0.05;
|
676
691
|
var anchor = 0;
|
677
|
-
var stage = sector.getCheesecake().stage;
|
678
|
-
var context = sector.getRegion().getLayer().getContext();
|
679
692
|
if(!options) throw "No arguments passed to the function";
|
680
693
|
if(options.step) step = options.step;
|
681
694
|
if(options.destination == null) throw "destination must be defined";
|
@@ -721,16 +734,13 @@ var socialCheesecake = socialCheesecake || {};
|
|
721
734
|
sector.phi = currentPhi;
|
722
735
|
|
723
736
|
// redraw
|
724
|
-
|
725
|
-
context.save();
|
726
|
-
stage.draw();
|
737
|
+
sector.getCheesecake().drawLayer(sector.getLayer());
|
727
738
|
|
728
739
|
// request new frame
|
729
740
|
if(Math.abs(currentPhi - phiDestination) > 0.001) {
|
730
741
|
sector.phi = currentPhi % (2 * Math.PI);
|
731
742
|
requestAnimFrame(function() {
|
732
743
|
sector.rotateTo({
|
733
|
-
context : context,
|
734
744
|
destination : options.destination,
|
735
745
|
step : step,
|
736
746
|
callback : options.callback,
|
@@ -742,25 +752,27 @@ var socialCheesecake = socialCheesecake || {};
|
|
742
752
|
}
|
743
753
|
}
|
744
754
|
|
745
|
-
socialCheesecake.Sector.prototype.addNewSubsector = function (
|
755
|
+
socialCheesecake.Sector.prototype.addNewSubsector = function (subectorIndex){
|
746
756
|
var subsectors = this.subsectors;
|
747
757
|
var settings = {
|
748
758
|
parent : this,
|
749
759
|
x : this.x,
|
750
760
|
y : this.y,
|
751
761
|
delta : this.delta,
|
752
|
-
phi : this.phi
|
753
|
-
id :
|
762
|
+
phi : this.phi,
|
763
|
+
id : socialCheesecake.Sector.newSubsectorIdRoot +'S'+ this.getIndex() +'s'+subectorIndex
|
754
764
|
};
|
755
|
-
|
765
|
+
//Rearrange subsectors
|
756
766
|
for(var i = subsectors.length ; i >= 0 ; i--){
|
757
|
-
if( i >
|
758
|
-
if( i ==
|
767
|
+
if( i > subectorIndex) subsectors[i] = subsectors[i-1];
|
768
|
+
if( i == subectorIndex ){
|
759
769
|
settings.label = "New Subsector "+ i;
|
760
770
|
subsectors[i]= new socialCheesecake.Subsector(settings);
|
761
771
|
}
|
762
772
|
}
|
763
|
-
|
773
|
+
//Communicate changes to Cheesecake
|
774
|
+
this.getCheesecake().updateSectorChanges(this);
|
775
|
+
return subsectors[subectorIndex];
|
764
776
|
}
|
765
777
|
|
766
778
|
socialCheesecake.Sector.prototype.addActor = function(actorInfo , subsector){
|
@@ -797,6 +809,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
797
809
|
var actors = this.actors;
|
798
810
|
var actorParents;
|
799
811
|
var actorPresentInSector = false;
|
812
|
+
var grid = this.getCheesecake().grid;
|
800
813
|
|
801
814
|
for(var actorIndex in actors){
|
802
815
|
if(actors[actorIndex].id == actor.id){
|
@@ -813,6 +826,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
813
826
|
//If there isn't, remove the actor from the array and tell the Grid
|
814
827
|
if(!actorPresentInSector){
|
815
828
|
actors.splice(actorIndex,1);
|
829
|
+
grid.removeActor(actor);
|
816
830
|
}
|
817
831
|
}
|
818
832
|
}
|
@@ -826,6 +840,14 @@ var socialCheesecake = socialCheesecake || {};
|
|
826
840
|
return (this.rOut + this.rIn)/2;
|
827
841
|
}
|
828
842
|
|
843
|
+
socialCheesecake.Sector.prototype.getSubsectorsIds = function(){
|
844
|
+
var subsectors = [];
|
845
|
+
for(var subsector in this.subsectors){
|
846
|
+
subsectors.push(this.subsectors[subsector].id);
|
847
|
+
}
|
848
|
+
return subsectors;
|
849
|
+
}
|
850
|
+
|
829
851
|
socialCheesecake.Sector.prototype.listen = function (on){
|
830
852
|
var region = this.getRegion();
|
831
853
|
var sector = this;
|