Skip to content

Commit c974c7d

Browse files
scaling buttons, parameters add
1 parent 89122a6 commit c974c7d

File tree

7 files changed

+197
-49
lines changed

7 files changed

+197
-49
lines changed

cache/projectTemplate.xml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Class name="UMLExplorer.ClassView">
55
<Description>
66
Class contains methods that return structured class data.</Description>
7-
<TimeChanged>63663,69939</TimeChanged>
7+
<TimeChanged>63667,81331.819092</TimeChanged>
88
<TimeCreated>63653,67019.989197</TimeCreated>
99

1010
<Method name="getClassData">
@@ -13,6 +13,8 @@ Class contains methods that return structured class data.</Description>
1313
<ReturnType>%ZEN.proxyObject</ReturnType>
1414
<Implementation><![CDATA[
1515
set oClass = ##class(%ZEN.proxyObject).%New()
16+
17+
1618
set oProperties = ##class(%ZEN.proxyObject).%New()
1719
set oClass.super = classDefinition.Super
1820
set oClass.properties = oProperties
@@ -35,7 +37,31 @@ Class contains methods that return structured class data.</Description>
3537
do oMeth.%DispatchSetProperty("returns", classDefinition.Methods.GetAt(i).ReturnType)
3638
}
3739
38-
return oClass
40+
set oParameters = ##class(%ZEN.proxyObject).%New()
41+
set oClass.parameters = oParameters
42+
set count = classDefinition.Parameters.Count()
43+
for i = 1:1:count {
44+
set oPar = ##class(%ZEN.proxyObject).%New()
45+
do oParameters.%DispatchSetProperty(classDefinition.Parameters.GetAt(i).Name, oPar)
46+
do oPar.%DispatchSetProperty("type", classDefinition.Parameters.GetAt(i).Type)
47+
}
48+
49+
quit oClass
50+
]]></Implementation>
51+
</Method>
52+
53+
<Method name="extendClassFromType">
54+
<ClassMethod>1</ClassMethod>
55+
<FormalSpec>typeName:%String</FormalSpec>
56+
<ReturnType>%String</ReturnType>
57+
<Implementation><![CDATA[
58+
return $CASE(typeName,
59+
"%String": "%Library.String",
60+
"%Integer": "%Library.Integer",
61+
"%DataType": "%Library.DataType",
62+
"%Status": "%Library.Status",
63+
"%CacheString": "%Library.CacheString",
64+
:typeName)
3965
]]></Implementation>
4066
</Method>
4167

@@ -50,7 +76,7 @@ Class contains methods that return structured class data.</Description>
5076
}
5177
set oInherit = oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name)
5278
for i=1:1:$LISTLENGTH(superParts) {
53-
set className = $LISTGET(superParts, i)
79+
set className = ..extendClassFromType($LISTGET(superParts, i))
5480
do oInherit.%DispatchSetProperty(className, 1)
5581
if (oData.classes.%DispatchGetProperty(className) = "") {
5682
set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
@@ -60,13 +86,14 @@ Class contains methods that return structured class data.</Description>
6086
}
6187
}
6288
}
63-
return $$$OK
89+
quit $$$OK
6490
]]></Implementation>
6591
</Method>
6692

6793
<Method name="getClassView">
6894
<ClassMethod>1</ClassMethod>
6995
<FormalSpec>baseClassDefinition:%Dictionary.ClassDefinition</FormalSpec>
96+
<ReturnType>%ZEN.proxyObject</ReturnType>
7097
<Implementation><![CDATA[
7198
set oData = ##class(%ZEN.proxyObject).%New()
7299
set oData.classes = ##class(%ZEN.proxyObject).%New()
@@ -75,7 +102,7 @@ Class contains methods that return structured class data.</Description>
75102
76103
do ..collectInheritance(oData, baseClassDefinition)
77104
78-
return oData
105+
quit oData
79106
]]></Implementation>
80107
</Method>
81108
</Class>

