relation colors fix
This commit is contained in:
+2
-1
@@ -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: "",
|
||||
|
||||
+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++) {
|
||||
|
||||
+10
-10
@@ -29,7 +29,7 @@ SQL.Designer = function() {
|
||||
this.flag = 2;
|
||||
this.requestLanguage();
|
||||
this.requestDB();
|
||||
this.requestStyle();
|
||||
this.setStyle();
|
||||
}
|
||||
SQL.Designer.prototype = Object.create(SQL.Visual.prototype);
|
||||
|
||||
@@ -80,7 +80,15 @@ SQL.Designer.prototype.requestDB = function() { /* get datatypes file */
|
||||
OZ.Request(url, this.dbResponse.bind(this), {method:"get", xml:true});
|
||||
}
|
||||
|
||||
SQL.Designer.prototype.requestStyle = function() { /* set style */
|
||||
SQL.Designer.prototype.dbResponse = function(xmlDoc) {
|
||||
if (xmlDoc) {
|
||||
window.DATATYPES = xmlDoc.documentElement;
|
||||
}
|
||||
this.flag--;
|
||||
if (!this.flag) { this.init2(); }
|
||||
}
|
||||
|
||||
SQL.Designer.prototype.setStyle = function() { /* set style */
|
||||
var style = this.getOption("style");
|
||||
var i, link_elms;
|
||||
for (i=0; link_elms = document.getElementsByTagName("link"); i++) {
|
||||
@@ -91,14 +99,6 @@ SQL.Designer.prototype.requestStyle = function() { /* set style */
|
||||
}
|
||||
}
|
||||
|
||||
SQL.Designer.prototype.dbResponse = function(xmlDoc) {
|
||||
if (xmlDoc) {
|
||||
window.DATATYPES = xmlDoc.documentElement;
|
||||
}
|
||||
this.flag--;
|
||||
if (!this.flag) { this.init2(); }
|
||||
}
|
||||
|
||||
SQL.Designer.prototype.init2 = function() { /* secondary init, after locale & datatypes were retrieved */
|
||||
this.map = new SQL.Map(this);
|
||||
this.rubberband = new SQL.Rubberband(this);
|
||||
|
||||
Reference in New Issue
Block a user