Sidebar-Conduit.js 2.41 KB

(function () {
	// Adds Atlassian shapes
	// conduit 管道
	Sidebar.prototype.addConduitPalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { DEFAULT } = this.enumComponentType
		const gn = 'mxgraph.conduit';
		const dt = 'conduit';
		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: 'Y形接头.svg', path: 'conduit/Y形接头.svg' },
			{ name: '三通.svg', path: 'conduit/三通.svg' },
			{ name: '四通.svg', path: 'conduit/四通.svg' },
			{ name: '斜三通 上.svg', path: 'conduit/斜三通 上.svg' },
			{ name: '斜三通 下.svg', path: 'conduit/斜三通 下.svg' },
			{ name: '斜四通.svg', path: 'conduit/斜四通.svg' },
			{ name: '斜面弯管 1.svg', path: 'conduit/斜面弯管 1.svg' },
			{ name: '斜面弯管 2.svg', path: 'conduit/斜面弯管 2.svg' },
			{ name: '斜面弯管 3.svg', path: 'conduit/斜面弯管 3.svg' },
			{ name: '斜面弯管 4.svg', path: 'conduit/斜面弯管 4.svg' },
			{ name: '直管 2.svg', path: 'conduit/直管 2.svg' },
			{ name: '直管.svg', path: 'conduit/直管.svg' },
			{ name: '转换接头 2.svg', path: 'conduit/转换接头 2.svg' },
			{ name: '转换接头 3.svg', path: 'conduit/转换接头 3.svg' },
			{ name: '转换接头 4.svg', path: 'conduit/转换接头 4.svg' },
			{ name: '转换接头 5.svg', path: 'conduit/转换接头 5.svg' },
			{ name: '转换接头.svg', path: 'conduit/转换接头.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();
	};
})();