This repository was archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.ts
More file actions
58 lines (51 loc) · 2.28 KB
/
test.ts
File metadata and controls
58 lines (51 loc) · 2.28 KB
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
/**
* This file is an introduction for adding tests to mxgraph-type-definitions
* A larger infrastructure should be setup for a more robust solution: a file per types, in a dedicated subfolder (test
* or spec), ...
*/
// a custom shape without explicit constructor, so inherited from parent class: constructor(stencil: mxStencil)
class CustomShape extends mxShape {}
// Validate fix for #24
mxCellRenderer.registerShape("customShape", CustomShape);
mxCellRenderer.registerShape("customShape", mxActor);
// =====================================================================================================================
// shape properties not documented in the JS API
// =====================================================================================================================
function htmlElement(elementId: string):HTMLElement {
const element = document.getElementById(elementId);
if (element == null) {
throw new Error('Null html element');
}
return element;
}
const myShape = new mxShape(new mxStencil(htmlElement('container')));
myShape.fill = 'orange';
myShape.gradient = 'green';
myShape.gradientDirection = mxConstants.DIRECTION_NORTH;
myShape.opacity = 60;
myShape.fillOpacity = 100;
myShape.strokeOpacity = 80;
myShape.stroke = 'red';
myShape.strokewidth = 4;
myShape.isShadow = true;
myShape.isDashed = true;
myShape.spacing = 4;
myShape.startSize = 8;
myShape.endSize = 8;
myShape.isRounded = true;
myShape.startArrow = mxConstants.ARROW_BLOCK_THIN;
myShape.endArrow = mxConstants.ARROW_OPEN;
myShape.rotation = 75;
myShape.direction = mxConstants.DIRECTION_WEST;
myShape.glass = true;
myShape.flipH = false;
myShape.flipV = true;
myShape.constraints = [new mxConnectionConstraint()];
// =====================================================================================================================
// check inherited properties (previously directly defined in the class in mxgraph-type-definitions@1.0.3)
// =====================================================================================================================
const rectangleShape = new mxRectangleShape(new mxRectangle(0, 10, 100,40), 'black', 'orange');
rectangleShape.fill = 'yellow';
rectangleShape.stroke = 'black';
rectangleShape.strokewidth = 3;
rectangleShape.bounds = new mxRectangle(10, 10, 100,40);