Skip to content

Commit 7d9e94a

Browse files
committed
upgrade to JointJS v0.9.3
1 parent 76c4bbc commit 7d9e94a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+9026
-2380
lines changed

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = function(grunt) {
3131
'shapes.pn': ['plugins/joint.shapes.pn.js'],
3232
'shapes.devs': ['plugins/joint.shapes.devs.js'],
3333
'shapes.uml': ['plugins/joint.shapes.uml.js'],
34+
'shapes.logic': ['plugins/joint.shapes.logic.js'],
3435

3536
'layout.DirectedGraph': ['plugins/layout/DirectedGraph/lib/dagre.js', 'plugins/layout/DirectedGraph/joint.layout.DirectedGraph.js']
3637
}

demo/basic.js

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var graph = new joint.dia.Graph;
22

33
var paper = new joint.dia.Paper({
4-
54
el: $('#paper'),
65
width: 650,
76
height: 400,
87
gridSize: 20,
9-
model: graph
8+
model: graph,
9+
linkConnectionPoint: joint.util.shapePerimeterConnectionPoint
1010
});
1111

1212
var rb = new joint.shapes.basic.Rect({
@@ -35,7 +35,7 @@ var ib = new joint.shapes.basic.Image({
3535
size: { width: 40, height: 40 },
3636
attrs: {
3737
text: { text: 'basic.Image' },
38-
image: { 'xlink:href': 'https://cdn3.iconfinder.com/data/icons/betelgeuse/96/224386-folder-image-48.png', width: 48, height: 48 }
38+
image: { 'xlink:href': 'http://placehold.it/48x48', width: 48, height: 48 }
3939
}
4040
});
4141
graph.addCell(ib);
@@ -166,3 +166,67 @@ rb.on('change:attrs', function(element) {
166166
element.resize(width + 10, height);
167167
});
168168

169+
// Image decorated rectangle shape example.
170+
171+
joint.shapes.basic.DecoratedRect = joint.shapes.basic.Generic.extend({
172+
173+
markup: '<g class="rotatable"><g class="scalable"><rect/></g><image/><text/></g>',
174+
175+
defaults: joint.util.deepSupplement({
176+
177+
type: 'basic.DecoratedRect',
178+
size: { width: 100, height: 60 },
179+
attrs: {
180+
'rect': { fill: '#FFFFFF', stroke: 'black', width: 100, height: 60 },
181+
'text': { 'font-size': 14, text: '', 'ref-x': .5, 'ref-y': .5, ref: 'rect', 'y-alignment': 'middle', 'x-alignment': 'middle', fill: 'black' },
182+
'image': { 'ref-x': 2, 'ref-y': 2, ref: 'rect', width: 16, height: 16 }
183+
}
184+
185+
}, joint.shapes.basic.Generic.prototype.defaults)
186+
});
187+
188+
var decoratedRect = new joint.shapes.basic.DecoratedRect({
189+
position: { x: 150, y: 80 },
190+
size: { width: 100, height: 60 },
191+
attrs: {
192+
text: { text: 'My Element' },
193+
image: { 'xlink:href': 'http://placehold.it/16x16' }
194+
}
195+
});
196+
graph.addCell(decoratedRect);
197+
198+
199+
joint.shapes.basic.Cylinder = joint.shapes.basic.Generic.extend({
200+
201+
markup: '<g class="rotatable"><g class="scalable"><path/></g><text/></g>',
202+
203+
defaults: joint.util.deepSupplement({
204+
205+
type: 'basic.Cylinder',
206+
size: { width: 40, height: 40 },
207+
attrs: {
208+
'path': {
209+
fill: '#FFFFFF', stroke: '#cbd2d7', 'stroke-width': 3,
210+
d: [
211+
'M 0 10 C 10 5, 30 5, 40 10 C 30 15, 10 15, 0 10',
212+
'L 0 20',
213+
'C 10 25, 30 25, 40 20',
214+
'L 40 10'
215+
].join(' ')
216+
},
217+
'text': { fill: '#435460', 'font-size': 14, text: '', 'ref-x': .5, 'ref-y': .7, ref: 'path', 'y-alignment': 'middle', 'text-anchor': 'middle', fill: 'black', 'font-family': 'Arial, helvetica, sans-serif' }
218+
}
219+
220+
}, joint.shapes.basic.Generic.prototype.defaults)
221+
});
222+
223+
224+
var cylinder = new joint.shapes.basic.Cylinder({
225+
position: { x: 200, y: 200 },
226+
size: { width: 180, height: 150 },
227+
attrs: {
228+
text: { text: 'SEQUENCE\nLIBRARY' }
229+
}
230+
});
231+
232+
graph.addCell(cylinder);

demo/links-sticky-points.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,7 @@ var paper = new joint.dia.Paper({
66
gridSize: 10,
77
perpendicularLinks: false,
88
model: graph,
9-
linkConnectionPoint: function(linkView, view, magnet, reference) {
10-
11-
var bbox = view.getStrokeBBox(magnet);
12-
13-
if (magnet && magnet.isPointInStroke && _.contains(['path', 'circle', 'rect'], magnet.localName)) {
14-
15-
spot = intersection(magnet, reference);
16-
17-
} else {
18-
19-
spot = g.rect(bbox).intersectionWithLineFromCenterToPoint(reference);
20-
}
21-
22-
return spot || g.rect(bbox).center();
23-
}
9+
linkConnectionPoint: joint.util.shapePerimeterConnectionPoint
2410
});
2511

2612
// Shortcuts.
@@ -67,7 +53,7 @@ var palm = 'M14.296,27.885v-2.013c0,0-0.402-1.408-1.073-2.013c-0.671-0.604-1.274
6753
var icons = [cross, star, umbrella, music, thunder, palm];
6854

6955
var d = star;
70-
var o7 = (new path({ position: { x: 150, y: 370 }, attrs: { text: { text: 'path' }, path: { magnet: true, d: d }}})).addTo(graph);
56+
var o7 = (new path({ position: { x: 150, y: 370 }, attrs: { text: { text: 'path' }, path: { d: d }}})).addTo(graph);
7157
var o8 = (new rect({ position: { x: 300, y: 380 }, size: { width: 60, height: 30 } })).addTo(graph);
7258
var linko7o8 = (new link({ source: { id: o7.id, selector: 'path' }, target: { id: o8.id } })).addTo(graph);
7359

@@ -77,6 +63,10 @@ paper.on('cell:pointerdown', function(cellView, evt, x, y) {
7763
}
7864
});
7965

66+
var o9 = (new text({ position: { x: 400, y: 50 }, size: { width: 60, height: 30 }, attrs: { text: { text: 'my text' } } })).addTo(graph);
67+
var o10 = o1.clone().position(500, 50).addTo(graph);
68+
var linko9o10 = (new link({ source: { id: o9.id, selector: 'text' }, target: { id: o10.id } })).addTo(graph);
69+
8070
function intersection(node, ref) {
8171

8272
var bbox = g.rect(V(node).bbox()).moveAndExpand(g.rect(-5, -5, 10, 10));

demo/links.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ var paper = new joint.dia.Paper({
1313
if (V(evt.target).hasClass('connection') || V(evt.target).hasClass('connection-wrap')) {
1414
this.addVertex({ x: x, y: y });
1515
}
16-
}
16+
},
17+
options: _.extend({}, joint.dia.LinkView.prototype.options, {
18+
doubleLinkTools: true,
19+
linkToolsOffset: 40,
20+
doubleLinkToolsOffset: 60
21+
})
1722
}),
1823
interactive: function(cellView) {
1924
if (cellView.model.get('vertexOnDblClick')) {

0 commit comments

Comments
 (0)