Skip to content

Commit 5e347b2

Browse files
composition visualizing
1 parent a2d355a commit 5e347b2

File tree

4 files changed

+32
-38
lines changed

4 files changed

+32
-38
lines changed

cache/projectTemplate.xml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Class name="UMLExplorer.ClassView">
44
<Description>
55
Class contains methods that return structured class data.</Description>
6-
<TimeChanged>63670,70761.169478</TimeChanged>
6+
<TimeChanged>63670,72515.130814</TimeChanged>
77
<TimeCreated>63653,67019.989197</TimeCreated>
88

99
<Method name="getClassTree">
@@ -70,8 +70,8 @@ return structured data about class</Description>
7070
do oProp.%DispatchSetProperty("private", p.Private)
7171
do oProp.%DispatchSetProperty("readOnly", p.ReadOnly)
7272
do oProp.%DispatchSetProperty("type", p.Type)
73-
do ..collectAggregation(oData, classDefinition.Name, p.Type)
74-
do ..collectAggregation(oData, classDefinition.Name, basePack _ "." _ p.Type)
73+
do ..collectAggregation(oData, classDefinition.Name, p.Type, p.Private)
74+
do ..collectAggregation(oData, classDefinition.Name, basePack _ "." _ p.Type, p.Private)
7575
}
7676
7777
set oMethods = ##class(%ZEN.proxyObject).%New()
@@ -143,15 +143,16 @@ return structured data about class</Description>
143143

144144
<Method name="collectAggregation">
145145
<ClassMethod>1</ClassMethod>
146-
<FormalSpec>oData:%ZEN.proxyObject,className:%String,type:%String</FormalSpec>
146+
<FormalSpec>oData:%ZEN.proxyObject,className:%String,type:%String,private:%String</FormalSpec>
147147
<ReturnType>%Status</ReturnType>
148148
<Implementation><![CDATA[
149149
set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(type)
150150
if (classDef '= "") {
151-
set oAgg = oData.aggregation.%DispatchGetProperty(className)
151+
if (private) { set t = "composition" } else { set t = "aggregation" }
152+
set oAgg = oData.%DispatchGetProperty(t).%DispatchGetProperty(className)
152153
if (oAgg = "") {
153154
set oAgg = ##class(%ZEN.proxyObject).%New()
154-
do oData.aggregation.%DispatchSetProperty(className, oAgg)
155+
do oData.%DispatchGetProperty(t).%DispatchSetProperty(className, oAgg)
155156
}
156157
} else { quit $$$OK }
157158
@@ -198,6 +199,7 @@ return structured data about class</Description>
198199
set oData.classes = ##class(%ZEN.proxyObject).%New()
199200
set oData.inheritance = ##class(%ZEN.proxyObject).%New()
200201
set oData.aggregation = ##class(%ZEN.proxyObject).%New()
202+
set oData.composition = ##class(%ZEN.proxyObject).%New()
201203
202204
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
203205
do classes.Execute()
@@ -218,7 +220,7 @@ return structured data about class</Description>
218220
</Class>
219221

220222

221-
<Project name="UMLExplorer" LastModified="2015-04-28 19:17:47.344256">
223+
<Project name="UMLExplorer" LastModified="2015-04-28 19:55:49.450783">
222224
<Items>
223225
<ProjectItem name="UMLExplorer.ClassView" type="CLS"></ProjectItem>
224226
<ProjectItem name="UMLExplorer.Router" type="CLS"></ProjectItem>

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

web/js/ClassView.js

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
138138

139139
ClassView.prototype.render = function (data) {
140140

141-
var p, pp, className, classInstance,
141+
var self = this, p, pp, className, classInstance,
142142
uml = joint.shapes.uml, relFrom, relTo,
143143
classes = {}, connector;
144144

@@ -158,37 +158,29 @@ ClassView.prototype.render = function (data) {
158158

159159
}
160160

161-
for (p in data["inheritance"]) {
162-
relFrom = (classes[p] || {}).instance;
163-
for (pp in data["inheritance"][p]) {
164-
relTo = (classes[pp] || {}).instance;
165-
if (relFrom && relTo) {
166-
this.graph.addCell(connector = new uml.Generalization({
167-
source: { id: relFrom.id },
168-
target: { id: relTo.id },
169-
router: { name: "manhattan" },
170-
connector: { name: "rounded" }
171-
}));
172-
this.links.push(connector);
161+
var link = function (type) {
162+
var name = type === "inheritance" ? "Generalization" :
163+
type === "aggregation" ? "Aggregation" : "Composition";
164+
for (p in data[type]) {
165+
relFrom = (classes[p] || {}).instance;
166+
for (pp in data[type][p]) {
167+
relTo = (classes[pp] || {}).instance;
168+
if (relFrom && relTo) {
169+
self.graph.addCell(connector = new uml[name]({
170+
source: { id: type === "inheritance" ? relFrom.id : relTo.id },
171+
target: { id: type === "inheritance" ? relTo.id : relFrom.id },
172+
router: { name: "manhattan" },
173+
connector: { name: "rounded" }
174+
}));
175+
self.links.push(connector);
176+
}
173177
}
174178
}
175-
}
179+
};
176180

177-
for (p in data["aggregation"]) {
178-
relTo = (classes[p] || {}).instance;
179-
for (pp in data["aggregation"][p]) {
180-
relFrom = (classes[pp] || {}).instance;
181-
if (relFrom && relTo) {
182-
this.graph.addCell(connector = new uml.Aggregation({
183-
source: { id: relFrom.id },
184-
target: { id: relTo.id },
185-
router: { name: "manhattan" },
186-
connector: { name: "rounded" }
187-
}));
188-
this.links.push(connector);
189-
}
190-
}
191-
}
181+
link("inheritance");
182+
link("composition");
183+
link("aggregation");
192184

193185
joint.layout.DirectedGraph.layout(this.graph, {
194186
setLinkVertices: false,

web/jsLib/joint.shapes.uml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ joint.shapes.uml.Aggregation = joint.dia.Link.extend({
190190
joint.shapes.uml.Composition = joint.dia.Link.extend({
191191
defaults: {
192192
type: 'uml.Composition',
193-
attrs: { '.marker-target': { d: 'M 40 10 L 20 20 L 0 10 L 20 0 z', fill: 'black' }}
193+
attrs: { '.marker-target': { d: 'M 20 10 L 10 15 L 0 10 L 10 5 z', fill: 'black' }}
194194
}
195195
});
196196

0 commit comments

Comments
 (0)