前言

ConnectionRouter 的作用是定义连线的展示样式.

是直线连接还是曲线连接(好像也是基于Bezier曲线)

位于包: draw2d.layout.connection 下。

常见的有:

1. DirectRouter  -- 用直线连接两个节点

2. ManhattanConnectionRouter -- 使用 曼哈顿距离算法, 效果看上去是直角折线连接的。

3. SplineConnectionRouter 从ManhattanConnectionRouter继承过来, 不过是曲线的效果

4. ManhattanBridgedConnectionRouter -- 当两个线相交时自动产生一个 桥出来。

本篇介绍的重点是解决一个IE下的问题。

实例

画两个椭圆, 用线把两个椭圆连接起来:

var oval2 =  new draw2d.shape.basic.Oval(100,80);
var port2 = new draw2d.HybridPort();
oval2.addPort(port2);
canvas.addFigure(oval2,200,200); var router = new draw2d.layout.connection.SplineConnectionRouter();
//var router = new draw2d.layout.connection.DirectRouter();
var conn = new draw2d.Connection(router)
conn.setSource(port1);
conn.setTarget(port2);
canvas.addFigure(conn);

这里使用SplineConnectionRouter这种连线连接。

在Firefox 和 Chrome 中是正常的。

但是到IE 下,却会报错

错误查找与解决

出错点就是在 SplineConnectionRouter定义的地方。

draw2d.layout.connection.SplineConnectionRouter = draw2d.layout.connection.ManhattanConnectionRouter.extend({
NAME: "draw2d.layout.connection.SplineConnectionRouter",
init: function () {
this.spline = new draw2d.util.spline.CubicSpline();
//this.spline = new draw2d.util.spline.BezierSpline();
//this.spline = new draw2d.util.spline.CatmullRomSpline(); this.MINDIST = 50, this.cheapRouter = null;
},
route: function (conn) {
var i = 0;
var fromPt = conn.getStartPoint();
var fromDir = this.getStartDirection(conn);
var toPt = conn.getEndPoint();
var toDir = this.getEndDirection(conn);
this._route(conn, toPt, toDir, fromPt, fromDir);
var ps = conn.getPoints();
conn.oldPoint = null;
conn.lineSegments = new draw2d.util.ArrayList();
conn.basePoints = new draw2d.util.ArrayList();
var splinePoints = this.spline.generate(ps, 8);
splinePoints.each(function (i, e) {
conn.addPoint(e);
});
var ps = conn.getPoints();
length = ps.getSize();
var p = ps.get(0);
var path = ["M", p.x, " ", p.y];
for (i = 1; i < length; i++) {
p = ps.get(i);
path.push("L", p.x, " ", p.y);
}
conn.svgPathString = path.join("");
}

length = ps.getSize(); 这个地方出错, 看上去是 ps对象 没有这个方法。

不知道draw2d的新版是否解决了这个问题。

临时解决就是判断浏览器, 如果是IE则用 DirectRouter 替换。

[Web Chart系列之五] 6. 实战draw2d之ConnectionRouter的更多相关文章

  1. nginx高性能WEB服务器系列之五--实战项目线上nginx多站点配置

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  2. [Web Chart系列之六] canvas Chart 导出图文件

    前言 博主正在参加CSDN2013年度博客之星评选,如果这篇文章对您有用,请投他一票: 投票地址:http://vote.blog.csdn.net/blogstaritem/blogstar2013 ...

  3. nginx高性能WEB服务器系列之九--nginx运维故障日常解决方案

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  4. nginx高性能WEB服务器系列之八--nginx日志分析与切割

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  5. nginx高性能WEB服务器系列之七--nginx反向代理

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  6. nginx高性能WEB服务器系列之六--nginx负载均衡配置+健康检查

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  7. nginx高性能WEB服务器系列之四配置文件详解

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  8. nginx高性能WEB服务器系列之三版本升级

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  9. nginx高性能WEB服务器系列之二命令管理

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

随机推荐

  1. Swift - 高级运算符介绍

    除了基本运算符之外,Swift还支持位运算和位移运算,包括:   1,按位取反运算:操作符是 ~ 2,按位与运算:操作符是 & 3,按位或运算:操作符是 | 4,按位异或运算:操作符是 ^ 5 ...

  2. 【Demo 0004】屏幕、窗体及视图基础知识

    本章学习要点       1.  了解iOS中应用程序(UIApplication)与屏幕.窗体以及视图相关基础知识:       2.  掌握应用程序常用的属性与方法:        3.  掌握窗 ...

  3. [eclipse] 三个操作技巧

    [eclipse] 三个操作技巧 1.快捷键Ctrl+Shift+i:Debug调试中直接获取方法的返回值 在下图代码中,想知道getHost(),则在调试时运行完该句代码后,选中"urlU ...

  4. 10881 - Piotr's Ants

    Problem D Piotr's Ants Time Limit: 2 seconds "One thing is for certain: there is no stopping th ...

  5. go编程基础

    可见性规则: go语言,根据函数名首字母大小写区分private,和pulic. 函数名首字母小写为private 函数名首字母大写为public

  6. QT操作Excel(通过QAxObject使用了OLE,前提是本地安装了Excel)

    新建QT GUI项目,在选择选项中勾选ActiveQT Container. #include <qaxobject.h> QAxObject *obj = new QAxObject(& ...

  7. How to append files to a .tar archive using Apache Commons Compress?(转)

    I created a copy of the tar archive and copied to entire content to it. Then I delete the old tar ar ...

  8. 2014年Windows平台软件推荐:神器小工具(骨灰级

    原文  http://www.wtoutiao.com/a/120621.html 底层工具 “If you know how to use Process Monitor competently, ...

  9. DataReader和DataSet的区别以及使用

    DataReader和DataSet这两个对象都可以将检索的关系数据存储在内存中.它们在功能使用方面非常相似,但是它们不可以相互替换. 主要区别如表所示:   DataReader DataSet 数 ...

  10. 《转》Linux下的多线程编程

    原地址:http://linux.chinaunix.net/doc/program/2001-08-11/642.shtml 1 引言 线程(thread)技术早在60年代就被提出,但真正应用多线程 ...