big gloabl removal on tree.js

This commit is contained in:
Peter Cottle 2012-11-03 14:50:11 -07:00
parent d485120f44
commit 1857f5a651
2 changed files with 28 additions and 18 deletions

View file

@ -52,8 +52,10 @@ var VisBranch = VisBase.extend({
initialize: function() { initialize: function() {
this.validateAtInit(); this.validateAtInit();
this.get('branch').set('visBranch', this); // shorthand notation
this.gitVisuals = this.get('gitVisuals');
this.get('branch').set('visBranch', this);
var id = this.get('branch').get('id'); var id = this.get('branch').get('id');
if (id == 'HEAD') { if (id == 'HEAD') {
@ -100,11 +102,11 @@ var VisBranch = VisBase.extend({
}, },
getBranchStackArray: function() { getBranchStackArray: function() {
var arr = gitVisuals.branchStackMap[this.get('branch').get('target').get('id')]; var arr = this.gitVisuals.branchStackMap[this.get('branch').get('target').get('id')];
if (arr === undefined) { if (arr === undefined) {
// this only occurs when we are generating graphics inside of // this only occurs when we are generating graphics inside of
// a new Branch instantiation, so we need to force the update // a new Branch instantiation, so we need to force the update
gitVisuals.calcBranchStacks(); this.gitVisuals.calcBranchStacks();
return this.getBranchStackArray(); return this.getBranchStackArray();
} }
return arr; return arr;
@ -265,13 +267,13 @@ var VisBranch = VisBase.extend({
} }
// woof. now it's hard, we need to blend hues... // woof. now it's hard, we need to blend hues...
return gitVisuals.blendHuesFromBranchStack(this.getBranchStackArray()); return this.gitVisuals.blendHuesFromBranchStack(this.getBranchStackArray());
}, },
remove: function() { remove: function() {
this.removeKeys(['text', 'arrow', 'rect']); this.removeKeys(['text', 'arrow', 'rect']);
// also need to remove from gitVisuals // also need to remove from this.gitVisuals
gitVisuals.removeVisBranch(this); this.gitVisuals.removeVisBranch(this);
}, },
genGraphics: function(paper) { genGraphics: function(paper) {
@ -436,6 +438,8 @@ var VisNode = VisBase.extend({
initialize: function() { initialize: function() {
this.validateAtInit(); this.validateAtInit();
// shorthand
this.gitVisuals = this.get('gitVisuals');
this.set('outgoingEdges', []); this.set('outgoingEdges', []);
}, },
@ -457,7 +461,7 @@ var VisNode = VisBase.extend({
getMaxWidthScaled: function() { getMaxWidthScaled: function() {
// returns our max width scaled based on if we are visible // returns our max width scaled based on if we are visible
// from a branch or not // from a branch or not
var stat = gitVisuals.getCommitUpstreamStatus(this.get('commit')); var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit'));
var map = { var map = {
branch: 1, branch: 1,
head: 0.3, head: 0.3,
@ -479,7 +483,7 @@ var VisNode = VisBase.extend({
'none': GRAPHICS.upstreamNoneOpacity 'none': GRAPHICS.upstreamNoneOpacity
}; };
var stat = gitVisuals.getCommitUpstreamStatus(this.get('commit')); var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit'));
if (map[stat] === undefined) { if (map[stat] === undefined) {
throw new Error('invalid status'); throw new Error('invalid status');
} }
@ -568,7 +572,7 @@ var VisNode = VisBase.extend({
getScreenCoords: function() { getScreenCoords: function() {
var pos = this.get('pos'); var pos = this.get('pos');
return gitVisuals.toScreenCoords(pos); return this.gitVisuals.toScreenCoords(pos);
}, },
getRadius: function() { getRadius: function() {
@ -684,7 +688,7 @@ var VisNode = VisBase.extend({
getFill: function() { getFill: function() {
// first get our status, might be easy from this // first get our status, might be easy from this
var stat = gitVisuals.getCommitUpstreamStatus(this.get('commit')); var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit'));
if (stat == 'head') { if (stat == 'head') {
return GRAPHICS.headRectFill; return GRAPHICS.headRectFill;
} else if (stat == 'none') { } else if (stat == 'none') {
@ -693,7 +697,7 @@ var VisNode = VisBase.extend({
// now we need to get branch hues // now we need to get branch hues
return gitVisuals.getBlendedHuesForCommit(this.get('commit')); return this.gitVisuals.getBlendedHuesForCommit(this.get('commit'));
return this.get('fill'); return this.get('fill');
}, },
@ -723,7 +727,7 @@ var VisNode = VisBase.extend({
// needs a manual removal of text for whatever reason // needs a manual removal of text for whatever reason
this.get('text').remove(); this.get('text').remove();
gitVisuals.removeVisNode(this); this.gitVisuals.removeVisNode(this);
}, },
removeAll: function() { removeAll: function() {
@ -781,13 +785,15 @@ var VisEdge = VisBase.extend({
initialize: function() { initialize: function() {
this.validateAtInit(); this.validateAtInit();
// shorthand
this.gitVisuals = this.get('gitVisuals');
this.get('tail').get('outgoingEdges').push(this); this.get('tail').get('outgoingEdges').push(this);
}, },
remove: function() { remove: function() {
this.removeKeys(['path']); this.removeKeys(['path']);
gitVisuals.removeVisEdge(this); this.gitVisuals.removeVisEdge(this);
}, },
genSmoothBezierPathString: function(tail, head) { genSmoothBezierPathString: function(tail, head) {
@ -877,7 +883,7 @@ var VisEdge = VisBase.extend({
}, },
getOpacity: function() { getOpacity: function() {
var stat = gitVisuals.getCommitUpstreamStatus(this.get('tail')); var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('tail'));
var map = { var map = {
'branch': 1, 'branch': 1,
'head': GRAPHICS.edgeUpstreamHeadOpacity, 'head': GRAPHICS.edgeUpstreamHeadOpacity,

View file

@ -105,7 +105,8 @@ GitVisuals.prototype.whenGitEngineReady = function(gitEngine) {
// seed this with the HEAD pseudo-branch // seed this with the HEAD pseudo-branch
var headBranch = new VisBranch({ var headBranch = new VisBranch({
branch: gitEngine.HEAD branch: gitEngine.HEAD,
gitVisuals: this
}); });
this.visBranchCollection.add(headBranch); this.visBranchCollection.add(headBranch);
@ -426,7 +427,8 @@ GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) {
GitVisuals.prototype.addBranch = function(branch, paperOverride) { GitVisuals.prototype.addBranch = function(branch, paperOverride) {
var visBranch = new VisBranch({ var visBranch = new VisBranch({
branch: branch branch: branch,
gitVisuals: this
}); });
this.visBranchCollection.add(visBranch); this.visBranchCollection.add(visBranch);
@ -500,7 +502,8 @@ GitVisuals.prototype.addNode = function(id, commit) {
var visNode = new VisNode({ var visNode = new VisNode({
id: id, id: id,
commit: commit commit: commit,
gitVisuals: this
}); });
this.visNodeMap[id] = visNode; this.visNodeMap[id] = visNode;
@ -522,7 +525,8 @@ GitVisuals.prototype.addEdge = function(idTail, idHead) {
var edge = new VisEdge({ var edge = new VisEdge({
tail: visNodeTail, tail: visNodeTail,
head: visNodeHead head: visNodeHead,
gitVisuals: this
}); });
this.visEdgeCollection.add(edge); this.visEdgeCollection.add(edge);