• 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,这样比較easy的定位详细的某个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;
        };
    
    


  • 相关阅读:
    node.js的querystring模块
    jsonp的作用
    js开发性能(一)
    express创建第一个web应用
    安装express
    关于【歧视】的一点事
    在统计报表中用到的sql语法记录
    北京民航总医院杀医事件
    那些自杀的人似乎更有勇气
    河南人究竟偷了多少井盖?
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5068841.html
Copyright © 2020-2023  润新知