Skip to content

Commit 7d5a0e0

Browse files
introducing colors
1 parent 1e8ba83 commit 7d5a0e0

File tree

5 files changed

+100
-14
lines changed

5 files changed

+100
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheUMLExplorer",
3-
"version": "0.13.2",
3+
"version": "0.14.0",
44
"description": "An UML Class explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"

web/css/classView.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ svg {
1616
}
1717

1818
.uml-class-name-rect {
19-
fill: lightgray;
19+
/*fill: lightgray;*/
2020
}
2121

2222
.uml-class-attrs-rect, .uml-class-methods-rect {
@@ -57,7 +57,7 @@ text {
5757
.uml-class-attrs-label {
5858
font-family: monospace;
5959
font-weight: 900;
60-
fill: orange;
60+
fill: rgb(255, 97, 0);
6161
}
6262

6363
.uml-class-methods-label {

web/js/ClassView.js

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ ClassView.prototype.renderInfoGraphic = function () {
112112
classes: {
113113
"Shared object": {
114114
super: "Super object",
115+
classType: "Serial",
115116
parameters: {
116117
"Also inherit Super object": {}
117118
},
@@ -189,11 +190,15 @@ ClassView.prototype.renderInfoGraphic = function () {
189190
}
190191
},
191192
"Super object": {
193+
classType: "Persistent",
192194
methods: {},
193195
properties: {},
194-
parameters: {}
196+
parameters: {
197+
"(This class is %Persistent)": {}
198+
}
195199
},
196200
"HELP": {
201+
classType: "Registered",
197202
parameters: {
198203
"See the basics here!": {}
199204
}
@@ -216,20 +221,73 @@ ClassView.prototype.renderInfoGraphic = function () {
216221

217222
};
218223

224+
/**
225+
* Filter some inherits.
226+
*
227+
* @param data
228+
*/
229+
ClassView.prototype.filterInherits = function (data) {
230+
231+
if (!data || !data.inheritance) return;
232+
233+
var p1, p2, filter = {
234+
"%Library.Persistent": true,
235+
"%Persistent": true,
236+
"%Library.SerialObject": true,
237+
"%SerialObject": true,
238+
"%Library.RegisteredObject": true,
239+
"%RegisteredObject": true,
240+
"%Library.DataType": true,
241+
"%DataType": true
242+
};
243+
244+
for (p1 in data.inheritance) { // classes
245+
for (p2 in data.inheritance[p1]) { // inherits
246+
if (filter.hasOwnProperty(p2)) delete data.inheritance[p1][p2];
247+
}
248+
}
249+
250+
for (p1 in data.classes) {
251+
if (filter.hasOwnProperty(p1)) delete data.classes[p1];
252+
}
253+
254+
};
255+
219256
/**
220257
* Returns array of signs to render or empry array.
221258
*
222259
* @param classMetaData
223260
*/
224-
ClassView.prototype.getClassSigns = function (classMetaData) {
261+
ClassView.prototype.getClassSignsAndType = function (classMetaData) {
225262

226-
var signs = [];
263+
var signs = [], sup = lib.obj((classMetaData["super"] || "").split(",")), ct, CT = "NORMAL";
227264

228-
if (classMetaData["classType"]) signs.push({
229-
icon: lib.image.greenPill,
230-
text: lib.capitalize(classMetaData["classType"]),
231-
textStyle: "fill:rgb(130,0,255)"
232-
});
265+
if (classMetaData["classType"] || sup) {
266+
ct = classMetaData["classType"];
267+
if (sup.hasOwnProperty("%Library.Persistent") || sup.hasOwnProperty("%Persistent")) {
268+
ct = "Persistent";
269+
}
270+
if (sup.hasOwnProperty("%Library.SerialObject") || sup.hasOwnProperty("%SerialObject")) {
271+
ct = "Serial";
272+
}
273+
if (
274+
sup.hasOwnProperty("%Library.RegisteredObject")
275+
|| sup.hasOwnProperty("%RegisteredObject")
276+
) {
277+
ct = "Registered";
278+
}
279+
if (sup.hasOwnProperty("%Library.DataType") || sup.hasOwnProperty("%DataType")) {
280+
ct = "Datatype";
281+
}
282+
if (ct) {
283+
CT = ct;
284+
signs.push({
285+
icon: lib.image.greenPill,
286+
text: lib.capitalize(ct),
287+
textStyle: "fill:rgb(130,0,255)"
288+
});
289+
}
290+
}
233291
if (classMetaData["ABSTRACT"]) signs.push({
234292
icon: lib.image.crystalBall,
235293
text: "Abstract",
@@ -253,7 +311,7 @@ ClassView.prototype.getClassSigns = function (classMetaData) {
253311
text: "Hidden"
254312
});
255313

256-
return signs;
314+
return { signs: signs, classType: CT };
257315

258316
};
259317

@@ -291,6 +349,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
291349
classProps = classMetaData["properties"],
292350
classMethods = classMetaData["methods"],
293351
keyWordsArray = [name],
352+
signsAndType,
294353
self = this;
295354

296355
var classInstance = new joint.shapes.uml.Class({
@@ -341,7 +400,8 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
341400
}
342401
return arr;
343402
})(classMethods),
344-
classSigns: this.getClassSigns(classMetaData),
403+
classSigns: (signsAndType = this.getClassSignsAndType(classMetaData)).signs,
404+
classType: signsAndType.classType,
345405
SYMBOL_12_WIDTH: self.SYMBOL_12_WIDTH
346406
});
347407

@@ -444,6 +504,8 @@ ClassView.prototype.confirmRender = function (data) {
444504
uml = joint.shapes.uml, relFrom, relTo,
445505
classes = {}, connector;
446506

507+
this.filterInherits(data);
508+
447509
// Reset view and zoom again because it may cause visual damage to icons.
448510
// Don't ask me why. Just believe we need this peace of code.
449511
this.zoom(null);

web/js/Lib.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/jsLib/joint.shapes.uml.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
4242
attrs: {
4343
rect: { 'width': 0 },
4444

45-
'.uml-class-name-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': '#3498db' },
45+
'.uml-class-name-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': 'rgb(177, 205, 255)' },
4646
'.uml-class-params-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': 'white' },
4747
'.uml-class-attrs-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': '#2980b9' },
4848
'.uml-class-methods-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': '#2980b9' },
@@ -94,9 +94,23 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
9494
],
9595
self = this,
9696
classSigns = this.get('classSigns'),
97+
CLASS_TYPE = this.get('classType'),
9798
SYMBOL_12_WIDTH = this.get('SYMBOL_12_WIDTH') || 6.6,
9899
i, j, blockWidth, left = 3, top = 3, w, positions = [], sign;
99100

101+
// set color head according to class type
102+
var headColor;
103+
switch (CLASS_TYPE) {
104+
case "Persistent": headColor = "rgb(255,219,170)"; break; // light orange
105+
case "Serial": headColor = "rgb(252,255,149)"; break; // light yellow
106+
case "Registered": headColor = "rgb(192,255,170)"; break; // light green
107+
case "Datatype": headColor = "rgb(193,250,255)"; break; // light blue
108+
case "Stream": headColor = "rgb(246,188,255)"; break; // light magenta
109+
case "View": headColor = "rgb(255,188,188)"; break; // light red
110+
case "Index": headColor = "rgb(228,228,228)"; break; // light gray
111+
}
112+
if (headColor) this.attributes.attrs[".uml-class-name-rect"].fill = headColor;
113+
100114
var subLabelWidth = function (sign) { // object
101115
return sign.text.length * SYMBOL_12_WIDTH + (sign.icon ? 13 : 0)
102116
};

0 commit comments

Comments
 (0)