Sidebar-Instrument.js 2.06 KB

(function () {
	// Adds Atlassian shapes
	// instrument 仪表
	Sidebar.prototype.addInstrumentPalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { DEFAULT } = this.enumComponentType
		const gn = 'mxgraph.instrument';
		const dt = 'instrument';
		const label = '仪表'
		const width = 66;
		const height = 74;
		const staticPath = `${Proxy_Prefix}/img/lib/thingskit/`
		const prefix = 'image;image=img/lib/thingskit/'
		const defaultStyle = ';imageAspect=0;'
		this.setCurrentSearchEntryLibrary(dt);

		// 自定义属性
		const cellAttribute = {
			[COMPONENT_TYPE]: DEFAULT
		}

		const graphPathLib = [
			{ name: '仪表 1.svg', path: 'instrument/仪表 1.svg' },
			{ name: '仪表 10.svg', path: 'instrument/仪表 10.svg' },
			{ name: '仪表 11.svg', path: 'instrument/仪表 11.svg' },
			{ name: '仪表 12.svg', path: 'instrument/仪表 12.svg' },
			{ name: '仪表 2.svg', path: 'instrument/仪表 2.svg' },
			{ name: '仪表 3.svg', path: 'instrument/仪表 3.svg' },
			{ name: '仪表 4.svg', path: 'instrument/仪表 4.svg' },
			{ name: '仪表 5.svg', path: 'instrument/仪表 5.svg' },
			{ name: '仪表 6.svg', path: 'instrument/仪表 6.svg' },
			{ name: '仪表 7.svg', path: 'instrument/仪表 7.svg' },
			{ name: '仪表 8.svg', path: 'instrument/仪表 8.svg' },
			{ name: '仪表 9.svg', path: 'instrument/仪表 9.svg' },
		]

		const lib = graphPathLib.map(item => {
			item.staticPath = staticPath + item.path
			return item
		})

		const fns = graphPathLib.map(item => {
			return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
				const cell = new mxCell('', new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
				cell.setVertex(true)
				this.setCellAttributes(cell, cellAttribute)
				return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
			}));
		})

		this.setVariableImageLib(dt, label, lib)

		this.addPaletteFunctions(dt, label, false, fns);

		this.setCurrentSearchEntryLibrary();
	};
})();