1/** 2 * Plugin that always creates a small black circle to represent a join 3 * when a new edge is dropped with the target end in free space 4 */ 5Draw.loadPlugin(function(ui) { 6 mxConnectionHandler.prototype.createTargetVertex = function(evt, source) 7 { 8 // Uses the first non-relative source 9 var geo = this.graph.getCellGeometry(source); 10 11 while (geo != null && geo.relative) 12 { 13 source = this.graph.getModel().getParent(source); 14 geo = this.graph.getCellGeometry(source); 15 } 16 17 // OVERRIDE clone to create a big filled black circle instead of cloning the source 18 var clone = this.graph.createVertex(this.graph.getModel().getParent(source), null, null, 0, 0, 6, 6, 'ellipse;fillColor=#000000;fixedPoints=0'); 19 var geo = this.graph.getModel().getGeometry(clone); 20 21 if (geo != null) 22 { 23 var point = this.graph.getPointForEvent(evt); 24 geo.x = this.graph.snap(point.x - geo.width / 2) - this.graph.panDx / this.graph.view.scale; 25 geo.y = this.graph.snap(point.y - geo.height / 2) - this.graph.panDy / this.graph.view.scale; 26 27 // Aligns with source if within certain tolerance 28 if (this.first != null) 29 { 30 var sourceState = this.graph.view.getState(source); 31 32 if (sourceState != null) 33 { 34 var tol = this.getAlignmentTolerance(); 35 36 if (Math.abs(this.graph.snap(this.first.x) - 37 this.graph.snap(point.x)) <= tol) 38 { 39 geo.x = sourceState.x; 40 } 41 else if (Math.abs(this.graph.snap(this.first.y) - 42 this.graph.snap(point.y)) <= tol) 43 { 44 geo.y = sourceState.y; 45 } 46 } 47 } 48 } 49 50 return clone; 51 }; 52});