WIP on legend for goal

This commit is contained in:
Peter Cottle 2013-07-07 15:26:03 -07:00
parent ea30b42616
commit 264f245275
11 changed files with 217 additions and 17 deletions

View file

@ -3,6 +3,7 @@ var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS;
var VisBase = require('../visuals/visBase').VisBase;
var TreeCompare = require('../git/treeCompare').TreeCompare;
var randomHueString = function() {
var hue = Math.random();
@ -83,6 +84,39 @@ var VisBranch = VisBase.extend({
return visNode.getScreenCoords();
},
getDashArray: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return '';
}
return (this.getIsLevelBranchCompared()) ? '' : '- ';
},
getIsGoalAndNotCompared: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return false;
}
return !this.getIsLevelBranchCompared();
},
/**
* returns true if we are a branch that is not being
* compared in the goal (used in a goal visualization context
*/
getIsLevelBranchCompared: function() {
if (this.getIsMaster()) {
return true; // master always compared
}
// we are not master, so return true if its not just master being compared
var levelBlob = this.get('gitVisuals').getLevelBlob();
return !TreeCompare.onlyMasterCompared(levelBlob);
},
getIsMaster: function() {
return this.get('branch').get('id') == 'master';
},
getFlipValue: function(commit, visNode) {
var threshold = this.get('gitVisuals').getFlipPos();
var overThreshold = (visNode.get('pos').x > threshold);
@ -438,13 +472,22 @@ var VisBranch = VisBase.extend({
if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0;
}
return this.getBranchStackIndex() === 0 ? 1 : 0.0;
if (this.getBranchStackIndex() !== 0) {
return 0.0;
}
return 1;
},
getTextOpacity: function() {
if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0;
}
if (this.getIsGoalAndNotCompared()) {
return 0.3;
}
return 1;
},
@ -458,8 +501,7 @@ var VisBranch = VisBase.extend({
var rectSize = this.getRectSize();
var arrowPath = this.getArrowPath();
var dashArray = (this.getIsInOrigin()) ?
GRAPHICS.originDash : '';
var dashArray = this.getDashArray();
var cursorStyle = (this.shouldDisableClick()) ?
'auto' :
'pointer';
@ -481,7 +523,7 @@ var VisBranch = VisBase.extend({
opacity: nonTextOpacity,
fill: this.getFill(),
stroke: this.get('stroke'),
//'stroke-dasharray': dashArray,
'stroke-dasharray': dashArray,
'stroke-width': this.get('stroke-width')
},
arrow: {