diff --git a/js/config.js b/js/config.js index aef3b22..49636ed 100644 --- a/js/config.js +++ b/js/config.js @@ -11,8 +11,9 @@ var CONFIG = { RELATION_THICKNESS: 2, RELATION_SPACING: 15, RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"], - + STYLES: ["material-inspired", "original"], + MATERIAL_RELATION_COLORS: ["#323232", "#F44336", "#E91E63", "#9C27B0", "#3F51B5", "#673AB7", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#FF5722", "#795548", "#607D8B"], STATIC_PATH: "", XHR_PATH: "", diff --git a/js/relation.js b/js/relation.js index f8caaff..6a08156 100644 --- a/js/relation.js +++ b/js/relation.js @@ -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