码迷,mamicode.com
首页 > 其他好文 > 详细

mxGraph改变图形大小重置overlay位置

时间:2014-06-30 07:34:11      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:javascript   mxgraph   overlay   位置   大小   

要在改变图形大小的时候改变overlay的位置,那肯定就要对重置图形大小的方法进行改造了。下面是源文件中的代码

mxGraph.prototype.resizeCells = function(cells, bounds) {
    this.model.beginUpdate();
    try {
        this.cellsResized(cells, bounds);
        this.fireEvent(new mxEventObject(mxEvent.RESIZE_CELLS, 'cells', cells, 'bounds', bounds));
    } finally {
        this.model.endUpdate();
    }
    return cells;
};

我们要在这个方法中对overlay进行位置的改变,首先要获取到当前图形的overlays,在创建overlay的时候可以自定义overlay的一些属性,比方index,这样比较容易的定位具体的某个overlay,再根据条件变更其位置。


mxGraph.prototype.resizeCells = function (cells, bounds) {
        this.model.beginUpdate();
        try {
            this.cellsResized(cells, bounds);
            this.fireEvent(new mxEventObject(mxEvent.RESIZE_CELLS, 'cells', cells, 'bounds', bounds));
            var _this=this;
            $.each(cells,function(i,item){
                var overlays = _this.getCellOverlays(item) ;
                $.each(overlays,function(j,overlay){
                    if(overlay.tooltip=='辐射图'){
                        if(ylCommon.isAllowEdit()){
                            overlay.offset.x=item.geometry.width - 35;
                        }else{
                            overlay.offset.x=item.geometry.width - 15;
                        }
                    }
                    if(overlay.image.src.indexOf('lock.png')>0){
                        overlay.offset.x=item.geometry.width - 15;
                    }
                });
            });
        } finally {
            this.model.endUpdate();
        }
        return cells;
    };




mxGraph改变图形大小重置overlay位置,布布扣,bubuko.com

mxGraph改变图形大小重置overlay位置

标签:javascript   mxgraph   overlay   位置   大小   

原文地址:http://blog.csdn.net/gua_381091614/article/details/35570759

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!