Sidebar-Valve.js 2.76 KB

(function () {
	// Adds Atlassian shapes
	// valve 阀门
	Sidebar.prototype.addValvePalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { DEFAULT } = this.enumComponentType
		const gn = 'mxgraph.valve';
		const dt = 'valve';
		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: '卸灰阀.svg', path: 'valve/卸灰阀.svg' },
			{ name: '双通阀.svg', path: 'valve/双通阀.svg' },
			{ name: '垂直单向阀.svg', path: 'valve/垂直单向阀.svg' },
			{ name: '垂直控制阀.svg', path: 'valve/垂直控制阀.svg' },
			{ name: '塑料旋启式止回阀.svg', path: 'valve/塑料旋启式止回阀.svg' },
			{ name: '夹管阀.svg', path: 'valve/夹管阀.svg' },
			{ name: '安全阀.svg', path: 'valve/安全阀.svg' },
			{ name: '手动阀 1.svg', path: 'valve/手动阀 1.svg' },
			{ name: '手动阀 2.svg', path: 'valve/手动阀 2.svg' },
			{ name: '控制阀 2.svg', path: 'valve/控制阀 2.svg' },
			{ name: '控制阀.svg', path: 'valve/控制阀.svg' },
			{ name: '旋转阀.svg', path: 'valve/旋转阀.svg' },
			{ name: '水平单向阀.svg', path: 'valve/水平单向阀.svg' },
			{ name: '水平控制阀.svg', path: 'valve/水平控制阀.svg' },
			{ name: '水平控制阀2.svg', path: 'valve/水平控制阀2.svg' },
			{ name: '水平控制阀3.svg', path: 'valve/水平控制阀3.svg' },
			{ name: '法兰控制阀.svg', path: 'valve/法兰控制阀.svg' },
			{ name: '球形阀 1.svg', path: 'valve/球形阀 1.svg' },
			{ name: '球形阀 2.svg', path: 'valve/球形阀 2.svg' },
			{ name: '球形阀 3.svg', path: 'valve/球形阀 3.svg' },
			{ name: '电动阀.svg', path: 'valve/电动阀.svg' },
			{ name: '阀门.svg', path: 'valve/阀门.svg' },
			{ name: '阀门2.svg', path: 'valve/阀门2.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();
	};
})();