This commit is contained in:
Ondrej Zara
2013-01-10 13:49:42 +01:00
8 changed files with 19 additions and 12 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

+16 -9
View File
@@ -481,27 +481,30 @@ SQL.Row.prototype.enter = function(e) {
SQL.Relation = OZ.Class().extend(SQL.Visual); SQL.Relation = OZ.Class().extend(SQL.Visual);
SQL.Relation._counter = 0; SQL.Relation._counter = 0;
SQL.Relation.prototype.init = function(owner, row1, row2) { SQL.Relation.prototype.init = function(owner, row1, row2) {
this.constructor._counter++;
this.owner = owner; this.owner = owner;
this.row1 = row1; this.row1 = row1;
this.row2 = row2; this.row2 = row2;
this.color = "#000";
this.hidden = false; this.hidden = false;
SQL.Visual.prototype.init.apply(this); SQL.Visual.prototype.init.apply(this);
/* 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();
} else if (CONFIG.RELATION_COLORS) { /* pick next */
this.constructor._counter++;
var colorIndex = this.constructor._counter - 1;
this.color = CONFIG.RELATION_COLORS[colorIndex % CONFIG.RELATION_COLORS.length];
}
this.row1.addRelation(this); this.row1.addRelation(this);
this.row2.addRelation(this); this.row2.addRelation(this);
this.dom = []; this.dom = [];
if (CONFIG.RELATION_COLORS) {
var colorIndex = this.constructor._counter - 1;
var color = CONFIG.RELATION_COLORS[colorIndex % CONFIG.RELATION_COLORS.length];
} else {
var color = "#000";
}
if (this.owner.vector) { if (this.owner.vector) {
var path = document.createElementNS(this.owner.svgNS, "path"); var path = document.createElementNS(this.owner.svgNS, "path");
path.setAttribute("stroke", color); path.setAttribute("stroke", this.color);
path.setAttribute("stroke-width", CONFIG.RELATION_THICKNESS); path.setAttribute("stroke-width", CONFIG.RELATION_THICKNESS);
path.setAttribute("fill", "none"); path.setAttribute("fill", "none");
this.owner.dom.svg.appendChild(path); this.owner.dom.svg.appendChild(path);
@@ -522,6 +525,10 @@ SQL.Relation.prototype.init = function(owner, row1, row2) {
this.redraw(); this.redraw();
} }
SQL.Relation.prototype.getColor = function() {
return this.color;
}
SQL.Relation.prototype.show = function() { SQL.Relation.prototype.show = function() {
this.hidden = false; this.hidden = false;
for (var i=0;i<this.dom.length;i++) { for (var i=0;i<this.dom.length;i++) {