Skip to content

Commit 42010e1

Browse files
center class signs, right column size decrease by 50px
1 parent 8ba3043 commit 42010e1

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
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.7.0",
3+
"version": "0.7.1",
44
"description": "An UML Class explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"

web/css/interface.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ html, body {
1515
.ui-sideBlock {
1616
position: relative;
1717
float: left;
18-
width: 300px;
18+
width: 250px;
1919
height: 100%;
2020
}
2121

2222
.ui-mainBlock {
2323
position: relative;
24-
margin-left: 300px;
24+
margin-left: 250px;
2525
height: 100%;
2626
}
2727

web/jsLib/joint.shapes.uml.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
9494
self = this,
9595
classSigns = this.get('classSigns'),
9696
SYMBOL_12_WIDTH = this.get('SYMBOL_12_WIDTH') || 6.6,
97-
i, blockWidth, left = 3, top = 3, w;
97+
i, j, blockWidth, left = 3, top = 3, w, positions = [], sign;
98+
99+
var subLabelWidth = function (sign) { // object
100+
return sign.text.length * SYMBOL_12_WIDTH + (sign.icon ? 13 : 0)
101+
};
98102

99103
// preserve space for sub-labels
100104
w = 0; for (i in classSigns) {
101-
w += classSigns[i].text.length * SYMBOL_12_WIDTH + (classSigns[i].icon ? 13 : 0) + (i ? 3 : 0);
105+
w += subLabelWidth(classSigns[i]);
102106
i = 1;
103107
}
104108

@@ -116,18 +120,30 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
116120

117121
if (classSigns.length) this.HEAD_EMPTY_LINES = 1;
118122

123+
// centering algorithm - first, remember position without centering
124+
j = 0;
119125
for (i in classSigns) {
120126
w = classSigns[i].text.length*SYMBOL_12_WIDTH + (classSigns[i].icon ? 13 : 0);
121-
if (left + w - 3 > blockWidth) { top += 12; left = 3; this.HEAD_EMPTY_LINES++; }
122-
this.markup += '<g transform="translate(' + left + ', ' + top + ')">' +
123-
(classSigns[i].icon ? '<image xlink:href="' + classSigns[i].icon +
124-
'" width="13" height="13"/>' : '') + '<text fill="black" font-size="11" ' +
125-
(classSigns[i].textStyle ? 'style="' + classSigns[i].textStyle + '"' : '') +
126-
' x="' + (classSigns[i].icon ? 13 : 0) + '" y="10">' + classSigns[i].text +
127-
'</text></g>';
127+
if (left + w - 3 > blockWidth) { top += 12; left = 3; this.HEAD_EMPTY_LINES++; j++; }
128+
if (!positions[j]) positions[j] = [];
129+
positions[j].push({ top: top, left: left, o: classSigns[i] });
128130
left += w + 3;
129131
}
130132

133+
// then draw on position with computed seek by X to center content
134+
for (i = 0; i < positions.length; i++) { // repeat positions and draw signs
135+
w = (blockWidth - (sign = positions[i][positions[i].length - 1]).left - subLabelWidth(sign.o)) / 2;
136+
for (j = 0; j < positions[i].length; j++) {
137+
sign = positions[i][j];
138+
this.markup += '<g transform="translate(' + (sign.left + w) + ', ' + sign.top + ')">' +
139+
(sign.o.icon ? '<image xlink:href="' + sign.o.icon +
140+
'" width="13" height="13"/>' : '') + '<text fill="black" font-size="11" ' +
141+
(sign.o.textStyle ? 'style="' + sign.o.textStyle + '"' : '') +
142+
' x="' + (sign.o.icon ? 13 : 0) + '" y="10">' + sign.o.text +
143+
'</text></g>';
144+
}
145+
}
146+
131147
this.on('change:name change:attributes change:methods', function () {
132148
this.updateRectangles();
133149
this.trigger('uml-update');

0 commit comments

Comments
 (0)