-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.html
116 lines (104 loc) · 3.99 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>DiagramFlowJS Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="diagramflow.js"></script>
</head>
<body>
<h1>DiagramFlowJS Demo</h1>
<a target="github" href="http://github.com/luisalvesmartins">Github source</a>
<div style="position:relative;width:800px;height:500px">
<canvas id="myCanvas" width="100" height="100" tabindex="1"></canvas>
</div>
<div id="divSelectedNode"></div>
<script>
var img = new Image();
img.onload = function() {
model.draw()
}
img.src = "web.svg";
var Figures={
Rectangle:function(ctx,node){
ctx.beginPath();
ctx.fillStyle=node.fillStyle;
ctx.strokeStyle="blue";
ctx.fillRect(node.x, node.y, node.w, node.h);
ctx.fillStyle="black";
ctx.font="10px Verdana";
ctx.textBaseline="top";
node.textfill(ctx);
},
Circle:function(ctx,node){
ctx.beginPath();
ctx.fillStyle=node.fillStyle;
ctx.ellipse(node.x+node.w/2,node.y+node.h/2, node.w/2, node.h/2, 0, 0, 2 * Math.PI);
ctx.fill();
node.textfill(ctx);
},
Diamond:function(ctx,node){
ctx.beginPath();
ctx.fillStyle=node.fillStyle;
ctx.moveTo(node.x,node.y+node.h/2);
ctx.lineTo(node.x+node.w/2,node.y);
ctx.lineTo(node.x+node.w,node.y+node.h/2);
ctx.lineTo(node.x+node.w/2,node.y+node.h);
ctx.fill();
node.textfill(ctx);
},
Icon:function(ctx,node){
ctx.beginPath();
ctx.fillStyle=node.fillStyle;
ctx.strokeStyle="blue";
ctx.fillRect(node.x, node.y, node.w, node.h);
ctx.drawImage(img,node.x-24,node.y-10,150,116);
ctx.fillStyle="black";
ctx.textAlign="left"
ctx.fillText(node.text,node.x+5,node.y+85)
ctx.stroke();
}
}
var connectorDecoration={fillStyle:"green", strokeStyle: "black",
highlightStrokeStyle:"red", highlightText:"black"};
var connectorDecoration1={fillStyle:"red", strokeStyle: "orange",
highlightStrokeStyle:"red", highlightText:"black"};
var optionsInput={
dropAllowed:true,
dragAllowed:false,
radius:7};
var optionsOutput={dropAllowed:false, dragAllowed:true, radius:7};
var connectors=[
new model.connector(0,.25,"input","input1",connectorDecoration1,optionsInput),
new model.connector(1,.3,"output","output1",connectorDecoration,optionsOutput),
new model.connector(1,.6,"mixed","mixed connector",connectorDecoration),
];
model.addNode(new model.node(110,10,100,100,connectors,"A Square, dblclick me to edit the text","green","Rectangle"));
model.addNode(new model.node(30,140,100,100,null,"A Circle, click on the center handle to move","white", "Circle"));
var connectors2=[
new model.connector(0.75,.75,"output")
];
model.addNode(new model.node(250,10,150,150,connectors2,"A Diamond, click on the corner handle to resize.","yellow", "Diamond"));
model.addNode(new model.node(280,250,150,100,connectors,"A Rectangle, drag from the diamond to here to link.","Cyan", "Rectangle"));
model.addNode(new model.node(470,50,100,100,connectors,"An Image","white", "Icon"));
model.addLink(new model.link(0,3,1,0,"straight line","straight"));
model.addLink(new model.link(3,4,1,1,"dblclick me to edit","square"));
model.addLink(new model.link(4,2,0,0,"square line","square"));
model.init("myCanvas");
model.draw();
// Add an event listener
document.addEventListener("selectionChanged", function(e) {
document.getElementById("divSelectedNode").innerText="Selected node:" + e.detail;
});
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-135656500-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-135656500-1');
</script>
</body>
</html>