relation colors fix
This commit is contained in:
+14
-10
@@ -4,20 +4,29 @@ SQL.Relation = function(owner, row1, row2) {
|
||||
this.owner = owner;
|
||||
this.row1 = row1;
|
||||
this.row2 = row2;
|
||||
this.colorIndex = 0;
|
||||
this.color = "#000";
|
||||
this.hidden = false;
|
||||
this.relationColors = CONFIG.RELATION_COLORS;
|
||||
SQL.Visual.apply(this);
|
||||
|
||||
this.style = SQL.Designer.getOption("style");
|
||||
switch (this.style) {
|
||||
case "material-inspired":
|
||||
this.relationColors = CONFIG.MATERIAL_RELATION_COLORS;
|
||||
break;
|
||||
case "original":
|
||||
default:
|
||||
this.relationColors = CONFIG.RELATION_COLORS;
|
||||
}
|
||||
|
||||
/* if one of the rows already has relations, inherit color */
|
||||
var all = row1.relations.concat(row2.relations);
|
||||
if (all.length) { /* inherit */
|
||||
this.color = all[0].getColor();
|
||||
this.colorIndex = all[0].getColorIndex();
|
||||
} else if (CONFIG.RELATION_COLORS) { /* pick next */
|
||||
} else if (this.relationColors) { /* pick next */
|
||||
SQL.Relation._counter++;
|
||||
this.colorIndex = (SQL.Relation._counter - 1) % CONFIG.RELATION_COLORS.length;
|
||||
this.color = CONFIG.RELATION_COLORS[this.colorIndex];
|
||||
var colorIndex = (SQL.Relation._counter - 1) % this.relationColors.length;
|
||||
this.color = this.relationColors[colorIndex];
|
||||
}
|
||||
|
||||
this.row1.addRelation(this);
|
||||
@@ -27,7 +36,6 @@ SQL.Relation = function(owner, row1, row2) {
|
||||
if (this.owner.vector) {
|
||||
var path = document.createElementNS(this.owner.svgNS, "path");
|
||||
path.setAttribute("stroke", this.color);
|
||||
path.setAttribute("class", "relation_" + this.colorIndex);
|
||||
path.setAttribute("stroke-width", CONFIG.RELATION_THICKNESS);
|
||||
path.setAttribute("fill", "none");
|
||||
this.owner.dom.svg.appendChild(path);
|
||||
@@ -54,10 +62,6 @@ SQL.Relation.prototype.getColor = function() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
SQL.Relation.prototype.getColorIndex = function() {
|
||||
return this.colorIndex;
|
||||
}
|
||||
|
||||
SQL.Relation.prototype.show = function() {
|
||||
this.hidden = false;
|
||||
for (var i=0;i<this.dom.length;i++) {
|
||||
|
||||
Reference in New Issue
Block a user