同步操作将从 Gitee 极速下载/mxgraph 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!--Copyright (c) 2006-2013, JGraph LtdShape example for mxGraph. This example demonstrates how toimplement and use a custom shape.--><html><head><title>Shape example for mxGraph</title><!-- Sets the basepath for the library if not in same directory --><script type="text/javascript">mxBasePath = '../src';</script><!-- Loads and initializes the library --><script type="text/javascript" src="../src/js/mxClient.js"></script><!-- Example custom shape --><script type="text/javascript">/*The example shape is a "3D box" that looks like this:____/ /|/___/ || | /|___|/The code below defines the shape. The BoxShape functionit the constructor which creates a new object instance.*/function BoxShape(){mxCylinder.call(this);};/*The next lines use an mxCylinder instance to augment theprototype of the shape ("inheritance") and reset theconstructor to the topmost function of the c'tor chain.*/mxUtils.extend(BoxShape, mxCylinder);// Defines the extrusion of the box as a "static class variable"BoxShape.prototype.extrude = 10;/*Next, the mxCylinder's redrawPath method is "overridden".This method has a isForeground argument to separate twopaths, one for the background (which must be closed andmight be filled) and one for the foreground, which isjust a stroke.Foreground: /_____/||____Background: / |/ || /|____/*/BoxShape.prototype.redrawPath = function(path, x, y, w, h, isForeground){var dy = this.extrude * this.scale;var dx = this.extrude * this.scale;if (isForeground){path.moveTo(0, dy);path.lineTo(w - dx, dy);path.lineTo(w, 0);path.moveTo(w - dx, dy);path.lineTo(w - dx, h);}else{path.moveTo(0, dy);path.lineTo(dx, 0);path.lineTo(w, 0);path.lineTo(w, h - dy);path.lineTo(w - dx, h);path.lineTo(0, h);path.lineTo(0, dy);path.lineTo(dx, 0);path.close();}};mxCellRenderer.registerShape('box', BoxShape);</script><!-- Example code --><script type="text/javascript">// Program starts here. Creates a sample graph in the// DOM node with the specified ID. This function is invoked// from the onLoad event handler of the document (see below).function main(container){// Checks if browser is supportedif (!mxClient.isBrowserSupported()){// Displays an error message if the browser is// not supported.mxUtils.error('Browser is not supported!', 200, false);}else{// Creates the graph inside the DOM node.var graph = new mxGraph(container);// Disables basic selection and cell handlinggraph.setEnabled(false);// Changes the default style for vertices "in-place"// to use the custom shape.var style = graph.getStylesheet().getDefaultVertexStyle();style[mxConstants.STYLE_SHAPE] = 'box';// Adds a spacing for the label that matches the// extrusion sizestyle[mxConstants.STYLE_SPACING_TOP] = BoxShape.prototype.extrude;style[mxConstants.STYLE_SPACING_RIGHT] = BoxShape.prototype.extrude;// Adds a gradient and shadow to improve the user experiencestyle[mxConstants.STYLE_GRADIENTCOLOR] = '#FFFFFF';style[mxConstants.STYLE_SHADOW] = true;// Gets the default parent for inserting new cells. This// is normally the first child of the root (ie. layer 0).var parent = graph.getDefaultParent();// Adds cells to the model in a single stepgraph.getModel().beginUpdate();try{var v1 = graph.insertVertex(parent, null, 'Custom', 20, 20, 80, 60);var v2 = graph.insertVertex(parent, null, 'Shape', 200, 150, 80, 60);var e1 = graph.insertEdge(parent, null, '', v1, v2);}finally{// Updates the displaygraph.getModel().endUpdate();}}};</script></head><!-- Page passes the container for the graph to the program --><body onload="main(document.getElementById('graphContainer'))"><!-- Creates a container for the graph with a grid wallpaper --><div id="graphContainer"style="overflow:hidden;width:321px;height:241px;background:url('editors/images/grid.gif')"></div></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。