Skip to content

Commit d7f83b5

Browse files
authored
refactor(shapes)!: remove devs shapes; update standard shapes (#2425)
1 parent 29da5f0 commit d7f83b5

File tree

20 files changed

+524
-848
lines changed

20 files changed

+524
-848
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
The **Devs** demo introduces a ready-to-use shape with predefined input & output port groups and simplified API.
2+
3+
### joint.shapes.devs.Model
4+
5+
The Model shape implements simple API on top of the JointJS built-in ports. It splits ports into two semantic groups (**in** and **out**) and adds convenient methods for adding and removing ports.
6+
7+
| Attribute | Description |
8+
| --- | --- |
9+
| inPorts | an array of all input ports |
10+
| outPorts | an array of all output ports |
11+
12+
##### shapes.devs.Model.addInPort
13+
14+
element.addInPort(port, [opt])
15+
16+
Add a single port into the \`inPorts\` array, where \`port\` is a name of the port.
17+
18+
##### shapes.devs.Model.addOutPort
19+
20+
element.addOutPort(port, [opt])
21+
22+
Add a single port into the \`outPorts\` array, where \`port\` is a name of the port.
23+
24+
##### shapes.devs.Model.changeInGroup
25+
26+
element.changeInGroup(properties, [opt])
27+
28+
Change the settings for the input ports, where \`properties\` is an object with a [group configuration](https://resources.jointjs.com/docs/jointjs/v3.7/joint.html#dia.Element.ports.interface). It extends the previous settings with the new configuration by default. Pass `{ rewrite: true }` via `opt` to invalidate the previous settings.
29+
30+
##### shapes.devs.Model.changeOutGroup
31+
32+
element.changeOutGroup(properties, [opt])
33+
34+
Change the settings for the output ports, where \`properties\` is an object with a [group configuration](https://resources.jointjs.com/docs/jointjs/v3.7/joint.html#dia.Element.ports.interface). It extends the previous settings with the new configuration by default. Pass `{ rewrite: true }` via `opt` to invalidate the previous settings.
35+
36+
##### shapes.devs.Model.removeInPort
37+
38+
element.removeInPort(port, [opt])
39+
40+
Remove a port from an element from the \`inPorts\` array, where \`port\` is a name of the port.
41+
42+
##### shapes.devs.Model.removeOutPort
43+
44+
element.removeOutPort(port, [opt])
45+
46+
Remove a port from an element from the \`outPorts\` array, where \`port\` is a name of the port.
47+
48+
### joint.shapes.devs.Link
49+
50+
The `devs.Link` extends the `joint.shapes.standard.Link` and changes the link appearance.
51+
52+
#### Example usage
53+
54+
const shape = new joint.shapes.devs.Model({
55+
position: {
56+
x: 100,
57+
y: 100
58+
},
59+
inPorts: ['in1', 'in2'],
60+
outPorts: ['out1', 'out2']
61+
});
62+
63+
shape.addTo(graph);
64+
65+
// adding/removing ports dynamically
66+
shape.addInPort('in3');
67+
shape.removeOutPort('out1').addOutPort('out3');
68+
69+
const link = new joint.shapes.devs.Link({
70+
source: {
71+
id: shape.id,
72+
port: 'out3'
73+
},
74+
target: {
75+
x: 200,
76+
y: 300
77+
}
78+
});
79+
link.addTo(graph);
80+
81+
// moving the input ports from `left` to `top`
82+
shape.changeInGroup({ position: 'top' });
83+
// moving the output ports 'right' to 'bottom'
84+
shape.changeOutGroup({ position: 'bottom' });
85+
86+
87+
#### Hierarchical diagrams
88+
89+
There are two more shapes designed for hierarchical diagrams as part of the demo - `devs.Atomic` and `devs.Coupled`. They inherit from the `devs.Model` and differ only in the color and size. The purpose of these shapes is to enable you to implement a custom logic in your application based on their type. For instance a `devs.Coupled` can embed `devs.Atomic`'s but not the other way round as shown in the demo below.
90+
91+
When working with hierarchical diagrams there is a few methods, that might come in handy.
92+
93+
[`coupled.embed(atomic)`](https://resources.jointjs.com/docs/jointjs/v3.7/joint.html#dia.Element.prototype.embed) that can put the \`atomic\` shape into the \`coupled\`.
94+
95+
[`coupled.fitToChildren()`](https://resources.jointjs.com/docs/jointjs/v3.7/joint.html#dia.Element.prototype.fitToChildren) that resizes the \`coupled\` shape such that all embedded elements are visually contained within it.
96+
97+
[`link.reparent()`](https://resources.jointjs.com/docs/jointjs/v3.7/joint.html#dia.Link.prototype.reparent) that finds the best parent for the \`link\` based on the source and target element.

packages/joint-core/demo/devs/css/shapes.devs.css

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,6 @@ body {
5252
fill: #feb663;
5353
}
5454

55-
/* links */
56-
57-
.joint-link .connection {
58-
stroke: #4B4F6A;
59-
stroke-width: 4px;
60-
}
61-
62-
.joint-link .marker-arrowheads .marker-arrowhead,
63-
.joint-link .marker-vertex-group .marker-vertex,
64-
.joint-link .marker-vertex-group .marker-vertex:hover {
65-
fill: #31D0C6;
66-
}
67-
68-
.joint-link .marker-arrowheads .marker-arrowhead:hover {
69-
fill: #F39C12;
70-
}
71-
72-
.joint-link .link-tools .link-tool .tool-remove circle {
73-
fill: #fe854f;
74-
}
75-
7655
/* highlighting */
7756

7857
.highlighted-parent .body {

packages/joint-core/demo/devs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8"/>
5-
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
5+
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
66
<meta name="description" content="The JointJS Discrete Event System Specification demo serves as a template to help bring your idea to life in no time.">
77

88
<title>Discrete Event System Specification | JointJS</title>

0 commit comments

Comments
 (0)