lassoedAreasEnabled Property

Description

This property is used to control whether lassoed diagram areas will be enabled in the editor. To fully enable lassoed diagram areas int your application, you must set this property to true and define at least one lassoed areas action via the method defineLassoedAreaAction.

Valid values are true and false.

By default, lassoed diagram areas are not enabled.

To get the value of this property, use the ESDWeb object's get method.

To set the value of this property, use the ESDWeb object's set method or include this property in the configuration information passed to the startup method.

This property can only be set before calling the startup method or by including it in the configuration information passed to the startup method.

Example

editor = new ESDWeb(null, 'editorNode');

...

// Startup the editor with lassoed areas enabled.
editor.startup({
	requestTimeout: 10 * 1000, // Set the request timeout (10 seconds)
	lassoedAreasEnabled: true, // Enable lassoed areas
	beginZIndex: 50            // Set the z-index
});

...

// Define a lassoed area action that will export a lassoed area as an image.
var exportAction = this.editor.defineLassoedAreaAction('Export',
	function (rect) {
		// summary:
		//		Download a base64 encoded image of the portion of the diagram defined
		//		by rect.
		// rect: Object
		//      A rectangular diagram area defined by top, left, width, and height
		//		values.

		var aspectRatio = rect.width / rect.height,
			targetWidthHeight = 1200,
			width = targetWidthHeight,
			height = targetWidthHeight,
			exportOptions;

		if (aspectRatio < 1) {
			width = Math.ceil(width * aspectRatio);
		} else if (aspectRatio > 1) {
			height = Math.ceil(height / aspectRatio);
		}

		exportOptions = {
			image: true,
			format: 'image/jpeg',
			margin: 10,
			width: width,
			height: height,
			includePrefix: false,
			zoomTo: rect
		};

		editor.exportImage(
			exportOptions,
			function (image) {
				var byteCharacters = atob(image),
					byteNumbers = new Array(byteCharacters.length),
					byteArray,
					blob,
					i;
				for (i = 0; i < byteCharacters.length; i++) {
					byteNumbers[i] = byteCharacters.charCodeAt(i);
				}
				byteArray = new Uint8Array(byteNumbers);
				blob = new Blob([byteArray], {type: options.format});
				saveAs(blob, 'export' + '.' + options.format.substr(6));
			},
			onError('Export failed')
		);
	}
);