web/css/extras.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,72 @@
6060
100% {
6161
transform: rotate(360deg);
6262
}
63+
}
64+
65+
.icon {
66+
display: inline-block;
67+
background-color: #333;
68+
border-radius: 12px;
69+
width: 24px;
70+
height: 24px;
71+
position: relative;
72+
cursor: pointer;
73+
-webkit-transition: all .2s ease;
74+
-moz-transition: all .2s ease;
75+
-o-transition: all .2s ease;
76+
transition: all .2s ease;
77+
-webkit-user-select: none;
78+
-moz-user-select: none;
79+
-ms-user-select: none;
80+
user-select: none;
81+
}
82+
83+
.icon:hover {
84+
box-shadow: 0 0 5px 2px #ffcc1b;
85+
}
86+
87+
.icon.plus:before {
88+
content: "";
89+
background-color: #fff;
90+
width: 4px;
91+
height: 14px;
92+
border-radius: 1px;
93+
position: absolute;
94+
top: 5px;
95+
left: 10px;
96+
}
97+
98+
.icon.plus:after {
99+
content: "";
100+
background-color: #fff;
101+
width: 14px;
102+
height: 4px;
103+
border-radius: 1px;
104+
position: absolute;
105+
top: 10px;
106+
left: 5px;
107+
}
108+
109+
.icon.minus:after {
110+
content: "";
111+
background-color: #fff;
112+
width: 14px;
113+
height: 4px;
114+
border-radius: 1px;
115+
position: absolute;
116+
top: 10px;
117+
left: 5px;
118+
}
119+
120+
.icon.scaleNormal:after {
121+
content: "1:1";
122+
position: absolute;
123+
color: #fff;
124+
text-align: center;
125+
font-weight: 900;
126+
font-family: monospace;
127+
font-size: 10px;
128+
width: 100%;
129+
top: 6px;
130+
left: 0;
63131
}

web/css/interface.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ html, body {
2929
position: absolute;
3030
top: 0;
3131
left: 0;
32-
width: 100%;
3332
padding: .5em;
3433
font-weight: 600;
3534
font-size: 18pt;
3635
}
3736

37+
.ui-toolBar {
38+
position: absolute;
39+
bottom: 0;
40+
right: 0;
41+
padding: .5em;
42+
}
43+
3844
#className {
3945
text-shadow: 1px 1px 0 white, -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white;
4046
}

web/css/treeView.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313

1414
.tv-class-name.selected {
15-
box-shadow: inset 0 0 2px 2px deepskyblue;
15+
box-shadow: inset 0 0 2px 2px #ffcc1b;
1616
}
1717

1818
.tv-class-name, .tv-package-name {
@@ -26,11 +26,15 @@
2626
}
2727

2828
.tv-class-name:hover, .tv-package-name:hover {
29-
background: #b9ffff;
29+
background: #ffcc1b;
3030
font-weight: 900;
3131
padding-left: 30px;
3232
}
3333

