[Web Chart系列之五] 6. 实战draw2d之ConnectionRouter
前言
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的更多相关文章
- nginx高性能WEB服务器系列之五--实战项目线上nginx多站点配置
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- [Web Chart系列之六] canvas Chart 导出图文件
前言 博主正在参加CSDN2013年度博客之星评选,如果这篇文章对您有用,请投他一票: 投票地址:http://vote.blog.csdn.net/blogstaritem/blogstar2013 ...
- nginx高性能WEB服务器系列之九--nginx运维故障日常解决方案
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之八--nginx日志分析与切割
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之七--nginx反向代理
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之六--nginx负载均衡配置+健康检查
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之四配置文件详解
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之三版本升级
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- nginx高性能WEB服务器系列之二命令管理
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
随机推荐
- Mysql InnoDB 是IOT表 锁基于索引
</pre>Mysql InnoDB 是IOT表 锁基于索引<pre>
- 初窥Linux 之 区分硬连接和软连接
一.Linux下的两种连接文件及创建方式 在Linux下面的连接文件有两种——软连接和硬连接,虽然都是连接文件,但两者却有很大的区别.一种是类似于Windows的快捷方式功能的文件(或目录),这种连接 ...
- 《sql---教学反馈系统-阶段项目1》
--修改列 --把 "Address" 栏位改名为 "Addr".这可以用以下的指令达成: --ALTER table customer change Addr ...
- STM32学习之路-SysTick的应用(时间延迟)
开发板:奋斗V5 好~ 菜B要来搞实验了.. 前面已经说了SysTick的工作原理什么的了,这里就不说了.. 先来做第一个实验: 盗自奋斗的样例,嘿嘿, 用SysTick产生1ms的基准时间,产生中断 ...
- java多线程12设计模式
1.Single Threaded Execution Pattern(单线程运行模式) 2.Immutable Pattern(一成不变的模式) 3.Guarded Suspension Patte ...
- Android 动态生成布局 (多层嵌套)
Android 除了能够载入xml文件,显示布局外,也能够代码生成布局,并通过setContentView(View view)方法显示布局.单独的一层布局,如一个主布局加一个控件(如Button\i ...
- (hdu 简单题 128道)平方和与立方和(求一个区间的立方和和平方和)
题目: 平方和与立方和 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- 破解.net程序 编译和反编译方法
原文地址:http://www.cnblogs.com/li-peng/archive/2013/01/31/2886727.html 有好多.net程序有加密狗或者有验证,如果exe或dll没有做过 ...
- codechef Sums in a Triangle题解
Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear ...
- Cocos2d-x教程(28)-ttf 字体库的使用
欢迎增加 Cocos2d-x 交流群: 193411763 转载请注明原文出处:http://blog.csdn.net/u012945598/article/details/37650843 通常为 ...