MxGraph changes the image size and resets the overlay position

Source: Internet
Author: User

To change the overlay position when changing the image size, you must modify the method for resetting the image size. The code in the source file is as follows:

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;};

In this method, we need to change the position of overlay. First, we need to obtain the overlays of the current image. When creating overlay, We can customize some attributes of overlay, such as index, in this way, it is easier to locate a specific overlay and change its location based on the conditions.


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 = 'radiation fig') {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 ;};
 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.