2 pepe1204 pepe1204 于 2014.12.10 10:29 提问

mxgraph看下自定义 线样式代码 加急! 2C

这段代码怎么改坐标,使线不重叠
graph.stylesheet.getDefaultEdgeStyle()[mxConstants.STYLE_EDGE] =
mxEdgeStyle.MyStyle = function(state, source, target, points, result)
{
var view = state.view;
var pt = (points != null && points.length > 0) ? points[0] : null;
var pts = state.absolutePoints;
var p0 = pts[0];
var pe = pts[pts.length-1];

        if (pt != null)
        {
            pt = view.transformControlPoint(state, pt);
        }

        if (p0 != null)
        {
            source = new mxCellState();
            source.x = p0.x;
            source.y = p0.y;
        }

        if (pe != null)
        {
            target = new mxCellState();
            target.x = pe.x;
            target.y = pe.y;
        }

        if (source != null && target != null)
        {
            var l = Math.max(source.x, target.x);
            var r = Math.min(source.x + source.width,
                             target.x + target.width);

            var x = (pt != null) ? pt.x : r + (l - r) / 2;

            var y1 = view.getRoutingCenterY(source);
            var y2 = view.getRoutingCenterY(target);

            if (pt != null)
            {
                if (pt.y >= source.y && pt.y <= source.y + source.height)
                {
                    y1 = pt.y;
                }

                if (pt.y >= target.y && pt.y <= target.y + target.height)
                {
                    y2 = pt.y;
                }
            }

            if (!mxUtils.contains(target, x, y1) &&
                !mxUtils.contains(source, x, y1))
            {
                result.push(new mxPoint(x,  y1));
            }

            if (!mxUtils.contains(target, x, y2) &&
                !mxUtils.contains(source, x, y2))
            {
                result.push(new mxPoint(x, y2));
            }

            if (result.length == 1)
            {
                if (pt != null)
                {
                    if (!mxUtils.contains(target, x, pt.y) &&
                        !mxUtils.contains(source, x, pt.y))
                    {
                        result.push(new mxPoint(x, pt.y));
                    }
                }
                else
                {   
                    var t = Math.max(source.y, target.y);
                    var b = Math.min(source.y + source.height,
                             target.y + target.height);

                    result.push(new mxPoint(x, t + (b - t) / 2));
                }
            }
        }
    };
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!