34+
.tv-package-name:hover {
35+
background: #7dcdeb;
36+
}
37+
3438
.tv-package-name {
3539
position: relative;
3640
padding-left: 20px;

web/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
<div class="ui-ClassInfo">
3333
<span id="className"></span>
3434
</div>
35+
<div class="ui-toolBar">
36+
<div id="button.zoomIn" class="icon plus"></div>
37+
<div id="button.zoomNormal" class="icon scaleNormal"></div>
38+
<div id="button.zoomOut" class="icon minus"></div>
39+
</div>
3540
<div id="classView">
3641

3742
</div>

web/js/CacheUMLExplorer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ var CacheUMLExplorer = function (treeViewContainer, classViewContainer) {
1111
this.elements = {
1212
className: document.getElementById("className"),
1313
treeViewContainer: treeViewContainer,
14-
classViewContainer: classViewContainer
14+
classViewContainer: classViewContainer,
15+
zoomInButton: document.getElementById("button.zoomIn"),
16+
zoomOutButton: document.getElementById("button.zoomOut"),
17+
zoomNormalButton: document.getElementById("button.zoomNormal")
1518
};
1619

1720
this.source = new Source();

web/js/ClassView.js

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,59 @@ ClassView.prototype.resetView = function () {
6060

6161
};
6262

63+
/**
64+
* @param {string} name
65+
* @param classMetaData
66+
* @returns {joint.shapes.uml.Class}
67+
*/
68+
ClassView.prototype.createClassInstance = function (name, classMetaData) {
69+
70+
var attrArr, methArr,
71+
classParams = classMetaData["parameters"],
72+
classProps = classMetaData["properties"],
73+
classMethods = classMetaData["methods"];
74+
75+
var insertString = function (array, string) {
76+
string.match(/.{1,44}/g).forEach(function (p) {
77+
array.push(p);
78+
});
79+
};
80+
81+
return new joint.shapes.uml.Class({
82+
name: name,
83+
attributes: attrArr = (function (params, ps) {
84+
var arr = [], n;
85+
for (n in params) {
86+
insertString(arr, n + (params[n]["type"] ? ": " + params[n]["type"] : ""));
87+
}
88+
for (n in ps) {
89+
insertString(
90+
arr,
91+
(ps[n]["private"] ? "- " : "+ ") + n
92+
+ (ps[n]["type"] ? ": " + ps[n]["type"] : "")
93+
);
94+
}
95+
return arr;
96+
})(classParams, classProps),
97+
methods: methArr = (function (ps) {
98+
var arr = [], n;
99+
for (n in ps) {
100+
insertString(arr, "+ " + n + (ps[n]["returns"] ? ": " + ps[n]["returns"] : ""));
101+
}
102+
return arr;
103+
})(classMethods),
104+
size: {
105+
width: 300,
106+
height: Math.max(attrArr.length*12.1, 15) + Math.max(methArr.length*12.1, 15) + 40
107+
}
108+
});
109+
110+
};
111+
63112
ClassView.prototype.render = function (data) {
64113

65-
var p, pp, className, classProps, classMethods, classInstance,
66-
uml = joint.shapes.uml, attrArr, methArr, relFrom, relTo,
114+
var p, pp, className, classInstance,
115+
uml = joint.shapes.uml, relFrom, relTo,
67116
classes = {}, connector;
68117

69118
if (!data["classes"]) {
@@ -72,36 +121,7 @@ ClassView.prototype.render = function (data) {
72121
}
73122

74123
for (className in data["classes"]) {
75-
classProps = data["classes"][className]["properties"];
76-
classMethods = data["classes"][className]["methods"];
77-
78-
classInstance = new uml.Class({
79-
name: className,
80-
attributes: attrArr = (function (ps) {
81-
var arr = [], n, s;
82-
for (n in ps) {
83-
s = (ps[n]["private"] ? "- " : "+ ") + n + ": " + ps[n]["type"];
84-
s.match(/.{1,44}/g).forEach(function (p) {
85-
arr.push(p);
86-
});
87-
}
88-
return arr;
89-
})(classProps),
90-
methods: methArr = (function (ps) {
91-
var arr = [], n, s;
92-
for (n in ps) {
93-
s = "+ " + n + (ps[n]["returns"] ? ": " + ps[n]["returns"] : "");
94-
s.match(/.{1,44}/g).forEach(function (p) {
95-
arr.push(p);
96-
});
97-
}
98-
return arr;
99-
})(classMethods),
100-
size: {
101-
width: 300,
102-
height: Math.max(attrArr.length*12.1, 15) + Math.max(methArr.length*12.1, 15) + 40
103-
}
104-
});
124+
classInstance = this.createClassInstance(className, data["classes"][className]);
105125
this.objects.push(classInstance);
106126
classes[className] = {
107127
instance: classInstance
@@ -168,20 +188,26 @@ ClassView.prototype.updateSizes = function () {
168188
/**
169189
* Scale view according to delta.
170190
*
171-
* @param {number} delta
191+
* @param {number|string} delta
172192
*/
173193
ClassView.prototype.zoom = function (delta) {
174194

175195
var scaleOld = this.PAPER_SCALE, scaleDelta;
176-
this.PAPER_SCALE += delta*Math.min(0.5, Math.abs(this.PAPER_SCALE - (delta < 0 ? this.MIN_PAPER_SCALE : this.MAX_PAPER_SCALE))/2);
177-
this.paper.scale(
178-
this.PAPER_SCALE,
179-
this.PAPER_SCALE
180-
);
196+
if (typeof delta === "number") {
197+
this.PAPER_SCALE += delta *Math.min(
198+
0.5,
199+
Math.abs(this.PAPER_SCALE - (delta < 0 ? this.MIN_PAPER_SCALE : this.MAX_PAPER_SCALE))/2
200+
);
201+
} else {
202+
this.PAPER_SCALE = 1;
203+
}
204+
this.paper.scale(this.PAPER_SCALE, this.PAPER_SCALE);
181205
scaleDelta = this.PAPER_SCALE - scaleOld;
182206
this.paper.setOrigin(
183-
this.paper.options.origin.x - scaleDelta*this.cacheUMLExplorer.elements.classViewContainer.offsetWidth/2,
184-
this.paper.options.origin.y - scaleDelta*this.cacheUMLExplorer.elements.classViewContainer.offsetHeight/2
207+
this.paper.options.origin.x
208+
- scaleDelta*this.cacheUMLExplorer.elements.classViewContainer.offsetWidth/2,
209+
this.paper.options.origin.y
210+
- scaleDelta*this.cacheUMLExplorer.elements.classViewContainer.offsetHeight/2
185211
);
186212

187213
};
@@ -244,6 +270,15 @@ ClassView.prototype.init = function () {
244270
this.cacheUMLExplorer.elements.classViewContainer.addEventListener("mousewheel", function (e) {
245271
self.zoom(Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))));
246272
});
273+
this.cacheUMLExplorer.elements.zoomInButton.addEventListener("click", function () {
274+
self.zoom(1);
275+
});
276+
this.cacheUMLExplorer.elements.zoomOutButton.addEventListener("click", function () {
277+
self.zoom(-1);
278+
});
279+
this.cacheUMLExplorer.elements.zoomNormalButton.addEventListener("click", function () {
280+
self.zoom(null);
281+
});
247282

248283
//var classes = {
249284
//

0 commit comments

Comments
 (0)