1/**
2 * $Id: mxFlowchart.js,v 1.5 2016/04/1 12:32:06 mate Exp $
3 * Copyright (c) 2006-2018, JGraph Ltd
4 */
5//**********************************************************************************************************************************************************
6// Document 2
7//**********************************************************************************************************************************************************
8/**
9* Extends mxShape.
10*/
11function mxShapeFlowchartDocument2(bounds, fill, stroke, strokewidth)
12{
13	mxShape.call(this);
14	this.bounds = bounds;
15	this.fill = fill;
16	this.stroke = stroke;
17	this.strokewidth = (strokewidth != null) ? strokewidth : 1;
18	this.size = 0.5;
19};
20
21/**
22* Extends mxShape.
23*/
24mxUtils.extend(mxShapeFlowchartDocument2, mxActor);
25
26mxShapeFlowchartDocument2.prototype.cst = {DOCUMENT2 : 'mxgraph.flowchart.document2'};
27
28mxShapeFlowchartDocument2.prototype.customProperties = [
29	{name: 'size', dispName: 'Wave Size', type: 'float', min:0, max:1, defVal:0.25},
30];
31
32/**
33* Function: paintVertexShape
34*
35* Paints the vertex shape.
36*/
37mxShapeFlowchartDocument2.prototype.paintVertexShape = function(c, x, y, w, h)
38{
39	c.translate(x, y);
40
41	var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
42	var fy = 1.4;
43	var r = 5;
44
45	c.begin();
46	c.moveTo(w - r, 0);
47	c.arcTo(r, r, 0, 0, 1, w, r);
48	c.lineTo(w, h - dy / 2);
49	c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
50	c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
51	c.lineTo(0, dy / 2);
52	c.lineTo(0, r);
53	c.arcTo(r, r, 0, 0, 1, r, 0);
54	c.close();
55	c.fillAndStroke();
56
57};
58
59mxCellRenderer.registerShape(mxShapeFlowchartDocument2.prototype.cst.DOCUMENT2, mxShapeFlowchartDocument2);
60
61mxShapeFlowchartDocument2.prototype.constraints =
62	[new mxConnectionConstraint(new mxPoint(0.25, 0), false),
63    new mxConnectionConstraint(new mxPoint(0.5, 0), false),
64    new mxConnectionConstraint(new mxPoint(0.75, 0), false),
65	new mxConnectionConstraint(new mxPoint(0, 0.25), false),
66	new mxConnectionConstraint(new mxPoint(0, 0.5), false),
67	new mxConnectionConstraint(new mxPoint(0, 0.75), false),
68	new mxConnectionConstraint(new mxPoint(1, 0.25), false),
69	new mxConnectionConstraint(new mxPoint(1, 0.5), false),
70	new mxConnectionConstraint(new mxPoint(1, 0.75), false)];
71
72Graph.handleFactory[mxShapeFlowchartDocument2.prototype.cst.DOCUMENT2] = function(state)
73{
74	var handles = [Graph.createHandle(state, ['size'], function(bounds)
75	{
76		var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
77
78		return new mxPoint(bounds.x + 3 * bounds.width / 4, bounds.y + (1 - size) * bounds.height);
79
80	}, function(bounds, pt)
81	{
82		this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
83	})];
84
85	return handles;
86};
87