Added images and made the visualizator work
[VSoRC/.git] / js / joint.shapes.erd.js
1 /*! JointJS v0.9.0 - JavaScript diagramming library  2014-05-13 
2
3
4 This Source Code Form is subject to the terms of the Mozilla Public
5 License, v. 2.0. If a copy of the MPL was not distributed with this
6 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 if (typeof exports === 'object') {
9
10     var joint = {
11         util: require('../src/core').util,
12         shapes: {},
13         dia: {
14             Element: require('../src/joint.dia.element').Element,
15             Link: require('../src/joint.dia.link').Link
16         }
17     };
18 }
19
20
21 joint.shapes.erd = {};
22
23 joint.shapes.erd.Entity = joint.dia.Element.extend({
24
25     markup: '<g class="rotatable"><g class="scalable"><polygon class="outer"/><polygon class="inner"/></g><text/></g>',
26
27     defaults: joint.util.deepSupplement({
28
29         type: 'erd.Entity',
30         size: { width: 150, height: 60 },
31         attrs: {
32             '.outer': {
33                 fill: '#2ECC71', stroke: '#27AE60', 'stroke-width': 2,
34                 points: '100,0 100,60 0,60 0,0'
35             },
36             '.inner': {
37                 fill: '#2ECC71', stroke: '#27AE60', 'stroke-width': 2,
38                 points: '95,5 95,55 5,55 5,5',
39                 display: 'none'
40             },
41             text: {
42                 text: 'Entity',
43                 'font-family': 'Arial', 'font-size': 14,
44                 ref: '.outer', 'ref-x': .5, 'ref-y': .5,
45                 'x-alignment': 'middle', 'y-alignment': 'middle'
46             }
47         }
48
49     }, joint.dia.Element.prototype.defaults)
50 });
51
52 joint.shapes.erd.WeakEntity = joint.shapes.erd.Entity.extend({
53
54     defaults: joint.util.deepSupplement({
55
56         type: 'erd.WeakEntity',
57
58         attrs: {
59             '.inner' : { display: 'auto' },
60             text: { text: 'Weak Entity' }
61         }
62
63     }, joint.shapes.erd.Entity.prototype.defaults)
64 });
65
66 joint.shapes.erd.Relationship = joint.dia.Element.extend({
67
68     markup: '<g class="rotatable"><g class="scalable"><polygon class="outer"/><polygon class="inner"/></g><text/></g>',
69     
70     defaults: joint.util.deepSupplement({
71
72         type: 'erd.Relationship',
73         size: { width: 80, height: 80 },
74         attrs: {
75             '.outer': {
76                 fill: '#3498DB', stroke: '#2980B9', 'stroke-width': 2,
77                 points: '40,0 80,40 40,80 0,40'
78             },
79             '.inner': {
80                 fill: '#3498DB', stroke: '#2980B9', 'stroke-width': 2,
81                 points: '40,5 75,40 40,75 5,40',
82                 display: 'none'
83             },
84             text: {
85                 text: 'Relationship',
86                 'font-family': 'Arial', 'font-size': 12,
87                 ref: '.', 'ref-x': .5, 'ref-y': .5,
88                 'x-alignment': 'middle', 'y-alignment': 'middle'
89             }
90         }
91
92     }, joint.dia.Element.prototype.defaults)
93 });
94
95 joint.shapes.erd.IdentifyingRelationship = joint.shapes.erd.Relationship.extend({
96
97     defaults: joint.util.deepSupplement({
98
99         type: 'erd.IdentifyingRelationship',
100
101         attrs: {
102             '.inner': { display: 'auto' },
103             text: { text: 'Identifying' }
104         }
105
106     }, joint.shapes.erd.Relationship.prototype.defaults)
107 });
108
109 joint.shapes.erd.Attribute = joint.dia.Element.extend({
110
111     markup: '<g class="rotatable"><g class="scalable"><ellipse class="outer"/><ellipse class="inner"/></g><text/></g>',
112
113     defaults: joint.util.deepSupplement({
114
115         type: 'erd.Attribute',
116         size: { width: 100, height: 50 },
117         attrs: {
118             'ellipse': {
119                 transform: 'translate(50, 25)'
120             },
121             '.outer': {
122                 stroke: '#D35400', 'stroke-width': 2,
123                 cx: 0, cy: 0, rx: 50, ry: 25,
124                 fill: '#E67E22'
125             },
126             '.inner': {
127                 stroke: '#D35400', 'stroke-width': 2,
128                 cx: 0, cy: 0, rx: 45, ry: 20,
129                 fill: 'transparent', display: 'none'
130             },
131             text: {
132                  'font-family': 'Arial', 'font-size': 14,
133                  ref: '.', 'ref-x': .5, 'ref-y': .5,
134                  'x-alignment': 'middle', 'y-alignment': 'middle'
135              }
136          }
137
138      }, joint.dia.Element.prototype.defaults)
139
140  });
141
142  joint.shapes.erd.Multivalued = joint.shapes.erd.Attribute.extend({
143
144      defaults: joint.util.deepSupplement({
145
146          type: 'erd.Multivalued',
147
148          attrs: {
149              '.inner': { display: 'block' },
150              text: { text: 'multivalued' }
151          }
152      }, joint.shapes.erd.Attribute.prototype.defaults)
153  });
154
155  joint.shapes.erd.Derived = joint.shapes.erd.Attribute.extend({
156
157      defaults: joint.util.deepSupplement({
158
159          type: 'erd.Derived',
160
161          attrs: {
162              '.outer': { 'stroke-dasharray': '3,5' },
163              text: { text: 'derived' }
164          }
165
166      }, joint.shapes.erd.Attribute.prototype.defaults)
167  });
168
169  joint.shapes.erd.Key = joint.shapes.erd.Attribute.extend({
170
171      defaults: joint.util.deepSupplement({
172
173          type: 'erd.Key',
174
175          attrs: {
176              ellipse: { 'stroke-width': 4 },
177              text: { text: 'key', 'font-weight': 'bold', 'text-decoration': 'underline' }
178          }
179      }, joint.shapes.erd.Attribute.prototype.defaults)
180 });
181
182 joint.shapes.erd.Normal = joint.shapes.erd.Attribute.extend({
183
184     defaults: joint.util.deepSupplement({
185
186         type: 'erd.Normal',
187
188         attrs: { text: { text: 'Normal' }}
189
190     }, joint.shapes.erd.Attribute.prototype.defaults)
191 });
192
193 joint.shapes.erd.ISA = joint.dia.Element.extend({
194
195     markup: '<g class="rotatable"><g class="scalable"><polygon/></g><text/></g>',
196
197     defaults: joint.util.deepSupplement({
198
199         type: 'erd.ISA',
200         size: { width: 100, height: 50 },
201         attrs: {
202             polygon: {
203                 points: '0,0 50,50 100,0',
204                 fill: '#F1C40F', stroke: '#F39C12', 'stroke-width': 2
205             },
206             text: {
207                 text: 'ISA',
208                 ref: '.', 'ref-x': .5, 'ref-y': .3,
209                 'x-alignment': 'middle', 'y-alignment': 'middle'
210             }
211         }
212
213     }, joint.dia.Element.prototype.defaults)
214
215 });
216
217 joint.shapes.erd.Line = joint.dia.Link.extend({
218
219     defaults: { type: "erd.Line" },
220
221     cardinality: function(value) {
222         this.set('labels', [{ position: -20, attrs: { text: { dy: -8, text: value }}}]);
223     }
224 });
225
226 if (typeof exports === 'object') {
227
228     module.exports = joint.shapes.erd;
229 }